SCsub 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python
  2. Import("env")
  3. env_crypto = env.Clone()
  4. is_builtin = env["builtin_mbedtls"]
  5. has_module = env["module_mbedtls_enabled"]
  6. thirdparty_obj = []
  7. if is_builtin or not has_module:
  8. # Use our headers for builtin or if the module is not going to be compiled.
  9. # We decided not to depend on system mbedtls just for these few files that can
  10. # be easily extracted.
  11. env_crypto.Prepend(CPPPATH=["#thirdparty/mbedtls/include"])
  12. # MbedTLS core functions (for CryptoCore).
  13. # If the mbedtls module is compiled we don't need to add the .c files with our
  14. # custom config since they will be built by the module itself.
  15. # Only if the module is not enabled, we must compile here the required sources
  16. # to make a "light" build with only the necessary mbedtls files.
  17. if not has_module:
  18. # Minimal mbedTLS config file
  19. env_crypto.Append(
  20. CPPDEFINES=[("MBEDTLS_CONFIG_FILE", '\\"thirdparty/mbedtls/include/godot_core_mbedtls_config.h\\"')]
  21. )
  22. # Build minimal mbedTLS library (MD5/SHA/Base64/AES).
  23. env_thirdparty = env_crypto.Clone()
  24. env_thirdparty.disable_warnings()
  25. thirdparty_mbedtls_dir = "#thirdparty/mbedtls/library/"
  26. thirdparty_mbedtls_sources = [
  27. "aes.c",
  28. "base64.c",
  29. "constant_time.c",
  30. "ctr_drbg.c",
  31. "entropy.c",
  32. "md5.c",
  33. "sha1.c",
  34. "sha256.c",
  35. "godot_core_mbedtls_platform.c",
  36. ]
  37. thirdparty_mbedtls_sources = [thirdparty_mbedtls_dir + file for file in thirdparty_mbedtls_sources]
  38. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_mbedtls_sources)
  39. # Needed to force rebuilding the library when the configuration file is updated.
  40. env_thirdparty.Depends(thirdparty_obj, "#thirdparty/mbedtls/include/godot_core_mbedtls_config.h")
  41. env.core_sources += thirdparty_obj
  42. elif is_builtin:
  43. # Module mbedTLS config file
  44. env_crypto.Append(
  45. CPPDEFINES=[("MBEDTLS_CONFIG_FILE", '\\"thirdparty/mbedtls/include/godot_module_mbedtls_config.h\\"')]
  46. )
  47. # Needed to force rebuilding the core files when the configuration file is updated.
  48. thirdparty_obj = ["#thirdparty/mbedtls/include/godot_module_mbedtls_config.h"]
  49. # Godot source files
  50. core_obj = []
  51. env_crypto.add_source_files(core_obj, "*.cpp")
  52. env.core_sources += core_obj
  53. # Needed to force rebuilding the core files when the thirdparty library is updated.
  54. env.Depends(core_obj, thirdparty_obj)