SCsub 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python
  2. import modules_builders
  3. import os
  4. Import("env")
  5. env_modules = env.Clone()
  6. Export("env_modules")
  7. # Header with MODULE_*_ENABLED defines.
  8. env.CommandNoCache(
  9. "modules_enabled.gen.h",
  10. Value(env.module_list),
  11. env.Run(
  12. modules_builders.generate_modules_enabled,
  13. "Generating enabled modules header.",
  14. # NOTE: No need to run in subprocess since this is still executed serially.
  15. subprocess=False,
  16. ),
  17. )
  18. # Header to be included in `tests/test_main.cpp` to run module-specific tests.
  19. if env["tests"]:
  20. env.CommandNoCache(
  21. "modules_tests.gen.h",
  22. Value(env.module_list),
  23. env.Run(
  24. modules_builders.generate_modules_tests,
  25. "Generating modules tests header.",
  26. # NOTE: No need to run in subprocess since this is still executed serially.
  27. subprocess=False,
  28. ),
  29. )
  30. env.AlwaysBuild("modules_tests.gen.h")
  31. vs_sources = []
  32. # libmodule_<name>.a for each active module.
  33. for name, path in env.module_list.items():
  34. env.modules_sources = []
  35. if not os.path.isabs(path):
  36. SConscript(name + "/SCsub") # Built-in.
  37. else:
  38. SConscript(path + "/SCsub") # Custom.
  39. lib = env_modules.add_library("module_%s" % name, env.modules_sources)
  40. env.Prepend(LIBS=[lib])
  41. if env["vsproj"]:
  42. vs_sources += env.modules_sources
  43. # libmodules.a with only register_module_types.
  44. # Must be last so that all libmodule_<name>.a libraries are on the right side
  45. # in the linker command.
  46. env.modules_sources = []
  47. env_modules.add_source_files(env.modules_sources, "register_module_types.gen.cpp")
  48. lib = env_modules.add_library("modules", env.modules_sources)
  49. env.Prepend(LIBS=[lib])
  50. if env["vsproj"]:
  51. env.modules_sources += vs_sources