Debian Codegraph @

core/crypto/SCsub

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