[PATCH v3 3/6] waf: Generate a rtems/bsd/modules.h

Christian Mauderer christian.mauderer at embedded-brains.de
Wed May 2 13:15:04 UTC 2018


The generated file defines a RTEMS_BSD_MODULE_xxx for each enabled
module. That is usefull for conditional compilation depending on whether
a module is build not.

Update #3351.
---
 waf_libbsd.py | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/waf_libbsd.py b/waf_libbsd.py
index f8fcf00f..0972cf2c 100644
--- a/waf_libbsd.py
+++ b/waf_libbsd.py
@@ -37,6 +37,7 @@ from __future__ import print_function
 import os
 import sys
 import tempfile
+import re
 
 import builder
 
@@ -155,6 +156,8 @@ class Builder(builder.ModuleManager):
         # Localize the config.
         #
         config = self.getConfiguration()
+        module_header_path = "rtems/bsd"
+        module_header_name = "modules.h"
 
         #
         #
@@ -257,6 +260,30 @@ class Builder(builder.ModuleManager):
                         is_copy = True)
 
         #
+        # Generate a header that contains information about enabled modules
+        #
+        def rtems_libbsd_modules_h_gen(self):
+            output = ""
+            output += '/*\n'
+            output += ' * This file contains a list of modules that have been\n'
+            output += ' * enabled during libbsd build. It is a generated file\n'
+            output += ' * DO NOT EDIT MANUALLY.\n'
+            output += ' */'
+            output += '\n'
+            output += '#ifndef RTEMS_BSD_MODULES_H\n'
+            for mod in config['modules-enabled']:
+                modname = re.sub("[^A-Za-z0-9]", "_", mod.upper())
+                output += '#define RTEMS_BSD_MODULE_{} 1\n'.format(modname)
+            output += '#endif /* RTEMS_BSD_MODULES_H */\n'
+            self.outputs[0].write(output)
+        modules_h_file_with_path = os.path.join(buildinclude,
+                                                module_header_path,
+                                                module_header_name)
+        bld(rule = rtems_libbsd_modules_h_gen,
+            target = modules_h_file_with_path,
+            before = ['c', 'cxx'])
+
+        #
         # Add the specific rule based builders
         #
 
@@ -457,6 +484,11 @@ class Builder(builder.ModuleManager):
                                       cwd = start_dir,
                                       relative_trick = True)
 
+        bld.install_files(os.path.join("${PREFIX}", arch_inc_path,
+                                       module_header_path),
+                          modules_h_file_with_path,
+                          cwd = bld.path)
+
         #
         # Tests
         #
-- 
2.13.6



More information about the devel mailing list