SCsub 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. "md5.c",
  29. "sha1.c",
  30. "sha256.c",
  31. "godot_core_mbedtls_platform.c",
  32. ]
  33. thirdparty_mbedtls_sources = [thirdparty_mbedtls_dir + file for file in thirdparty_mbedtls_sources]
  34. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_mbedtls_sources)
  35. env.core_sources += thirdparty_obj
  36. # Godot source files
  37. core_obj = []
  38. env_crypto.add_source_files(core_obj, "*.cpp")
  39. env.core_sources += core_obj
  40. # Needed to force rebuilding the core files when the thirdparty library is updated.
  41. env.Depends(core_obj, thirdparty_obj)