SCsub 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. env_thirdparty = env_crypto.Clone()
  19. env_thirdparty.disable_warnings()
  20. # Custom config file
  21. env_thirdparty.Append(
  22. CPPDEFINES=[("MBEDTLS_CONFIG_FILE", '\\"thirdparty/mbedtls/include/godot_core_mbedtls_config.h\\"')]
  23. )
  24. thirdparty_mbedtls_dir = "#thirdparty/mbedtls/library/"
  25. thirdparty_mbedtls_sources = [
  26. "aes.c",
  27. "base64.c",
  28. "constant_time.c",
  29. "md5.c",
  30. "sha1.c",
  31. "sha256.c",
  32. "godot_core_mbedtls_platform.c",
  33. ]
  34. thirdparty_mbedtls_sources = [thirdparty_mbedtls_dir + file for file in thirdparty_mbedtls_sources]
  35. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_mbedtls_sources)
  36. env.core_sources += thirdparty_obj
  37. # Godot source files
  38. core_obj = []
  39. env_crypto.add_source_files(core_obj, "*.cpp")
  40. env.core_sources += core_obj
  41. # Needed to force rebuilding the core files when the thirdparty library is updated.
  42. env.Depends(core_obj, thirdparty_obj)