[rtems-central commit] spec: Add conditional build dependencies

Sebastian Huber sebh at rtems.org
Tue Aug 31 05:08:04 UTC 2021


Module:    rtems-central
Branch:    master
Commit:    48ce03a6bb3a9c3e76bfe803e3b088998d3007f5
Changeset: http://git.rtems.org/rtems-central/commit/?id=48ce03a6bb3a9c3e76bfe803e3b088998d3007f5

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Aug 30 16:27:11 2021 +0200

spec: Add conditional build dependencies

---

 rtemsspec/build.py                         | 12 ++++++++----
 rtemsspec/tests/spec-build/bsp.yml         |  4 +++-
 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 a2956be..5dc2582 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 6be302e..d622b71 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 0000000..c27368c
--- /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



More information about the vc mailing list