summaryrefslogtreecommitdiffstats
path: root/waf_libbsd.py
diff options
context:
space:
mode:
authorChristian Mauderer <christian.mauderer@embedded-brains.de>2018-04-25 14:51:07 +0200
committerChristian Mauderer <christian.mauderer@embedded-brains.de>2018-05-03 07:09:46 +0200
commit93f19042f95364e525dae0ba002cfae8df08d1c3 (patch)
treece5d16c191e3020dc3c9c74dfb7deed525cee503 /waf_libbsd.py
parentwaf: Fix source code generators. (diff)
downloadrtems-libbsd-93f19042f95364e525dae0ba002cfae8df08d1c3.tar.bz2
waf: Generate a rtems/bsd/modules.h
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.
Diffstat (limited to '')
-rw-r--r--waf_libbsd.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/waf_libbsd.py b/waf_libbsd.py
index a0b8e9f3..1f498aa3 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
#