SCsub 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. Import("env_modules")
  5. env_mbed_tls = env_modules.Clone()
  6. # Thirdparty source files
  7. thirdparty_obj = []
  8. if env["builtin_mbedtls"]:
  9. thirdparty_sources = [
  10. "aes.c",
  11. "aesce.c",
  12. "aesni.c",
  13. "aria.c",
  14. "asn1parse.c",
  15. "asn1write.c",
  16. "base64.c",
  17. "bignum.c",
  18. "bignum_core.c",
  19. "bignum_mod_raw.c",
  20. "camellia.c",
  21. "ccm.c",
  22. "chacha20.c",
  23. "chachapoly.c",
  24. "cipher.c",
  25. "cipher_wrap.c",
  26. "cmac.c",
  27. "constant_time.c",
  28. "ctr_drbg.c",
  29. "debug.c",
  30. "des.c",
  31. "dhm.c",
  32. "ecdh.c",
  33. "ecdsa.c",
  34. "ecjpake.c",
  35. "ecp.c",
  36. "ecp_curves.c",
  37. "entropy.c",
  38. "entropy_poll.c",
  39. "error.c",
  40. "gcm.c",
  41. "hkdf.c",
  42. "hmac_drbg.c",
  43. "md.c",
  44. "md5.c",
  45. "memory_buffer_alloc.c",
  46. "mps_reader.c",
  47. "mps_trace.c",
  48. "net_sockets.c",
  49. "nist_kw.c",
  50. "oid.c",
  51. "padlock.c",
  52. "pem.c",
  53. "pk.c",
  54. "pk_ecc.c",
  55. "pk_wrap.c",
  56. "pkcs12.c",
  57. "pkcs5.c",
  58. "pkcs7.c",
  59. "pkparse.c",
  60. "pkwrite.c",
  61. "platform.c",
  62. "platform_util.c",
  63. "poly1305.c",
  64. "psa_crypto.c",
  65. "psa_crypto_aead.c",
  66. "psa_crypto_cipher.c",
  67. "psa_crypto_client.c",
  68. "psa_crypto_driver_wrappers_no_static.c",
  69. "psa_crypto_ecp.c",
  70. "psa_crypto_ffdh.c",
  71. "psa_crypto_hash.c",
  72. "psa_crypto_mac.c",
  73. "psa_crypto_pake.c",
  74. "psa_crypto_rsa.c",
  75. "psa_crypto_se.c",
  76. "psa_crypto_slot_management.c",
  77. "psa_crypto_storage.c",
  78. "psa_its_file.c",
  79. "psa_util.c",
  80. "ripemd160.c",
  81. "rsa.c",
  82. "rsa_alt_helpers.c",
  83. "sha1.c",
  84. "sha3.c",
  85. "sha256.c",
  86. "sha512.c",
  87. "ssl_cache.c",
  88. "ssl_ciphersuites.c",
  89. "ssl_client.c",
  90. "ssl_cookie.c",
  91. "ssl_debug_helpers_generated.c",
  92. "ssl_msg.c",
  93. "ssl_ticket.c",
  94. "ssl_tls.c",
  95. "ssl_tls12_client.c",
  96. "ssl_tls12_server.c",
  97. "ssl_tls13_client.c",
  98. "ssl_tls13_generic.c",
  99. "ssl_tls13_keys.c",
  100. "ssl_tls13_server.c",
  101. "threading.c",
  102. "timing.c",
  103. "version.c",
  104. "version_features.c",
  105. "x509.c",
  106. "x509_create.c",
  107. "x509_crl.c",
  108. "x509_crt.c",
  109. "x509_csr.c",
  110. "x509write.c",
  111. "x509write_crt.c",
  112. "x509write_csr.c",
  113. ]
  114. thirdparty_dir = "#thirdparty/mbedtls/library/"
  115. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  116. env_mbed_tls.Prepend(CPPPATH=["#thirdparty/mbedtls/include/"])
  117. config_path = "thirdparty/mbedtls/include/godot_module_mbedtls_config.h"
  118. config_path = f"<{config_path}>" if env_mbed_tls["ninja"] and env_mbed_tls.msvc else f'\\"{config_path}\\"'
  119. env_mbed_tls.Append(CPPDEFINES=[("MBEDTLS_CONFIG_FILE", config_path)])
  120. env_thirdparty = env_mbed_tls.Clone()
  121. env_thirdparty.disable_warnings()
  122. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  123. env_thirdparty.Depends(thirdparty_obj, "#thirdparty/mbedtls/include/godot_module_mbedtls_config.h")
  124. env.modules_sources += thirdparty_obj
  125. # Godot source files
  126. module_obj = []
  127. env_mbed_tls.add_source_files(module_obj, "*.cpp")
  128. if env["tests"]:
  129. env_mbed_tls.Append(CPPDEFINES=["TESTS_ENABLED"])
  130. env_mbed_tls.add_source_files(module_obj, "./tests/*.cpp")
  131. if env["disable_exceptions"]:
  132. env_mbed_tls.Append(CPPDEFINES=["DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS"])
  133. env.modules_sources += module_obj
  134. # Needed to force rebuilding the module files when the thirdparty library is updated.
  135. env.Depends(module_obj, thirdparty_obj)