diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-08-30 16:27:11 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-08-30 16:27:11 +0200 |
commit | 48ce03a6bb3a9c3e76bfe803e3b088998d3007f5 (patch) | |
tree | de24cc1d774271f66e0a45f44cd1d0014ac4e0cf | |
parent | spec: Document build option (diff) | |
download | rtems-central-48ce03a6bb3a9c3e76bfe803e3b088998d3007f5.tar.bz2 |
spec: Add conditional build dependencies
-rw-r--r-- | rtemsspec/build.py | 12 | ||||
-rw-r--r-- | rtemsspec/tests/spec-build/bsp.yml | 4 | ||||
-rw-r--r-- | spec/spec/build-dependency-conditional.yml | 27 |
3 files changed, 38 insertions, 5 deletions
diff --git a/rtemsspec/build.py b/rtemsspec/build.py index a2956be6..5dc25822 100644 --- a/rtemsspec/build.py +++ b/rtemsspec/build.py @@ -26,7 +26,7 @@ from typing import Dict, List -from rtemsspec.items import Item, ItemCache +from rtemsspec.items import is_enabled, Item, ItemCache BSPMap = Dict[str, Dict[str, Item]] ItemMap = Dict[str, Item] @@ -64,12 +64,16 @@ _EXTEND_SOURCE_FILES = { "start-file": _extend_by_source, } +_BUILD_ROLES = ["build-dependency", "build-dependency-conditional"] + def _gather_source_files(item: Item, enabled: List[str], source_files: List[str]) -> None: - for parent in item.parents("build-dependency"): - if parent.is_enabled(enabled): - _gather_source_files(parent, enabled, source_files) + for link in item.links_to_parents(_BUILD_ROLES): + if (link.role == "build-dependency" or is_enabled( + enabled, + link["enabled-by"])) and link.item.is_enabled(enabled): + _gather_source_files(link.item, enabled, source_files) _EXTEND_SOURCE_FILES[item["build-type"]](item, source_files) diff --git a/rtemsspec/tests/spec-build/bsp.yml b/rtemsspec/tests/spec-build/bsp.yml index 6be302e5..d622b71b 100644 --- a/rtemsspec/tests/spec-build/bsp.yml +++ b/rtemsspec/tests/spec-build/bsp.yml @@ -6,7 +6,9 @@ install: - source: - abc links: -- role: build-dependency +- enabled-by: + not: false + role: build-dependency-conditional uid: o - role: build-dependency uid: op diff --git a/spec/spec/build-dependency-conditional.yml b/spec/spec/build-dependency-conditional.yml new file mode 100644 index 00000000..c27368ca --- /dev/null +++ b/spec/spec/build-dependency-conditional.yml @@ -0,0 +1,27 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: spec-member + uid: root +- role: spec-refinement + spec-key: role + spec-value: build-dependency-conditional + uid: link +spec-description: null +spec-example: null +spec-info: + dict: + attributes: + enabled-by: + description: | + It shall define under which conditions the build dependency is + enabled. + spec-type: enabled-by + description: | + It defines the build dependency conditional role of links. + mandatory-attributes: all +spec-name: Build Dependency Conditional Link Role +spec-type: build-dependency-conditional +type: spec |