From 93f19042f95364e525dae0ba002cfae8df08d1c3 Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Wed, 25 Apr 2018 14:51:07 +0200 Subject: 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. --- waf_libbsd.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'waf_libbsd.py') 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" # # @@ -256,6 +259,30 @@ class Builder(builder.ModuleManager): source = header, 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 # -- cgit v1.2.3