[PATCH v1 2/6] waf: Add path-mappings feature

Jan Sommer jan.sommer at dlr.de
Fri Aug 14 19:57:49 UTC 2020


- path-mappings allow to fix autogenerated include paths for some corner
cases of target platforms without the need to change the build system
- Currently used for i386 based bsps
---
 libbsd.py     |  8 ++++++++
 waf_libbsd.py | 13 +++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/libbsd.py b/libbsd.py
index 511de7af..e02226f3 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -90,6 +90,14 @@ _defaults = {
     'cpu-include-paths': ['rtemsbsd/@CPU@/include',
                           'freebsd/sys/@CPU@/include'],
 
+    #
+    # Map paths based on RTEMS naming to FreeBSD naming.
+    #
+    'path-mappings': [     # (source, targets)
+    # i386
+    ('freebsd/sys/i386/include', ['freebsd/sys/x86/include', 'freebsd/sys/i386/include']),
+    ],
+
     # The path where headers will be copied during build.
     'build-include-path': ['build-include'],
 
diff --git a/waf_libbsd.py b/waf_libbsd.py
index 9ac5bf35..14f2ae78 100644
--- a/waf_libbsd.py
+++ b/waf_libbsd.py
@@ -210,8 +210,6 @@ class Builder(builder.ModuleManager):
         buildinclude = 'build-include'
         if 'cpu-include-paths' in config:
             cpu = bld.get_env()['RTEMS_ARCH']
-            if cpu == "i386":
-                includes += ['freebsd/sys/x86/include']
             for i in config['cpu-include-paths']:
                 includes += [i.replace('@CPU@', cpu)]
         if 'include-paths' in config:
@@ -222,6 +220,17 @@ class Builder(builder.ModuleManager):
                 buildinclude = buildinclude[0]
         includes += [buildinclude]
 
+        #
+        # Path mappings
+        #
+        if 'path-mappings' in config:
+            for source, target in config['path-mappings']:
+                if source in includes:
+                    target = [target] if isinstance(target, str) else target
+                    i = includes.index(source)
+                    includes.remove(source)
+                    includes[i:i] = target
+
         #
         # Collect the libbsd uses
         #
-- 
2.17.1



More information about the devel mailing list