SCons: Generate header with info on which modules are enabled
We already had `MODULE_*_ENABLED` defines but only in the modules
environment, and a few custom `*_ENABLED` defines in the main env
when we needed the information in core.
Now this is defined in a single header which can be included in the
files that need this information.
(cherry picked from commit b7297fb39c
)
This commit is contained in:
parent
aecb1c32ab
commit
cbbea6084d
|
@ -1,8 +1,8 @@
|
|||
"""Functions used to generate source files during build time
|
||||
|
||||
All such functions are invoked in a subprocess on Windows to prevent build flakiness.
|
||||
|
||||
"""
|
||||
|
||||
from platform_methods import subprocess_main
|
||||
from compat import iteritems, itervalues, open_utf8, escape_string, byte_to_str
|
||||
|
||||
|
|
24
methods.py
24
methods.py
|
@ -238,27 +238,25 @@ def write_modules(modules):
|
|||
except IOError:
|
||||
pass
|
||||
|
||||
modules_cpp = (
|
||||
"""
|
||||
// modules.cpp - THIS FILE IS GENERATED, DO NOT EDIT!!!!!!!
|
||||
modules_cpp = """// register_module_types.gen.cpp
|
||||
/* THIS FILE IS GENERATED DO NOT EDIT */
|
||||
#include "register_module_types.h"
|
||||
|
||||
"""
|
||||
+ includes_cpp
|
||||
+ """
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
%s
|
||||
|
||||
void register_module_types() {
|
||||
"""
|
||||
+ register_cpp
|
||||
+ """
|
||||
%s
|
||||
}
|
||||
|
||||
void unregister_module_types() {
|
||||
"""
|
||||
+ unregister_cpp
|
||||
+ """
|
||||
%s
|
||||
}
|
||||
"""
|
||||
""" % (
|
||||
includes_cpp,
|
||||
register_cpp,
|
||||
unregister_cpp,
|
||||
)
|
||||
|
||||
# NOTE: It is safe to generate this file here, since this is still executed serially
|
||||
|
|
|
@ -4,19 +4,18 @@ Import("env")
|
|||
|
||||
import os
|
||||
|
||||
import modules_builders
|
||||
|
||||
env_modules = env.Clone()
|
||||
|
||||
Export("env_modules")
|
||||
|
||||
env.modules_sources = []
|
||||
env.CommandNoCache("modules_enabled.gen.h", Value(env.module_list), modules_builders.generate_modules_enabled)
|
||||
|
||||
env.modules_sources = []
|
||||
env_modules.add_source_files(env.modules_sources, "register_module_types.gen.cpp")
|
||||
|
||||
for name, path in env.module_list.items():
|
||||
if name in env.disabled_modules:
|
||||
continue
|
||||
|
||||
env_modules.Append(CPPDEFINES=["MODULE_" + name.upper() + "_ENABLED"])
|
||||
if not os.path.isabs(path):
|
||||
SConscript(name + "/SCsub") # Built-in.
|
||||
else:
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
"""Functions used to generate source files during build time
|
||||
|
||||
All such functions are invoked in a subprocess on Windows to prevent build flakiness.
|
||||
"""
|
||||
|
||||
from platform_methods import subprocess_main
|
||||
|
||||
|
||||
def generate_modules_enabled(target, source, env):
|
||||
with open(target[0].path, "w") as f:
|
||||
for module in env.module_list:
|
||||
f.write("#define %s\n" % ("MODULE_" + module.upper() + "_ENABLED"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
subprocess_main(globals())
|
|
@ -31,9 +31,7 @@
|
|||
#ifndef REGISTER_MODULE_TYPES_H
|
||||
#define REGISTER_MODULE_TYPES_H
|
||||
|
||||
//
|
||||
|
||||
void register_module_types();
|
||||
void unregister_module_types();
|
||||
|
||||
#endif
|
||||
#endif // REGISTER_MODULE_TYPES_H
|
||||
|
|
Loading…
Reference in New Issue