SCsub 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python
  2. import modules_builders
  3. import os
  4. Import("env")
  5. env_modules = env.Clone()
  6. # Allow modules to detect if they are being built as a module.
  7. env_modules.Append(CPPDEFINES=["GODOT_MODULE"])
  8. Export("env_modules")
  9. # Header with MODULE_*_ENABLED defines.
  10. env.Depends("modules_enabled.gen.h", Value(env.module_list))
  11. env.CommandNoCache(
  12. "modules_enabled.gen.h",
  13. Value(env.module_list),
  14. env.Run(modules_builders.generate_modules_enabled),
  15. )
  16. vs_sources = []
  17. test_headers = []
  18. # libmodule_<name>.a for each active module.
  19. for name, path in env.module_list.items():
  20. env.modules_sources = []
  21. # Name for built-in modules, (absolute) path for custom ones.
  22. base_path = path if os.path.isabs(path) else name
  23. SConscript(base_path + "/SCsub")
  24. lib = env_modules.add_library("module_%s" % name, env.modules_sources)
  25. env.Prepend(LIBS=[lib])
  26. if env["vsproj"]:
  27. vs_sources += env.modules_sources
  28. if env["tests"]:
  29. # Lookup potential headers in `tests` subfolder.
  30. import glob
  31. module_tests = sorted(glob.glob(os.path.join(base_path, "tests", "*.h")))
  32. if module_tests != []:
  33. test_headers += module_tests
  34. # Generate header to be included in `tests/test_main.cpp` to run module-specific tests.
  35. if env["tests"]:
  36. env.Depends("modules_tests.gen.h", test_headers)
  37. env.CommandNoCache(
  38. "modules_tests.gen.h",
  39. test_headers,
  40. env.Run(modules_builders.generate_modules_tests),
  41. )
  42. # libmodules.a with only register_module_types.
  43. # Must be last so that all libmodule_<name>.a libraries are on the right side
  44. # in the linker command.
  45. env.modules_sources = []
  46. env_modules.add_source_files(env.modules_sources, "register_module_types.gen.cpp")
  47. lib = env_modules.add_library("modules", env.modules_sources)
  48. env.Prepend(LIBS=[lib])
  49. if env["vsproj"]:
  50. env.modules_sources += vs_sources