mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-23 00:45:37 +08:00
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.
This commit is contained in:
parent
1588cf1e03
commit
93f19042f9
@ -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
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user