The implementation of the 'lib' rule. Beyond standard syntax that rule allows simplified: 'lib a b c ;'.
(names, sources=[], requirements=[], default_build=[], usage_requirements=[])
| 446 | generators.override("builtin.prebuilt", "builtin.lib-generator") |
| 447 | |
| 448 | def lib(names, sources=[], requirements=[], default_build=[], usage_requirements=[]): |
| 449 | """The implementation of the 'lib' rule. Beyond standard syntax that rule allows |
| 450 | simplified: 'lib a b c ;'.""" |
| 451 | |
| 452 | if len(names) > 1: |
| 453 | if any(r.startswith('<name>') for r in requirements): |
| 454 | get_manager().errors()("When several names are given to the 'lib' rule\n" + |
| 455 | "it is not allowed to specify the <name> feature.") |
| 456 | |
| 457 | if sources: |
| 458 | get_manager().errors()("When several names are given to the 'lib' rule\n" + |
| 459 | "it is not allowed to specify sources.") |
| 460 | |
| 461 | project = get_manager().projects().current() |
| 462 | result = [] |
| 463 | |
| 464 | for name in names: |
| 465 | r = requirements[:] |
| 466 | |
| 467 | # Support " lib a ; " and " lib a b c ; " syntax. |
| 468 | if not sources and not any(r.startswith("<name>") for r in requirements) \ |
| 469 | and not any(r.startswith("<file") for r in requirements): |
| 470 | r.append("<name>" + name) |
| 471 | |
| 472 | result.append(targets.create_typed_metatarget(name, "LIB", sources, |
| 473 | r, |
| 474 | default_build, |
| 475 | usage_requirements)) |
| 476 | return result |
| 477 | |
| 478 | get_manager().projects().add_rule("lib", lib) |
| 479 |
nothing calls this directly
no test coverage detected