SCsub 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. Import("env_modules")
  5. env_regex = env_modules.Clone()
  6. # Thirdparty source files
  7. thirdparty_obj = []
  8. if env["builtin_pcre2"]:
  9. thirdparty_dir = "#thirdparty/pcre2/src/"
  10. thirdparty_flags = ["PCRE2_STATIC", "HAVE_CONFIG_H", "SUPPORT_UNICODE"]
  11. if env["builtin_pcre2_with_jit"]:
  12. thirdparty_flags.append("SUPPORT_JIT")
  13. thirdparty_sources = [
  14. "pcre2_auto_possess.c",
  15. "pcre2_chartables.c",
  16. "pcre2_chkdint.c",
  17. "pcre2_compile.c",
  18. "pcre2_config.c",
  19. "pcre2_context.c",
  20. "pcre2_convert.c",
  21. "pcre2_dfa_match.c",
  22. "pcre2_error.c",
  23. "pcre2_extuni.c",
  24. "pcre2_find_bracket.c",
  25. "pcre2_jit_compile.c",
  26. # "pcre2_jit_match.c", "pcre2_jit_misc.c", # Included in `pcre2_jit_compile.c`.
  27. "pcre2_maketables.c",
  28. "pcre2_match.c",
  29. "pcre2_match_data.c",
  30. "pcre2_newline.c",
  31. "pcre2_ord2utf.c",
  32. "pcre2_pattern_info.c",
  33. "pcre2_script_run.c",
  34. "pcre2_serialize.c",
  35. "pcre2_string_utils.c",
  36. "pcre2_study.c",
  37. "pcre2_substitute.c",
  38. "pcre2_substring.c",
  39. "pcre2_tables.c",
  40. "pcre2_ucd.c",
  41. # "pcre2_ucptables.c", # Included in `pcre2_tables.c`.
  42. "pcre2_valid_utf.c",
  43. "pcre2_xclass.c",
  44. ]
  45. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  46. env_regex.Prepend(CPPPATH=[thirdparty_dir])
  47. env_regex.Append(CPPDEFINES=thirdparty_flags)
  48. def pcre2_builtin(width):
  49. env_pcre2 = env_regex.Clone()
  50. env_pcre2.disable_warnings()
  51. env_pcre2["OBJSUFFIX"] = "_" + width + env_pcre2["OBJSUFFIX"]
  52. env_pcre2.Append(CPPDEFINES=[("PCRE2_CODE_UNIT_WIDTH", width)])
  53. env_pcre2.add_source_files(thirdparty_obj, thirdparty_sources)
  54. pcre2_builtin("16")
  55. pcre2_builtin("32")
  56. env.modules_sources += thirdparty_obj
  57. # Godot source files
  58. module_obj = []
  59. env_regex.Append(CPPDEFINES=[("PCRE2_CODE_UNIT_WIDTH", 0)])
  60. env_regex.add_source_files(module_obj, "*.cpp")
  61. env.modules_sources += module_obj
  62. # Needed to force rebuilding the module files when the thirdparty library is updated.
  63. env.Depends(module_obj, thirdparty_obj)