SCsub 2.2 KB

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