| 1 |
|
| 2 |
from misc.utility.scons_hints import * |
| 3 |
|
| 4 |
import os |
| 5 |
|
| 6 |
import core_builders |
| 7 |
|
| 8 |
import methods |
| 9 |
|
| 10 |
Import("env") |
| 11 |
|
| 12 |
env.core_sources = [] |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
thirdparty_obj = [] |
| 17 |
|
| 18 |
env_thirdparty = env.Clone() |
| 19 |
env_thirdparty.disable_warnings() |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
thirdparty_misc_dir = "#thirdparty/misc/" |
| 24 |
thirdparty_misc_sources = [ |
| 25 |
|
| 26 |
"fastlz.c", |
| 27 |
"r128.c", |
| 28 |
"smaz.c", |
| 29 |
|
| 30 |
"pcg.cpp", |
| 31 |
"polypartition.cpp", |
| 32 |
"smolv.cpp", |
| 33 |
] |
| 34 |
thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_misc_sources] |
| 35 |
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_misc_sources) |
| 36 |
|
| 37 |
|
| 38 |
if env["brotli"] and env["builtin_brotli"]: |
| 39 |
thirdparty_brotli_dir = "#thirdparty/brotli/" |
| 40 |
thirdparty_brotli_sources = [ |
| 41 |
"common/constants.c", |
| 42 |
"common/context.c", |
| 43 |
"common/dictionary.c", |
| 44 |
"common/platform.c", |
| 45 |
"common/shared_dictionary.c", |
| 46 |
"common/transform.c", |
| 47 |
"dec/bit_reader.c", |
| 48 |
"dec/decode.c", |
| 49 |
"dec/huffman.c", |
| 50 |
"dec/prefix.c", |
| 51 |
"dec/state.c", |
| 52 |
"dec/static_init.c", |
| 53 |
] |
| 54 |
thirdparty_brotli_sources = [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources] |
| 55 |
|
| 56 |
env_thirdparty.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"]) |
| 57 |
env.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"]) |
| 58 |
|
| 59 |
if env.get("use_ubsan") or env.get("use_asan") or env.get("use_tsan") or env.get("use_lsan") or env.get("use_msan"): |
| 60 |
env_thirdparty.Append(CPPDEFINES=["BROTLI_BUILD_PORTABLE"]) |
| 61 |
|
| 62 |
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_brotli_sources) |
| 63 |
|
| 64 |
|
| 65 |
if env["builtin_clipper2"]: |
| 66 |
thirdparty_clipper_dir = "#thirdparty/clipper2/" |
| 67 |
thirdparty_clipper_sources = [ |
| 68 |
"src/clipper.engine.cpp", |
| 69 |
"src/clipper.offset.cpp", |
| 70 |
"src/clipper.rectclip.cpp", |
| 71 |
] |
| 72 |
thirdparty_clipper_sources = [thirdparty_clipper_dir + file for file in thirdparty_clipper_sources] |
| 73 |
|
| 74 |
env_thirdparty.Prepend(CPPPATH=[thirdparty_clipper_dir + "include"]) |
| 75 |
env.Prepend(CPPPATH=[thirdparty_clipper_dir + "include"]) |
| 76 |
|
| 77 |
env_thirdparty.Append(CPPDEFINES=["CLIPPER2_ENABLED"]) |
| 78 |
env.Append(CPPDEFINES=["CLIPPER2_ENABLED"]) |
| 79 |
|
| 80 |
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_clipper_sources) |
| 81 |
|
| 82 |
|
| 83 |
if env["builtin_zlib"]: |
| 84 |
thirdparty_zlib_dir = "#thirdparty/zlib/" |
| 85 |
thirdparty_zlib_sources = [ |
| 86 |
"adler32.c", |
| 87 |
"compress.c", |
| 88 |
"crc32.c", |
| 89 |
"deflate.c", |
| 90 |
"inffast.c", |
| 91 |
"inflate.c", |
| 92 |
"inftrees.c", |
| 93 |
"trees.c", |
| 94 |
"uncompr.c", |
| 95 |
"zutil.c", |
| 96 |
] |
| 97 |
thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources] |
| 98 |
|
| 99 |
env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir]) |
| 100 |
|
| 101 |
env.Prepend(CPPPATH=[thirdparty_zlib_dir]) |
| 102 |
if env.dev_build: |
| 103 |
env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"]) |
| 104 |
|
| 105 |
env.Append(CPPDEFINES=["ZLIB_DEBUG"]) |
| 106 |
|
| 107 |
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_zlib_sources) |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
thirdparty_minizip_dir = "#thirdparty/minizip/" |
| 112 |
thirdparty_minizip_sources = ["ioapi.c", "unzip.c", "zip.c"] |
| 113 |
thirdparty_minizip_sources = [thirdparty_minizip_dir + file for file in thirdparty_minizip_sources] |
| 114 |
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_minizip_sources) |
| 115 |
|
| 116 |
|
| 117 |
if env["builtin_zstd"]: |
| 118 |
thirdparty_zstd_dir = "#thirdparty/zstd/" |
| 119 |
thirdparty_zstd_sources = [ |
| 120 |
"common/debug.c", |
| 121 |
"common/entropy_common.c", |
| 122 |
"common/error_private.c", |
| 123 |
"common/fse_decompress.c", |
| 124 |
"common/pool.c", |
| 125 |
"common/threading.c", |
| 126 |
"common/xxhash.c", |
| 127 |
"common/zstd_common.c", |
| 128 |
"compress/fse_compress.c", |
| 129 |
"compress/hist.c", |
| 130 |
"compress/huf_compress.c", |
| 131 |
"compress/zstd_compress.c", |
| 132 |
"compress/zstd_double_fast.c", |
| 133 |
"compress/zstd_fast.c", |
| 134 |
"compress/zstd_lazy.c", |
| 135 |
"compress/zstd_ldm.c", |
| 136 |
"compress/zstd_opt.c", |
| 137 |
"compress/zstd_preSplit.c", |
| 138 |
"compress/zstdmt_compress.c", |
| 139 |
"compress/zstd_compress_literals.c", |
| 140 |
"compress/zstd_compress_sequences.c", |
| 141 |
"compress/zstd_compress_superblock.c", |
| 142 |
"decompress/huf_decompress.c", |
| 143 |
"decompress/zstd_ddict.c", |
| 144 |
"decompress/zstd_decompress_block.c", |
| 145 |
"decompress/zstd_decompress.c", |
| 146 |
] |
| 147 |
if ( |
| 148 |
env["platform"] in ["android", "ios", "linuxbsd", "macos", "windows"] |
| 149 |
and env["arch"] == "x86_64" |
| 150 |
and not env.msvc |
| 151 |
): |
| 152 |
|
| 153 |
thirdparty_zstd_sources.append("decompress/huf_decompress_amd64.S") |
| 154 |
thirdparty_zstd_sources = [thirdparty_zstd_dir + file for file in thirdparty_zstd_sources] |
| 155 |
|
| 156 |
env_thirdparty.Prepend(CPPPATH=[thirdparty_zstd_dir, thirdparty_zstd_dir + "common"]) |
| 157 |
env_thirdparty.Append(CPPDEFINES=["ZSTD_STATIC_LINKING_ONLY"]) |
| 158 |
env.Prepend(CPPPATH=thirdparty_zstd_dir) |
| 159 |
|
| 160 |
env.Append(CPPDEFINES=["ZSTD_STATIC_LINKING_ONLY"]) |
| 161 |
|
| 162 |
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_zstd_sources) |
| 163 |
|
| 164 |
|
| 165 |
env.core_sources += thirdparty_obj |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
env.add_source_files(env.core_sources, "*.cpp") |
| 170 |
|
| 171 |
|
| 172 |
env.CommandNoCache( |
| 173 |
"disabled_classes.gen.h", env.Value(env.disabled_classes), env.Run(core_builders.disabled_class_builder) |
| 174 |
) |
| 175 |
|
| 176 |
|
| 177 |
env.CommandNoCache( |
| 178 |
"version_generated.gen.h", |
| 179 |
env.Value(methods.get_version_info(env.module_version_string)), |
| 180 |
env.Run(core_builders.version_info_builder), |
| 181 |
) |
| 182 |
|
| 183 |
|
| 184 |
gen_hash = env.CommandNoCache( |
| 185 |
"version_hash.gen.cpp", env.Value(methods.get_git_info()), env.Run(core_builders.version_hash_builder) |
| 186 |
) |
| 187 |
env.add_source_files(env.core_sources, gen_hash) |
| 188 |
|
| 189 |
|
| 190 |
encryption_key = os.environ.get("SCRIPT_AES256_ENCRYPTION_KEY") |
| 191 |
if encryption_key: |
| 192 |
print( |
| 193 |
"\n*** IMPORTANT: Compiling Godot with custom `SCRIPT_AES256_ENCRYPTION_KEY` set as environment variable." |
| 194 |
"\n*** Make sure to use templates compiled with this key when exporting a project with encryption.\n" |
| 195 |
) |
| 196 |
gen_encrypt = env.CommandNoCache( |
| 197 |
"script_encryption_key.gen.cpp", |
| 198 |
env.Value(encryption_key), |
| 199 |
env.Run(core_builders.encryption_key_builder), |
| 200 |
) |
| 201 |
env.add_source_files(env.core_sources, gen_encrypt) |
| 202 |
|
| 203 |
|
| 204 |
env.CommandNoCache( |
| 205 |
"#core/io/certs_compressed.gen.h", |
| 206 |
["#thirdparty/certs/ca-bundle.crt", env.Value(env["builtin_certs"]), env.Value(env["system_certs_path"])], |
| 207 |
env.Run(core_builders.make_certs_header), |
| 208 |
) |
| 209 |
|
| 210 |
|
| 211 |
env.CommandNoCache("#core/authors.gen.h", "#AUTHORS.md", env.Run(core_builders.make_authors_header)) |
| 212 |
|
| 213 |
|
| 214 |
env.CommandNoCache("#core/donors.gen.h", "#DONORS.md", env.Run(core_builders.make_donors_header)) |
| 215 |
|
| 216 |
|
| 217 |
env.CommandNoCache( |
| 218 |
"#core/license.gen.h", ["#COPYRIGHT.txt", "#LICENSE.txt"], env.Run(core_builders.make_license_header) |
| 219 |
) |
| 220 |
|
| 221 |
|
| 222 |
SConscript("profiling/SCsub") |
| 223 |
SConscript("os/SCsub") |
| 224 |
SConscript("math/SCsub") |
| 225 |
SConscript("crypto/SCsub") |
| 226 |
SConscript("io/SCsub") |
| 227 |
SConscript("debugger/SCsub") |
| 228 |
SConscript("input/SCsub") |
| 229 |
SConscript("variant/SCsub") |
| 230 |
SConscript("extension/SCsub") |
| 231 |
SConscript("object/SCsub") |
| 232 |
SConscript("templates/SCsub") |
| 233 |
SConscript("string/SCsub") |
| 234 |
SConscript("config/SCsub") |
| 235 |
SConscript("error/SCsub") |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
lib = env.add_library("core", env.core_sources) |
| 240 |
env.Prepend(LIBS=[lib]) |
| 241 |
|
| 242 |
|
| 243 |
env.Depends(lib, thirdparty_obj) |