SCsub 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/usr/bin/env python
  2. Import('env')
  3. env.core_sources = []
  4. # Generate global defaults
  5. gd_call = ""
  6. gd_inc = ""
  7. for x in env.global_defaults:
  8. env.core_sources.append("#platform/" + x + "/globals/global_defaults.cpp")
  9. gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n'
  10. gd_call += "\tregister_" + x + "_global_defaults();\n"
  11. gd_cpp = '#include "project_settings.h"\n'
  12. gd_cpp += gd_inc
  13. gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n"
  14. f = open("global_defaults.gen.cpp", "w")
  15. f.write(gd_cpp)
  16. f.close()
  17. # Generate AES256 script encryption key
  18. import os
  19. txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
  20. if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
  21. e = os.environ["SCRIPT_AES256_ENCRYPTION_KEY"]
  22. txt = ""
  23. ec_valid = True
  24. if (len(e) != 64):
  25. ec_valid = False
  26. else:
  27. for i in range(len(e) >> 1):
  28. if (i > 0):
  29. txt += ","
  30. txts = "0x" + e[i * 2:i * 2 + 2]
  31. try:
  32. int(txts, 16)
  33. except:
  34. ec_valid = False
  35. txt += txts
  36. if (not ec_valid):
  37. txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
  38. print("Invalid AES256 encryption key, not 64 bits hex: " + e)
  39. f = open("script_encryption_key.gen.cpp", "w")
  40. f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
  41. f.close()
  42. # Add required thirdparty code. Header paths are hardcoded, we don't need to append
  43. # to the include path (saves a few chars on the compiler invocation for touchy MSVC...)
  44. thirdparty_dir = "#thirdparty/misc/"
  45. thirdparty_sources = [
  46. # C sources
  47. "base64.c",
  48. "fastlz.c",
  49. "sha256.c",
  50. "smaz.c",
  51. # C++ sources
  52. "aes256.cpp",
  53. "hq2x.cpp",
  54. "md5.cpp",
  55. "pcg.cpp",
  56. "triangulator.cpp",
  57. ]
  58. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  59. env.add_source_files(env.core_sources, thirdparty_sources)
  60. # Minizip library, can be unbundled in theory
  61. # However, our version has some custom modifications, so it won't compile with the system one
  62. thirdparty_minizip_dir = "#thirdparty/minizip/"
  63. thirdparty_minizip_sources = [
  64. "ioapi.c",
  65. "unzip.c",
  66. "zip.c",
  67. ]
  68. thirdparty_minizip_sources = [thirdparty_minizip_dir + file for file in thirdparty_minizip_sources]
  69. env.add_source_files(env.core_sources, thirdparty_minizip_sources)
  70. if 'builtin_zstd' in env and env['builtin_zstd']:
  71. SConscript("#thirdparty/zstd/SCsub")
  72. # Godot's own sources
  73. env.add_source_files(env.core_sources, "*.cpp")
  74. # Make binders
  75. import make_binders
  76. env.CommandNoCache(['method_bind.gen.inc', 'method_bind_ext.gen.inc'], 'make_binders.py', make_binders.run)
  77. # Chain load SCsubs
  78. SConscript('os/SCsub')
  79. SConscript('math/SCsub')
  80. SConscript('io/SCsub')
  81. SConscript('bind/SCsub')
  82. SConscript('helper/SCsub')
  83. # Build it all as a library
  84. lib = env.add_library("core", env.core_sources)
  85. env.Prepend(LIBS=[lib])
  86. Export('env')