SCsub 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 "globals.h"\n'
  12. gd_cpp += gd_inc
  13. gd_cpp += "void Globals::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 \"globals.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. "triangulator.cpp",
  56. ]
  57. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  58. env.add_source_files(env.core_sources, thirdparty_sources)
  59. # Minizip library, can be unbundled in theory
  60. # However, our version has some custom modifications, so it won't compile with the system one
  61. thirdparty_minizip_dir = "#thirdparty/minizip/"
  62. thirdparty_minizip_sources = [
  63. "ioapi.c",
  64. "unzip.c",
  65. "zip.c",
  66. ]
  67. thirdparty_minizip_sources = [thirdparty_minizip_dir + file for file in thirdparty_minizip_sources]
  68. env.add_source_files(env.core_sources, thirdparty_minizip_sources)
  69. # Godot's own sources
  70. env.add_source_files(env.core_sources, "*.cpp")
  71. # Make binders
  72. import make_binders
  73. env.CommandNoCache(['method_bind.gen.inc', 'method_bind_ext.gen.inc'], 'make_binders.py', make_binders.run)
  74. # Chain load SCsubs
  75. SConscript('os/SCsub')
  76. SConscript('math/SCsub')
  77. SConscript('io/SCsub')
  78. SConscript('bind/SCsub')
  79. SConscript('helper/SCsub')
  80. # Build it all as a library
  81. lib = env.add_library("core", env.core_sources)
  82. env.Prepend(LIBS=[lib])
  83. Export('env')