| 480 | |
| 481 | # Updated to trunk@47077 |
| 482 | class SearchedLibGenerator (generators.Generator): |
| 483 | def __init__ (self, id = 'SearchedLibGenerator', composing = False, source_types = [], target_types_and_names = ['SEARCHED_LIB'], requirements = []): |
| 484 | # TODO: the comment below looks strange. There are no requirements! |
| 485 | # The requirements cause the generators to be tried *only* when we're building |
| 486 | # lib target and there's 'search' feature. This seems ugly --- all we want |
| 487 | # is make sure SearchedLibGenerator is not invoked deep in transformation |
| 488 | # search. |
| 489 | generators.Generator.__init__ (self, id, composing, source_types, target_types_and_names, requirements) |
| 490 | |
| 491 | def run(self, project, name, prop_set, sources): |
| 492 | |
| 493 | if not name: |
| 494 | return None |
| 495 | |
| 496 | # If name is empty, it means we're called not from top-level. |
| 497 | # In this case, we just fail immediately, because SearchedLibGenerator |
| 498 | # cannot be used to produce intermediate targets. |
| 499 | |
| 500 | properties = prop_set.raw () |
| 501 | shared = '<link>shared' in properties |
| 502 | |
| 503 | a = virtual_target.NullAction (project.manager(), prop_set) |
| 504 | |
| 505 | real_name = feature.get_values ('<name>', properties) |
| 506 | if real_name: |
| 507 | real_name = real_name[0] |
| 508 | else: |
| 509 | real_nake = name |
| 510 | search = feature.get_values('<search>', properties) |
| 511 | usage_requirements = property_set.create(['<xdll-path>' + p for p in search]) |
| 512 | t = SearchedLibTarget(name, project, shared, real_name, search, a) |
| 513 | |
| 514 | # We return sources for a simple reason. If there's |
| 515 | # lib png : z : <name>png ; |
| 516 | # the 'z' target should be returned, so that apps linking to |
| 517 | # 'png' will link to 'z', too. |
| 518 | return(usage_requirements, [b2.manager.get_manager().virtual_targets().register(t)] + sources) |
| 519 | |
| 520 | generators.register (SearchedLibGenerator ()) |
| 521 | |