| 1 |
|
| 2 |
from misc.utility.scons_hints import * |
| 3 |
|
| 4 |
EnsureSConsVersion(4, 0) |
| 5 |
EnsurePythonVersion(3, 8) |
| 6 |
|
| 7 |
|
| 8 |
import glob |
| 9 |
import os |
| 10 |
import pickle |
| 11 |
import sys |
| 12 |
from collections import OrderedDict |
| 13 |
from importlib.util import module_from_spec, spec_from_file_location |
| 14 |
from types import ModuleType |
| 15 |
|
| 16 |
from SCons import __version__ as scons_raw_version |
| 17 |
from SCons.Builder import ListEmitter |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
def _helper_module(name, path): |
| 26 |
spec = spec_from_file_location(name, path) |
| 27 |
module = module_from_spec(spec) |
| 28 |
spec.loader.exec_module(module) |
| 29 |
sys.modules[name] = module |
| 30 |
|
| 31 |
|
| 32 |
child_module = module |
| 33 |
parent_name = name |
| 34 |
while True: |
| 35 |
try: |
| 36 |
parent_name, child_name = parent_name.rsplit(".", 1) |
| 37 |
except ValueError: |
| 38 |
break |
| 39 |
try: |
| 40 |
parent_module = sys.modules[parent_name] |
| 41 |
except KeyError: |
| 42 |
parent_module = ModuleType(parent_name) |
| 43 |
sys.modules[parent_name] = parent_module |
| 44 |
setattr(parent_module, child_name, child_module) |
| 45 |
|
| 46 |
|
| 47 |
_helper_module("gles3_builders", "gles3_builders.py") |
| 48 |
_helper_module("glsl_builders", "glsl_builders.py") |
| 49 |
_helper_module("methods", "methods.py") |
| 50 |
_helper_module("platform_methods", "platform_methods.py") |
| 51 |
_helper_module("version", "version.py") |
| 52 |
_helper_module("core.core_builders", "core/core_builders.py") |
| 53 |
_helper_module("main.main_builders", "main/main_builders.py") |
| 54 |
_helper_module("misc.utility.color", "misc/utility/color.py") |
| 55 |
|
| 56 |
|
| 57 |
import gles3_builders |
| 58 |
import glsl_builders |
| 59 |
import methods |
| 60 |
import scu_builders |
| 61 |
from misc.utility.color import is_stderr_color, print_error, print_info, print_warning |
| 62 |
from platform_methods import architecture_aliases, architectures, compatibility_platform_aliases |
| 63 |
|
| 64 |
if ARGUMENTS.get("target", "editor") == "editor": |
| 65 |
_helper_module("editor.editor_builders", "editor/editor_builders.py") |
| 66 |
_helper_module("editor.template_builders", "editor/template_builders.py") |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
platform_list = [] |
| 71 |
platform_opts = {} |
| 72 |
platform_flags = {} |
| 73 |
platform_doc_class_path = {} |
| 74 |
platform_exporters = [] |
| 75 |
platform_apis = [] |
| 76 |
|
| 77 |
for x in sorted(glob.glob("platform/*")): |
| 78 |
if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"): |
| 79 |
continue |
| 80 |
tmppath = "./" + x |
| 81 |
|
| 82 |
sys.path.insert(0, tmppath) |
| 83 |
import detect |
| 84 |
|
| 85 |
|
| 86 |
try: |
| 87 |
doc_classes = detect.get_doc_classes() |
| 88 |
doc_path = detect.get_doc_path() |
| 89 |
for c in doc_classes: |
| 90 |
platform_doc_class_path[c] = x.replace("\\", "/") + "/" + doc_path |
| 91 |
except Exception: |
| 92 |
pass |
| 93 |
|
| 94 |
platform_name = x[9:] |
| 95 |
|
| 96 |
if os.path.exists(x + "/export/export.cpp"): |
| 97 |
platform_exporters.append(platform_name) |
| 98 |
if os.path.exists(x + "/api/api.cpp"): |
| 99 |
platform_apis.append(platform_name) |
| 100 |
if detect.can_build(): |
| 101 |
x = x.replace("platform/", "") |
| 102 |
x = x.replace("platform\\", "") |
| 103 |
platform_list += [x] |
| 104 |
platform_opts[x] = detect.get_opts() |
| 105 |
platform_flags[x] = detect.get_flags() |
| 106 |
if isinstance(platform_flags[x], list): |
| 107 |
platform_flags[x] = {flag[0]: flag[1] for flag in platform_flags[x]} |
| 108 |
sys.path.remove(tmppath) |
| 109 |
sys.modules.pop("detect") |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
env = Environment(tools=[]) |
| 116 |
env.PrependENVPath("PATH", os.getenv("PATH")) |
| 117 |
env.PrependENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) |
| 118 |
if "TERM" in os.environ: |
| 119 |
env["ENV"]["TERM"] = os.environ["TERM"] |
| 120 |
|
| 121 |
env.disabled_modules = set() |
| 122 |
env.module_version_string = "" |
| 123 |
env.msvc = False |
| 124 |
env.scons_version = env._get_major_minor_revision(scons_raw_version) |
| 125 |
|
| 126 |
env.__class__.add_module_version_string = methods.add_module_version_string |
| 127 |
|
| 128 |
env.__class__.add_source_files = methods.add_source_files |
| 129 |
env.__class__.use_windows_spawn_fix = methods.use_windows_spawn_fix |
| 130 |
|
| 131 |
env.__class__.add_shared_library = methods.add_shared_library |
| 132 |
env.__class__.add_library = methods.add_library |
| 133 |
env.__class__.add_program = methods.add_program |
| 134 |
env.__class__.CommandNoCache = methods.CommandNoCache |
| 135 |
env.__class__.Run = methods.Run |
| 136 |
env.__class__.disable_warnings = methods.disable_warnings |
| 137 |
env.__class__.force_optimization_on_debug = methods.force_optimization_on_debug |
| 138 |
env.__class__.module_add_dependencies = methods.module_add_dependencies |
| 139 |
env.__class__.module_check_dependencies = methods.module_check_dependencies |
| 140 |
|
| 141 |
env["x86_libtheora_opt_gcc"] = False |
| 142 |
env["x86_libtheora_opt_vc"] = False |
| 143 |
|
| 144 |
|
| 145 |
env.SConsignFile(File("#.sconsign{0}.dblite".format(pickle.HIGHEST_PROTOCOL)).abspath) |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
customs = ["custom.py"] |
| 150 |
|
| 151 |
profile = ARGUMENTS.get("profile", "") |
| 152 |
if profile: |
| 153 |
if os.path.isfile(profile): |
| 154 |
customs.append(profile) |
| 155 |
elif os.path.isfile(profile + ".py"): |
| 156 |
customs.append(profile + ".py") |
| 157 |
|
| 158 |
opts = Variables(customs, ARGUMENTS) |
| 159 |
|
| 160 |
|
| 161 |
opts.Add((["platform", "p"], "Target platform (%s)" % "|".join(platform_list), "")) |
| 162 |
opts.Add( |
| 163 |
EnumVariable( |
| 164 |
"target", "Compilation target", "editor", ["editor", "template_release", "template_debug"], ignorecase=2 |
| 165 |
) |
| 166 |
) |
| 167 |
opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectures, architecture_aliases, ignorecase=2)) |
| 168 |
opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False)) |
| 169 |
opts.Add( |
| 170 |
EnumVariable( |
| 171 |
"optimize", |
| 172 |
"Optimization level (by default inferred from 'target' and 'dev_build')", |
| 173 |
"auto", |
| 174 |
["auto", "none", "custom", "debug", "speed", "speed_trace", "size", "size_extra"], |
| 175 |
ignorecase=2, |
| 176 |
) |
| 177 |
) |
| 178 |
opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", False)) |
| 179 |
opts.Add(BoolVariable("separate_debug_symbols", "Extract debugging symbols to a separate file", False)) |
| 180 |
opts.Add(BoolVariable("debug_paths_relative", "Make file paths in debug symbols relative (if supported)", False)) |
| 181 |
opts.Add( |
| 182 |
EnumVariable( |
| 183 |
"lto", "Link-time optimization (production builds)", "none", ["none", "auto", "thin", "full"], ignorecase=2 |
| 184 |
) |
| 185 |
) |
| 186 |
opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False)) |
| 187 |
opts.Add(BoolVariable("threads", "Enable threading support", True)) |
| 188 |
|
| 189 |
|
| 190 |
opts.Add(BoolVariable("deprecated", "Enable compatibility code for deprecated and removed features", True)) |
| 191 |
opts.Add( |
| 192 |
EnumVariable("precision", "Set the floating-point precision level", "single", ["single", "double"], ignorecase=2) |
| 193 |
) |
| 194 |
opts.Add(BoolVariable("minizip", "Enable ZIP archive support using minizip", True)) |
| 195 |
opts.Add(BoolVariable("brotli", "Enable Brotli for decompression and WOFF2 fonts support", True)) |
| 196 |
opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver on supported platforms", False)) |
| 197 |
opts.Add(BoolVariable("vulkan", "Enable the Vulkan rendering driver", True)) |
| 198 |
opts.Add(BoolVariable("opengl3", "Enable the OpenGL/GLES3 rendering driver", True)) |
| 199 |
opts.Add(BoolVariable("d3d12", "Enable the Direct3D 12 rendering driver on supported platforms", False)) |
| 200 |
opts.Add(BoolVariable("metal", "Enable the Metal rendering driver on supported platforms (Apple arm64 only)", False)) |
| 201 |
opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loader dynamically", True)) |
| 202 |
opts.Add(BoolVariable("accesskit", "Use AccessKit C SDK", True)) |
| 203 |
opts.Add(("accesskit_sdk_path", "Path to the AccessKit C SDK", "")) |
| 204 |
opts.Add(BoolVariable("sdl", "Enable the SDL3 input driver", True)) |
| 205 |
opts.Add( |
| 206 |
EnumVariable( |
| 207 |
"profiler", "Specify the profiler to use", "none", ["none", "tracy", "perfetto", "instruments"], ignorecase=2 |
| 208 |
) |
| 209 |
) |
| 210 |
opts.Add(("profiler_path", "Path to the Profiler framework.", "")) |
| 211 |
opts.Add( |
| 212 |
BoolVariable( |
| 213 |
"profiler_sample_callstack", |
| 214 |
"Profile random samples application-wide using a callstack based sampler.", |
| 215 |
False, |
| 216 |
) |
| 217 |
) |
| 218 |
opts.Add( |
| 219 |
BoolVariable( |
| 220 |
"profiler_track_memory", |
| 221 |
"Profile memory allocations, if the profiler supports it.", |
| 222 |
False, |
| 223 |
) |
| 224 |
) |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
opts.Add( |
| 229 |
BoolVariable( |
| 230 |
"dev_mode", "Alias for dev options: verbose=yes warnings=extra werror=yes tests=yes strict_checks=yes", False |
| 231 |
) |
| 232 |
) |
| 233 |
opts.Add(BoolVariable("tests", "Build the unit tests", False)) |
| 234 |
opts.Add(BoolVariable("fast_unsafe", "Enable unsafe options for faster incremental builds", False)) |
| 235 |
opts.Add(BoolVariable("ninja", "Use the ninja backend for faster rebuilds", False)) |
| 236 |
opts.Add(BoolVariable("ninja_auto_run", "Run ninja automatically after generating the ninja file", True)) |
| 237 |
opts.Add("ninja_file", "Path to the generated ninja file", "build.ninja") |
| 238 |
opts.Add(BoolVariable("compiledb", "Generate compilation DB (`compile_commands.json`) for external tools", False)) |
| 239 |
opts.Add( |
| 240 |
"num_jobs", |
| 241 |
"Use up to N jobs when compiling (equivalent to `-j N`). Defaults to max jobs - 1. Ignored if -j is used.", |
| 242 |
"", |
| 243 |
) |
| 244 |
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False)) |
| 245 |
opts.Add(BoolVariable("progress", "Show a progress indicator during compilation", True)) |
| 246 |
opts.Add( |
| 247 |
EnumVariable("warnings", "Level of compilation warnings", "all", ["extra", "all", "moderate", "no"], ignorecase=2) |
| 248 |
) |
| 249 |
opts.Add(BoolVariable("werror", "Treat compiler warnings as errors", False)) |
| •250 |
opts.Add("output_path", "Explicit path to output Godot binary relative to source root", "") |
| 251 |
opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files", "") |
| 252 |
opts.Add("object_prefix", "Custom prefix added to the base filename of all generated object files", "") |
| 253 |
opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False)) |
| 254 |
opts.Add("vsproj_name", "Name of the Visual Studio solution", "godot") |
| 255 |
opts.Add("import_env_vars", "A comma-separated list of environment variables to copy from the outer environment.", "") |
| 256 |
opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True)) |
| 257 |
opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False)) |
| 258 |
opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False)) |
| 259 |
opts.Add(BoolVariable("disable_physics_2d", "Disable 2D physics nodes and server", False)) |
| 260 |
opts.Add(BoolVariable("disable_physics_3d", "Disable 3D physics nodes and server", False)) |
| 261 |
opts.Add(BoolVariable("disable_navigation_2d", "Disable 2D navigation features", False)) |
| 262 |
opts.Add(BoolVariable("disable_navigation_3d", "Disable 3D navigation features", False)) |
| 263 |
opts.Add(BoolVariable("disable_xr", "Disable XR nodes and server", False)) |
| 264 |
opts.Add(BoolVariable("disable_overrides", "Disable project settings overrides (override.cfg)", False)) |
| 265 |
opts.Add( |
| 266 |
BoolVariable( |
| 267 |
"disable_path_overrides", |
| 268 |
"Disable CLI arguments to override project path/main pack/scene and run scripts (export template only)", |
| 269 |
True, |
| 270 |
) |
| 271 |
) |
| 272 |
opts.Add("build_profile", "Path to a file containing a feature build profile", "") |
| 273 |
opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "") |
| 274 |
opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True)) |
| 275 |
opts.Add(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True)) |
| 276 |
opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", True)) |
| 277 |
opts.Add( |
| 278 |
"system_certs_path", |
| 279 |
"Use this path as TLS certificates default for editor and Linux/BSD export templates (for package maintainers)", |
| 280 |
"", |
| 281 |
) |
| 282 |
opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False)) |
| 283 |
opts.Add(BoolVariable("strict_checks", "Enforce stricter checks (debug option)", False)) |
| 284 |
opts.Add( |
| 285 |
BoolVariable( |
| 286 |
"limit_transitive_includes", "Attempt to limit the amount of transitive includes in system headers", True |
| 287 |
) |
| 288 |
) |
| 289 |
opts.Add(BoolVariable("scu_build", "Use single compilation unit build", False)) |
| 290 |
opts.Add("scu_limit", "Max includes per SCU file when using scu_build (determines RAM use)", "0") |
| 291 |
opts.Add(BoolVariable("engine_update_check", "Enable engine update checks in the Project Manager", True)) |
| 292 |
opts.Add(BoolVariable("steamapi", "Enable minimal SteamAPI integration for usage time tracking (editor only)", False)) |
| 293 |
opts.Add("cache_path", "Path to a directory where SCons cache files will be stored. No value disables the cache.", "") |
| 294 |
opts.Add("cache_limit", "Max size (in GiB) for the SCons cache. 0 means no limit.", "0") |
| 295 |
opts.Add( |
| 296 |
BoolVariable( |
| 297 |
"redirect_build_objects", |
| 298 |
"Enable redirecting built objects/libraries to `bin/obj/` to declutter the repository.", |
| 299 |
True, |
| 300 |
) |
| 301 |
) |
| 302 |
opts.Add( |
| 303 |
EnumVariable( |
| 304 |
"library_type", |
| 305 |
"Build library type", |
| 306 |
"executable", |
| 307 |
("executable", "static_library", "shared_library"), |
| 308 |
) |
| 309 |
) |
| 310 |
|
| 311 |
|
| 312 |
opts.Add(BoolVariable("builtin_brotli", "Use the built-in Brotli library", True)) |
| 313 |
opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", True)) |
| 314 |
opts.Add(BoolVariable("builtin_clipper2", "Use the built-in Clipper2 library", True)) |
| 315 |
opts.Add(BoolVariable("builtin_embree", "Use the built-in Embree library", True)) |
| 316 |
opts.Add(BoolVariable("builtin_enet", "Use the built-in ENet library", True)) |
| 317 |
opts.Add(BoolVariable("builtin_freetype", "Use the built-in FreeType library", True)) |
| 318 |
opts.Add(BoolVariable("builtin_msdfgen", "Use the built-in MSDFgen library", True)) |
| 319 |
opts.Add(BoolVariable("builtin_glslang", "Use the built-in glslang library", True)) |
| 320 |
opts.Add(BoolVariable("builtin_graphite", "Use the built-in Graphite library", True)) |
| 321 |
opts.Add(BoolVariable("builtin_harfbuzz", "Use the built-in HarfBuzz library", True)) |
| 322 |
opts.Add(BoolVariable("builtin_sdl", "Use the built-in SDL library", True)) |
| 323 |
opts.Add(BoolVariable("builtin_icu4c", "Use the built-in ICU library", True)) |
| 324 |
opts.Add(BoolVariable("builtin_libjpeg_turbo", "Use the built-in libjpeg-turbo library", True)) |
| 325 |
opts.Add(BoolVariable("builtin_libogg", "Use the built-in libogg library", True)) |
| 326 |
opts.Add(BoolVariable("builtin_libpng", "Use the built-in libpng library", True)) |
| 327 |
opts.Add(BoolVariable("builtin_libtheora", "Use the built-in libtheora library", True)) |
| 328 |
opts.Add(BoolVariable("builtin_libvorbis", "Use the built-in libvorbis library", True)) |
| 329 |
opts.Add(BoolVariable("builtin_libwebp", "Use the built-in libwebp library", True)) |
| 330 |
opts.Add(BoolVariable("builtin_wslay", "Use the built-in wslay library", True)) |
| 331 |
opts.Add(BoolVariable("builtin_mbedtls", "Use the built-in mbedTLS library", True)) |
| 332 |
opts.Add(BoolVariable("builtin_miniupnpc", "Use the built-in miniupnpc library", True)) |
| 333 |
opts.Add(BoolVariable("builtin_openxr", "Use the built-in OpenXR library", True)) |
| 334 |
opts.Add(BoolVariable("builtin_pcre2", "Use the built-in PCRE2 library", True)) |
| 335 |
opts.Add(BoolVariable("builtin_pcre2_with_jit", "Use JIT compiler for the built-in PCRE2 library", True)) |
| 336 |
opts.Add(BoolVariable("builtin_recastnavigation", "Use the built-in Recast navigation library", True)) |
| 337 |
opts.Add(BoolVariable("builtin_rvo2_2d", "Use the built-in RVO2 2D library", True)) |
| 338 |
opts.Add(BoolVariable("builtin_rvo2_3d", "Use the built-in RVO2 3D library", True)) |
| 339 |
opts.Add(BoolVariable("builtin_xatlas", "Use the built-in xatlas library", True)) |
| 340 |
opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True)) |
| 341 |
opts.Add(BoolVariable("builtin_zstd", "Use the built-in Zstd library", True)) |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
opts.Add("CXX", "C++ compiler binary") |
| 347 |
opts.Add("CC", "C compiler binary") |
| 348 |
opts.Add("LINK", "Linker binary") |
| 349 |
opts.Add("cppdefines", "Custom defines for the pre-processor") |
| 350 |
opts.Add("ccflags", "Custom flags for both the C and C++ compilers") |
| 351 |
opts.Add("cxxflags", "Custom flags for the C++ compiler") |
| 352 |
opts.Add("cflags", "Custom flags for the C compiler") |
| 353 |
opts.Add("linkflags", "Custom flags for the linker") |
| 354 |
opts.Add("asflags", "Custom flags for the assembler") |
| 355 |
opts.Add("arflags", "Custom flags for the archive tool") |
| 356 |
opts.Add("rcflags", "Custom flags for Windows resource compiler") |
| 357 |
|
| 358 |
opts.Add("c_compiler_launcher", "C compiler launcher (e.g. `ccache`)") |
| 359 |
opts.Add("cpp_compiler_launcher", "C++ compiler launcher (e.g. `ccache`)") |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
opts.Update(env) |
| 364 |
|
| 365 |
|
| 366 |
methods.prepare_cache(env) |
| 367 |
|
| 368 |
|
| 369 |
if env["import_env_vars"]: |
| 370 |
for env_var in str(env["import_env_vars"]).split(","): |
| 371 |
if env_var in os.environ: |
| 372 |
env["ENV"][env_var] = os.environ[env_var] |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
if not env["platform"]: |
| 377 |
|
| 378 |
if ( |
| 379 |
sys.platform.startswith("linux") |
| 380 |
or sys.platform.startswith("dragonfly") |
| 381 |
or sys.platform.startswith("freebsd") |
| 382 |
or sys.platform.startswith("netbsd") |
| 383 |
or sys.platform.startswith("openbsd") |
| 384 |
): |
| 385 |
env["platform"] = "linuxbsd" |
| 386 |
elif sys.platform == "darwin": |
| 387 |
env["platform"] = "macos" |
| 388 |
elif sys.platform == "win32": |
| 389 |
env["platform"] = "windows" |
| 390 |
|
| 391 |
if env["platform"]: |
| 392 |
print(f"Automatically detected platform: {env['platform']}") |
| 393 |
|
| 394 |
|
| 395 |
if env["platform"] in compatibility_platform_aliases: |
| 396 |
alias = env["platform"] |
| 397 |
platform = compatibility_platform_aliases[alias] |
| 398 |
print_warning( |
| 399 |
f'Platform "{alias}" has been renamed to "{platform}" in Godot 4. Building for platform "{platform}".' |
| 400 |
) |
| 401 |
env["platform"] = platform |
| 402 |
|
| 403 |
|
| 404 |
if env["platform"] in ["linux", "bsd"]: |
| 405 |
env["platform"] = "linuxbsd" |
| 406 |
|
| 407 |
if env["platform"] not in platform_list: |
| 408 |
text = "The following platforms are available:\n\t{}\n".format("\n\t".join(platform_list)) |
| 409 |
text += "Please run SCons again and select a valid platform: platform=<string>." |
| 410 |
|
| 411 |
if env["platform"] == "list": |
| 412 |
print(text) |
| 413 |
elif not env["platform"]: |
| 414 |
print_error("Could not detect platform automatically.\n" + text) |
| 415 |
else: |
| 416 |
print_error(f'Invalid target platform "{env["platform"]}".\n' + text) |
| 417 |
|
| 418 |
Exit(0 if env["platform"] == "list" else 255) |
| 419 |
|
| 420 |
|
| 421 |
if env["platform"] in platform_opts: |
| 422 |
opts.AddVariables(*platform_opts[env["platform"]]) |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
flag_list = platform_flags[env["platform"]] |
| 428 |
for key, value in flag_list.items(): |
| 429 |
if key not in ARGUMENTS or ARGUMENTS[key] == "auto": |
| 430 |
env[key] = value |
| 431 |
|
| 432 |
|
| 433 |
opts.Update(env, {**ARGUMENTS, **env.Dictionary()}) |
| 434 |
|
| 435 |
|
| 436 |
modules_detected = OrderedDict() |
| 437 |
module_search_paths = ["modules"] |
| 438 |
|
| 439 |
if env["custom_modules"]: |
| 440 |
paths = env["custom_modules"].split(",") |
| 441 |
for p in paths: |
| 442 |
try: |
| 443 |
module_search_paths.append(methods.convert_custom_modules_path(p)) |
| 444 |
except ValueError as e: |
| 445 |
print_error(e) |
| 446 |
Exit(255) |
| 447 |
|
| 448 |
for path in module_search_paths: |
| 449 |
if path == "modules": |
| 450 |
|
| 451 |
|
| 452 |
modules = methods.detect_modules(path, recursive=False) |
| 453 |
else: |
| 454 |
modules = methods.detect_modules(path, env["custom_modules_recursive"]) |
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
env.Prepend(CPPPATH=[path, os.path.dirname(path)]) |
| 461 |
|
| 462 |
modules_detected.update(modules) |
| 463 |
|
| 464 |
|
| 465 |
for name, path in modules_detected.items(): |
| 466 |
sys.path.insert(0, path) |
| 467 |
import config |
| 468 |
|
| 469 |
if env["modules_enabled_by_default"]: |
| 470 |
enabled = True |
| 471 |
try: |
| 472 |
enabled = config.is_enabled() |
| 473 |
except AttributeError: |
| 474 |
pass |
| 475 |
else: |
| 476 |
enabled = False |
| 477 |
|
| 478 |
opts.Add(BoolVariable(f"module_{name}_enabled", f"Enable module '{name}'", enabled)) |
| 479 |
|
| 480 |
|
| 481 |
try: |
| 482 |
opts.AddVariables(*config.get_opts(env["platform"])) |
| 483 |
except AttributeError: |
| 484 |
pass |
| 485 |
|
| 486 |
sys.path.remove(path) |
| 487 |
sys.modules.pop("config") |
| 488 |
|
| 489 |
env.modules_detected = modules_detected |
| 490 |
|
| 491 |
|
| 492 |
opts.Update(env, {**ARGUMENTS, **env.Dictionary()}) |
| 493 |
Help(opts.GenerateHelpText(env)) |
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
tmppath = "./platform/" + env["platform"] |
| 500 |
sys.path.insert(0, tmppath) |
| 501 |
import detect |
| 502 |
|
| 503 |
custom_tools = ["default"] |
| 504 |
try: |
| 505 |
custom_tools = detect.get_tools(env) |
| 506 |
except AttributeError: |
| 507 |
pass |
| 508 |
for tool in custom_tools: |
| 509 |
env.Tool(tool) |
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
env.Prepend(CPPPATH=["#"]) |
| 514 |
|
| 515 |
|
| 516 |
env.platform_exporters = platform_exporters |
| 517 |
env.platform_apis = platform_apis |
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
env.editor_build = env["target"] == "editor" |
| 527 |
env.dev_build = env["dev_build"] |
| 528 |
env.debug_features = env["target"] in ["editor", "template_debug"] |
| 529 |
|
| 530 |
if env["optimize"] == "auto": |
| 531 |
if env.dev_build: |
| 532 |
opt_level = "none" |
| 533 |
elif env.debug_features: |
| 534 |
opt_level = "speed_trace" |
| 535 |
else: |
| 536 |
opt_level = "speed" |
| 537 |
env["optimize"] = opt_level |
| 538 |
|
| 539 |
env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", env.dev_build) |
| 540 |
|
| 541 |
if env.editor_build: |
| 542 |
env.Append(CPPDEFINES=["TOOLS_ENABLED"]) |
| 543 |
|
| 544 |
if env.debug_features: |
| 545 |
|
| 546 |
|
| 547 |
env.Append(CPPDEFINES=["DEBUG_ENABLED"]) |
| 548 |
|
| 549 |
if env.dev_build: |
| 550 |
|
| 551 |
|
| 552 |
env.Append(CPPDEFINES=["DEV_ENABLED"]) |
| 553 |
else: |
| 554 |
|
| 555 |
env.Append(CPPDEFINES=["NDEBUG"]) |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
env.Decider("MD5-timestamp") |
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
if env["fast_unsafe"]: |
| 570 |
env.SetOption("implicit_cache", 1) |
| 571 |
env.SetOption("max_drift", 60) |
| 572 |
|
| 573 |
if env["use_precise_math_checks"]: |
| 574 |
env.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"]) |
| 575 |
|
| 576 |
if env.editor_build: |
| 577 |
if env["engine_update_check"]: |
| 578 |
env.Append(CPPDEFINES=["ENGINE_UPDATE_CHECK_ENABLED"]) |
| 579 |
|
| 580 |
if not env.File("#main/splash_editor.png").exists(): |
| 581 |
|
| 582 |
env["no_editor_splash"] = True |
| 583 |
if env["no_editor_splash"]: |
| 584 |
env.Append(CPPDEFINES=["NO_EDITOR_SPLASH"]) |
| 585 |
|
| 586 |
if not env["deprecated"]: |
| 587 |
env.Append(CPPDEFINES=["DISABLE_DEPRECATED"]) |
| 588 |
|
| 589 |
if env["precision"] == "double": |
| 590 |
env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"]) |
| 591 |
|
| 592 |
|
| 593 |
if env["library_type"] != "executable": |
| 594 |
if "library" not in env.get("supported", []): |
| 595 |
print_error(f"Library builds unsupported for {env['platform']}") |
| 596 |
Exit(255) |
| 597 |
env.Append(CPPDEFINES=["LIBGODOT_ENABLED"]) |
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
initial_num_jobs = env.GetOption("num_jobs") |
| 603 |
altered_num_jobs = initial_num_jobs + 1 |
| 604 |
env.SetOption("num_jobs", altered_num_jobs) |
| 605 |
if env.GetOption("num_jobs") == altered_num_jobs: |
| 606 |
num_jobs = env.get("num_jobs", "") |
| 607 |
if str(num_jobs).isdigit() and int(num_jobs) > 0: |
| 608 |
env.SetOption("num_jobs", num_jobs) |
| 609 |
else: |
| 610 |
cpu_count = os.cpu_count() |
| 611 |
if cpu_count is None: |
| 612 |
print_warning( |
| 613 |
"Couldn't auto-detect CPU count to configure build parallelism. Specify it with the `-j` or `num_jobs` arguments." |
| 614 |
) |
| 615 |
else: |
| 616 |
safer_cpu_count = cpu_count if cpu_count <= 4 else cpu_count - 1 |
| 617 |
print( |
| 618 |
"Auto-detected %d CPU cores available for build parallelism. Using %d cores by default. You can override it with the `-j` or `num_jobs` arguments." |
| 619 |
% (cpu_count, safer_cpu_count) |
| 620 |
) |
| 621 |
env.SetOption("num_jobs", safer_cpu_count) |
| 622 |
|
| 623 |
env.extra_suffix = "" |
| 624 |
|
| 625 |
if env["extra_suffix"] != "": |
| 626 |
env.extra_suffix += "." + env["extra_suffix"] |
| 627 |
|
| 628 |
|
| 629 |
env.Append(CPPDEFINES=env.get("cppdefines", "").split()) |
| 630 |
env.Append(CCFLAGS=env.get("ccflags", "").split()) |
| 631 |
env.Append(CXXFLAGS=env.get("cxxflags", "").split()) |
| 632 |
env.Append(CFLAGS=env.get("cflags", "").split()) |
| 633 |
env.Append(LINKFLAGS=env.get("linkflags", "").split()) |
| 634 |
env.Append(ASFLAGS=env.get("asflags", "").split()) |
| 635 |
env.Append(ARFLAGS=env.get("arflags", "").split()) |
| 636 |
env.Append(RCFLAGS=env.get("rcflags", "").split()) |
| 637 |
|
| 638 |
|
| 639 |
env.disabled_classes = [] |
| 640 |
if env["build_profile"] != "": |
| 641 |
print(f'Using feature build profile: "{env["build_profile"]}"') |
| 642 |
import json |
| 643 |
|
| 644 |
try: |
| 645 |
ft = json.load(open(env["build_profile"], "r", encoding="utf-8")) |
| 646 |
if "disabled_classes" in ft: |
| 647 |
env.disabled_classes = ft["disabled_classes"] |
| 648 |
if "disabled_build_options" in ft: |
| 649 |
dbo = ft["disabled_build_options"] |
| 650 |
for c in dbo: |
| 651 |
env[c] = dbo[c] |
| 652 |
except json.JSONDecodeError: |
| 653 |
print_error(f'Failed to open feature build profile: "{env["build_profile"]}"') |
| 654 |
Exit(255) |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
if env["dev_mode"]: |
| 659 |
env["verbose"] = methods.get_cmdline_bool("verbose", True) |
| 660 |
env["warnings"] = ARGUMENTS.get("warnings", "extra") |
| 661 |
env["werror"] = methods.get_cmdline_bool("werror", True) |
| 662 |
env["tests"] = methods.get_cmdline_bool("tests", True) |
| 663 |
env["strict_checks"] = methods.get_cmdline_bool("strict_checks", True) |
| 664 |
if env["production"]: |
| 665 |
env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True) |
| 666 |
env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False) |
| 667 |
if env["platform"] == "android": |
| 668 |
env["swappy"] = methods.get_cmdline_bool("swappy", True) |
| 669 |
|
| 670 |
env["lto"] = ARGUMENTS.get("lto", "auto") |
| 671 |
|
| 672 |
if env["strict_checks"]: |
| 673 |
env.Append(CPPDEFINES=["STRICT_CHECKS"]) |
| 674 |
|
| 675 |
|
| 676 |
if env["scu_build"]: |
| 677 |
env.Append(CPPDEFINES=["SCU_BUILD_ENABLED"]) |
| 678 |
max_includes_per_scu = 8 |
| 679 |
if env.dev_build: |
| 680 |
max_includes_per_scu = 1024 |
| 681 |
|
| 682 |
read_scu_limit = int(env["scu_limit"]) |
| 683 |
read_scu_limit = max(0, min(read_scu_limit, 1024)) |
| 684 |
if read_scu_limit != 0: |
| 685 |
max_includes_per_scu = read_scu_limit |
| 686 |
|
| 687 |
methods.set_scu_folders(scu_builders.generate_scu_files(max_includes_per_scu)) |
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
detect.configure(env) |
| 692 |
|
| 693 |
platform_string = env["platform"] |
| 694 |
if env.get("simulator"): |
| 695 |
platform_string += " (simulator)" |
| 696 |
print(f'Building for platform "{platform_string}", architecture "{env["arch"]}", target "{env["target"]}".') |
| 697 |
|
| 698 |
if env.dev_build: |
| 699 |
print_info("Developer build, with debug optimization level and debug symbols (unless overridden).") |
| 700 |
|
| 701 |
|
| 702 |
cc_version = methods.get_compiler_version(env) |
| 703 |
cc_version_major = cc_version["major"] |
| 704 |
cc_version_minor = cc_version["minor"] |
| 705 |
cc_version_metadata1 = cc_version["metadata1"] |
| 706 |
|
| 707 |
if cc_version_major == -1: |
| 708 |
print_warning( |
| 709 |
"Couldn't detect compiler version, skipping version checks. " |
| 710 |
"Build may fail if the compiler doesn't support C++17 fully." |
| 711 |
) |
| 712 |
elif methods.using_gcc(env): |
| 713 |
if cc_version_major < 9: |
| 714 |
print_error( |
| 715 |
"Detected GCC version older than 9, which does not fully support " |
| 716 |
"C++17, or has bugs when compiling Godot. Supported versions are 9 " |
| 717 |
"and later. Use a newer GCC version, or Clang 6 or later by passing " |
| 718 |
'"use_llvm=yes" to the SCons command line.' |
| 719 |
) |
| 720 |
Exit(255) |
| 721 |
elif cc_version_metadata1 == "win32": |
| 722 |
print_error( |
| 723 |
"Detected mingw version is not using posix threads. Only posix " |
| 724 |
"version of mingw is supported. " |
| 725 |
'Use "update-alternatives --config x86_64-w64-mingw32-g++" ' |
| 726 |
"to switch to posix threads." |
| 727 |
) |
| 728 |
Exit(255) |
| 729 |
elif methods.using_clang(env): |
| 730 |
|
| 731 |
|
| 732 |
if methods.is_apple_clang(env): |
| 733 |
if cc_version_major < 16: |
| 734 |
print_error( |
| 735 |
"Detected Apple Clang version older than 16, supported versions are Apple Clang 16 (Xcode 16) and later." |
| 736 |
) |
| 737 |
Exit(255) |
| 738 |
else: |
| 739 |
if cc_version_major < 6: |
| 740 |
print_error( |
| 741 |
"Detected Clang version older than 6, which does not fully support " |
| 742 |
"C++17. Supported versions are Clang 6 and later." |
| 743 |
) |
| 744 |
Exit(255) |
| 745 |
elif env["debug_paths_relative"] and cc_version_major < 10: |
| 746 |
print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.") |
| 747 |
env["debug_paths_relative"] = False |
| 748 |
|
| 749 |
elif env.msvc: |
| 750 |
|
| 751 |
|
| 752 |
if cc_version_major == 16 and cc_version_minor < 11: |
| 753 |
print_error( |
| 754 |
"Detected Visual Studio 2019 version older than 16.11, which has bugs " |
| 755 |
"when compiling Godot. Use a newer VS2019 version, or VS2022." |
| 756 |
) |
| 757 |
Exit(255) |
| 758 |
if cc_version_major == 15 and cc_version_minor < 9: |
| 759 |
print_error( |
| 760 |
"Detected Visual Studio 2017 version older than 15.9, which has bugs " |
| 761 |
"when compiling Godot. Use a newer VS2017 version, or VS2019/VS2022." |
| 762 |
) |
| 763 |
Exit(255) |
| 764 |
if cc_version_major < 15: |
| 765 |
print_error( |
| 766 |
"Detected Visual Studio 2015 or earlier, which is unsupported in Godot. " |
| 767 |
"Supported versions are Visual Studio 2017 and later." |
| 768 |
) |
| 769 |
Exit(255) |
| 770 |
|
| 771 |
|
| 772 |
if env["arch"] == "x86_64": |
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
if env.msvc and not methods.using_clang(env): |
| 777 |
|
| 778 |
env.Append(CCFLAGS=["/d2archSSE42"]) |
| 779 |
else: |
| 780 |
|
| 781 |
env.Append(CCFLAGS=["-msse4.2", "-mpopcnt"]) |
| 782 |
elif env["arch"] == "x86_32": |
| 783 |
|
| 784 |
|
| 785 |
if env.msvc and not methods.using_clang(env): |
| 786 |
env.Append(CCFLAGS=["/arch:SSE2"]) |
| 787 |
else: |
| 788 |
|
| 789 |
|
| 790 |
env.Append(CCFLAGS=["-msse2", "-mfpmath=sse", "-mstackrealign"]) |
| 791 |
|
| 792 |
|
| 793 |
if methods.using_gcc(env): |
| 794 |
env.AppendUnique(CCFLAGS=["-fdiagnostics-color" if is_stderr_color() else "-fno-diagnostics-color"]) |
| 795 |
elif methods.using_clang(env) or methods.using_emcc(env): |
| 796 |
env.AppendUnique(CCFLAGS=["-fcolor-diagnostics" if is_stderr_color() else "-fno-color-diagnostics"]) |
| 797 |
if sys.platform == "win32": |
| 798 |
env.AppendUnique(CCFLAGS=["-fansi-escape-codes"]) |
| 799 |
|
| 800 |
|
| 801 |
if env["limit_transitive_includes"]: |
| 802 |
if not env.msvc: |
| 803 |
|
| 804 |
|
| 805 |
env.AppendUnique(CPPDEFINES=["_LIBCPP_REMOVE_TRANSITIVE_INCLUDES"]) |
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
env.AppendUnique(CCFLAGS=["$OPTIMIZELEVEL"]) |
| 811 |
if env.msvc: |
| 812 |
if env["debug_symbols"]: |
| 813 |
env.AppendUnique(CCFLAGS=["/Zi", "/FS"]) |
| 814 |
env.AppendUnique(LINKFLAGS=["/DEBUG:FULL"]) |
| 815 |
else: |
| 816 |
env.AppendUnique(LINKFLAGS=["/DEBUG:NONE"]) |
| 817 |
|
| 818 |
if env["optimize"].startswith("speed"): |
| 819 |
env["OPTIMIZELEVEL"] = "/O2" |
| 820 |
env.AppendUnique(LINKFLAGS=["/OPT:REF"]) |
| 821 |
if env["optimize"] == "speed_trace": |
| 822 |
env.AppendUnique(LINKFLAGS=["/OPT:NOICF"]) |
| 823 |
elif env["optimize"].startswith("size"): |
| 824 |
env["OPTIMIZELEVEL"] = "/O1" |
| 825 |
env.AppendUnique(LINKFLAGS=["/OPT:REF"]) |
| 826 |
if env["optimize"] == "size_extra": |
| 827 |
env.AppendUnique(CPPDEFINES=["SIZE_EXTRA"]) |
| 828 |
elif env["optimize"] == "debug" or env["optimize"] == "none": |
| 829 |
env["OPTIMIZELEVEL"] = "/Od" |
| 830 |
else: |
| 831 |
if env["debug_symbols"]: |
| 832 |
if env["platform"] == "windows": |
| 833 |
if methods.using_clang(env): |
| 834 |
env.AppendUnique(CCFLAGS=["-gdwarf-4"]) |
| 835 |
else: |
| 836 |
env.AppendUnique(CCFLAGS=["-gdwarf-5"]) |
| 837 |
else: |
| 838 |
|
| 839 |
|
| 840 |
env.AppendUnique(CCFLAGS=["-gdwarf-4"]) |
| 841 |
if methods.using_emcc(env): |
| 842 |
|
| 843 |
env.AppendUnique(CCFLAGS=["-g3"]) |
| 844 |
|
| 845 |
env.AppendUnique(LINKFLAGS=["-gdwarf-4"]) |
| 846 |
env.AppendUnique(LINKFLAGS=["-g3"]) |
| 847 |
elif env.dev_build: |
| 848 |
env.AppendUnique(CCFLAGS=["-g3"]) |
| 849 |
else: |
| 850 |
env.AppendUnique(CCFLAGS=["-g2"]) |
| 851 |
if env["debug_paths_relative"]: |
| 852 |
|
| 853 |
project_path = Dir("#").abspath |
| 854 |
env.AppendUnique(CCFLAGS=[f"-ffile-prefix-map={project_path}=."]) |
| 855 |
else: |
| 856 |
if methods.is_apple_clang(env): |
| 857 |
|
| 858 |
env.AppendUnique(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"]) |
| 859 |
else: |
| 860 |
env.AppendUnique(LINKFLAGS=["-s"]) |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
env.AppendUnique(LINKFLAGS=["$OPTIMIZELEVEL"]) |
| 865 |
|
| 866 |
if env["optimize"] == "speed": |
| 867 |
env["OPTIMIZELEVEL"] = "-O3" |
| 868 |
|
| 869 |
elif env["optimize"] == "speed_trace": |
| 870 |
env["OPTIMIZELEVEL"] = "-O2" |
| 871 |
elif env["optimize"].startswith("size"): |
| 872 |
env["OPTIMIZELEVEL"] = "-Os" |
| 873 |
if env["optimize"] == "size_extra": |
| 874 |
env.AppendUnique(CPPDEFINES=["SIZE_EXTRA"]) |
| 875 |
elif env["optimize"] == "debug": |
| 876 |
env["OPTIMIZELEVEL"] = "-Og" |
| 877 |
elif env["optimize"] == "none": |
| 878 |
env["OPTIMIZELEVEL"] = "-O0" |
| 879 |
|
| 880 |
|
| 881 |
if env["lto"] != "none": |
| 882 |
print("Using LTO: " + env["lto"]) |
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
if not env.msvc: |
| 889 |
|
| 890 |
|
| 891 |
env.Prepend(CFLAGS=["-std=gnu17"]) |
| 892 |
env.Prepend(CXXFLAGS=["-std=gnu++17"]) |
| 893 |
else: |
| 894 |
|
| 895 |
|
| 896 |
env.Prepend(CXXFLAGS=["/std:c++17"]) |
| 897 |
if cc_version_major < 16: |
| 898 |
print_warning("Visual Studio 2017 cannot specify a C-Standard.") |
| 899 |
else: |
| 900 |
env.Prepend(CFLAGS=["/std:c17"]) |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
env.Prepend(CCFLAGS=["/permissive-"]) |
| 905 |
|
| 906 |
env.Prepend(CXXFLAGS=["/Zc:__cplusplus"]) |
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
if env["disable_exceptions"]: |
| 911 |
if env.msvc: |
| 912 |
env.Append(CPPDEFINES=[("_HAS_EXCEPTIONS", 0)]) |
| 913 |
else: |
| 914 |
env.Append(CXXFLAGS=["-fno-exceptions"]) |
| 915 |
elif env.msvc: |
| 916 |
env.Append(CXXFLAGS=["/EHsc"]) |
| 917 |
|
| 918 |
|
| 919 |
env.AppendUnique(CCFLAGS=["$WARNLEVEL"]) |
| 920 |
if env.msvc and not methods.using_clang(env): |
| 921 |
|
| 922 |
disabled_warnings = [ |
| 923 |
"/wd4100", |
| 924 |
"/wd4127", |
| 925 |
"/wd4201", |
| 926 |
"/wd4244", |
| 927 |
"/wd4245", |
| 928 |
"/wd4267", |
| 929 |
"/wd4305", |
| 930 |
"/wd4324", |
| 931 |
"/wd4514", |
| 932 |
"/wd4714", |
| 933 |
"/wd4820", |
| 934 |
] |
| 935 |
|
| 936 |
if env["warnings"] == "extra": |
| 937 |
env["WARNLEVEL"] = "/W4" |
| 938 |
env.AppendUnique(CCFLAGS=disabled_warnings) |
| 939 |
elif env["warnings"] == "all": |
| 940 |
env["WARNLEVEL"] = "/W3" |
| 941 |
|
| 942 |
env.AppendUnique(CCFLAGS=["/w34458"] + disabled_warnings) |
| 943 |
elif env["warnings"] == "moderate": |
| 944 |
env["WARNLEVEL"] = "/W2" |
| 945 |
env.AppendUnique(CCFLAGS=disabled_warnings) |
| 946 |
else: |
| 947 |
env["WARNLEVEL"] = "/w" |
| 948 |
|
| 949 |
env.AppendUnique(CCFLAGS=["/wd4267"]) |
| 950 |
|
| 951 |
if env["werror"]: |
| 952 |
env.AppendUnique(CCFLAGS=["/WX"]) |
| 953 |
env.AppendUnique(LINKFLAGS=["/WX"]) |
| 954 |
|
| 955 |
else: |
| 956 |
common_warnings = [] |
| 957 |
if methods.using_gcc(env): |
| 958 |
common_warnings += ["-Wshadow", "-Wno-misleading-indentation"] |
| 959 |
if cc_version_major < 11: |
| 960 |
|
| 961 |
|
| 962 |
common_warnings += ["-Wno-type-limits"] |
| 963 |
if cc_version_major == 12: |
| 964 |
|
| 965 |
common_warnings += ["-Wno-return-type"] |
| 966 |
if cc_version_major >= 11: |
| 967 |
common_warnings += ["-Wenum-conversion"] |
| 968 |
if cc_version_major >= 16: |
| 969 |
|
| 970 |
env.AppendUnique(CXXFLAGS=["-Wno-sfinae-incomplete"]) |
| 971 |
elif methods.using_clang(env) or methods.using_emcc(env): |
| 972 |
common_warnings += ["-Wshadow-field-in-constructor", "-Wshadow-uncaptured-local"] |
| 973 |
|
| 974 |
|
| 975 |
common_warnings += ["-Wno-ordered-compare-function-pointers"] |
| 976 |
common_warnings += ["-Wenum-conversion"] |
| 977 |
|
| 978 |
|
| 979 |
env["WARNLEVEL"] = "-Wall" if not env.msvc else "-W3" |
| 980 |
|
| 981 |
if env["warnings"] == "extra": |
| 982 |
env.AppendUnique(CCFLAGS=["-Wextra", "-Wwrite-strings", "-Wno-unused-parameter"] + common_warnings) |
| 983 |
env.AppendUnique(CXXFLAGS=["-Wctor-dtor-privacy", "-Wnon-virtual-dtor"]) |
| 984 |
if methods.using_gcc(env): |
| 985 |
env.AppendUnique( |
| 986 |
CCFLAGS=[ |
| 987 |
"-Walloc-zero", |
| 988 |
"-Wduplicated-branches", |
| 989 |
"-Wduplicated-cond", |
| 990 |
"-Wstringop-overflow=4", |
| 991 |
] |
| 992 |
) |
| 993 |
env.AppendUnique(CXXFLAGS=["-Wplacement-new=1", "-Wvirtual-inheritance"]) |
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
if cc_version_major >= 9: |
| 998 |
env.AppendUnique(CCFLAGS=["-Wattribute-alias=2"]) |
| 999 |
if cc_version_major >= 11: |
| 1000 |
env.AppendUnique(CCFLAGS=["-Wlogical-op"]) |
| 1001 |
elif methods.using_clang(env) or methods.using_emcc(env): |
| 1002 |
env.AppendUnique(CCFLAGS=["-Wimplicit-fallthrough"]) |
| 1003 |
elif env["warnings"] == "all": |
| 1004 |
env.AppendUnique(CCFLAGS=common_warnings) |
| 1005 |
elif env["warnings"] == "moderate": |
| 1006 |
env.AppendUnique(CCFLAGS=["-Wno-unused"] + common_warnings) |
| 1007 |
else: |
| 1008 |
env["WARNLEVEL"] = "-w" |
| 1009 |
|
| 1010 |
if env["werror"]: |
| 1011 |
env.AppendUnique(CCFLAGS=["-Werror"]) |
| 1012 |
|
| 1013 |
if hasattr(detect, "get_program_suffix"): |
| 1014 |
suffix = "." + detect.get_program_suffix() |
| 1015 |
else: |
| 1016 |
suffix = "." + env["platform"] |
| 1017 |
|
| 1018 |
suffix += "." + env["target"] |
| 1019 |
if env.dev_build: |
| 1020 |
suffix += ".dev" |
| 1021 |
|
| 1022 |
if env["precision"] == "double": |
| 1023 |
suffix += ".double" |
| 1024 |
|
| 1025 |
suffix += "." + env["arch"] |
| 1026 |
|
| 1027 |
if not env["threads"]: |
| 1028 |
suffix += ".nothreads" |
| 1029 |
|
| 1030 |
suffix += env.extra_suffix |
| 1031 |
|
| 1032 |
sys.path.remove(tmppath) |
| 1033 |
sys.modules.pop("detect") |
| 1034 |
|
| 1035 |
if env.editor_build: |
| 1036 |
unsupported_opts = [] |
| 1037 |
for disable_opt in [ |
| 1038 |
"disable_3d", |
| 1039 |
"disable_advanced_gui", |
| 1040 |
"disable_physics_2d", |
| 1041 |
"disable_physics_3d", |
| 1042 |
"disable_navigation_2d", |
| 1043 |
"disable_navigation_3d", |
| 1044 |
]: |
| 1045 |
if env[disable_opt]: |
| 1046 |
unsupported_opts.append(disable_opt) |
| 1047 |
if unsupported_opts != []: |
| 1048 |
print_error( |
| 1049 |
"The following build option(s) cannot be used for editor builds, but only for export template builds: {}.".format( |
| 1050 |
", ".join(unsupported_opts) |
| 1051 |
) |
| 1052 |
) |
| 1053 |
Exit(255) |
| 1054 |
|
| 1055 |
if env["disable_3d"]: |
| 1056 |
env.Append(CPPDEFINES=["_3D_DISABLED"]) |
| 1057 |
env["disable_navigation_3d"] = True |
| 1058 |
env["disable_physics_3d"] = True |
| 1059 |
env["disable_xr"] = True |
| 1060 |
if env["disable_advanced_gui"]: |
| 1061 |
env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"]) |
| 1062 |
if env["disable_physics_2d"]: |
| 1063 |
env.Append(CPPDEFINES=["PHYSICS_2D_DISABLED"]) |
| 1064 |
if env["disable_physics_3d"]: |
| 1065 |
env.Append(CPPDEFINES=["PHYSICS_3D_DISABLED"]) |
| 1066 |
if env["disable_navigation_2d"]: |
| 1067 |
env.Append(CPPDEFINES=["NAVIGATION_2D_DISABLED"]) |
| 1068 |
if env["disable_navigation_3d"]: |
| 1069 |
env.Append(CPPDEFINES=["NAVIGATION_3D_DISABLED"]) |
| 1070 |
if env["disable_xr"]: |
| 1071 |
env.Append(CPPDEFINES=["XR_DISABLED"]) |
| 1072 |
if env["minizip"]: |
| 1073 |
env.Append(CPPDEFINES=["MINIZIP_ENABLED"]) |
| 1074 |
if env["brotli"]: |
| 1075 |
env.Append(CPPDEFINES=["BROTLI_ENABLED"]) |
| 1076 |
|
| 1077 |
if not env["disable_overrides"]: |
| 1078 |
env.Append(CPPDEFINES=["OVERRIDE_ENABLED"]) |
| 1079 |
|
| 1080 |
if env.editor_build or not env["disable_path_overrides"]: |
| 1081 |
env.Append(CPPDEFINES=["OVERRIDE_PATH_ENABLED"]) |
| 1082 |
|
| 1083 |
if not env["verbose"]: |
| 1084 |
methods.no_verbose(env) |
| 1085 |
|
| 1086 |
modules_enabled = OrderedDict() |
| 1087 |
env.module_dependencies = {} |
| 1088 |
env.module_icons_paths = [] |
| 1089 |
env.doc_class_path = platform_doc_class_path |
| 1090 |
|
| 1091 |
for name, path in modules_detected.items(): |
| 1092 |
if not env[f"module_{name}_enabled"]: |
| 1093 |
continue |
| 1094 |
sys.path.insert(0, path) |
| 1095 |
env.current_module = name |
| 1096 |
import config |
| 1097 |
|
| 1098 |
if config.can_build(env, env["platform"]): |
| 1099 |
|
| 1100 |
if not env.module_check_dependencies(name): |
| 1101 |
continue |
| 1102 |
|
| 1103 |
config.configure(env) |
| 1104 |
|
| 1105 |
try: |
| 1106 |
doc_classes = config.get_doc_classes() |
| 1107 |
doc_path = config.get_doc_path() |
| 1108 |
for c in doc_classes: |
| 1109 |
env.doc_class_path[c] = path + "/" + doc_path |
| 1110 |
except Exception: |
| 1111 |
pass |
| 1112 |
|
| 1113 |
try: |
| 1114 |
icons_path = config.get_icons_path() |
| 1115 |
env.module_icons_paths.append(path + "/" + icons_path) |
| 1116 |
except Exception: |
| 1117 |
|
| 1118 |
env.module_icons_paths.append(path + "/" + "icons") |
| 1119 |
modules_enabled[name] = path |
| 1120 |
|
| 1121 |
sys.path.remove(path) |
| 1122 |
sys.modules.pop("config") |
| 1123 |
|
| 1124 |
env.module_list = modules_enabled |
| 1125 |
methods.sort_module_list(env) |
| 1126 |
|
| 1127 |
if env.editor_build: |
| 1128 |
|
| 1129 |
env.module_add_dependencies("editor", ["freetype", "regex", "svg"]) |
| 1130 |
|
| 1131 |
|
| 1132 |
if not env.module_check_dependencies("editor"): |
| 1133 |
print_error("Not all modules required by editor builds are enabled.") |
| 1134 |
Exit(255) |
| 1135 |
|
| 1136 |
env["PROGSUFFIX_WRAP"] = suffix + env.module_version_string + ".console" + env["PROGSUFFIX"] |
| 1137 |
env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"] |
| 1138 |
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] |
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
if os.name == "nt": |
| 1144 |
|
| 1145 |
|
| 1146 |
env["LIBSUFFIXES"] += [env["LIBSUFFIX"]] |
| 1147 |
else: |
| 1148 |
env["LIBSUFFIXES"] += [env["LIBSUFFIX"], env["SHLIBSUFFIX"]] |
| 1149 |
env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"] |
| 1150 |
env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"] |
| 1151 |
|
| 1152 |
env["OBJPREFIX"] = env["object_prefix"] |
| 1153 |
env["SHOBJPREFIX"] = env["object_prefix"] |
| 1154 |
|
| 1155 |
GLSL_BUILDERS = { |
| 1156 |
"RD_GLSL": env.Builder( |
| 1157 |
action=env.Run(glsl_builders.build_rd_headers), |
| 1158 |
suffix="glsl.gen.h", |
| 1159 |
src_suffix=".glsl", |
| 1160 |
), |
| 1161 |
"GLSL_HEADER": env.Builder( |
| 1162 |
action=env.Run(glsl_builders.build_raw_headers), |
| 1163 |
suffix="glsl.gen.h", |
| 1164 |
src_suffix=".glsl", |
| 1165 |
), |
| 1166 |
"GLES3_GLSL": env.Builder( |
| 1167 |
action=env.Run(gles3_builders.build_gles3_headers), |
| 1168 |
suffix="glsl.gen.h", |
| 1169 |
src_suffix=".glsl", |
| 1170 |
), |
| 1171 |
} |
| 1172 |
env.Append(BUILDERS=GLSL_BUILDERS) |
| 1173 |
|
| 1174 |
if env["compiledb"]: |
| 1175 |
env.Tool("compilation_db") |
| 1176 |
env.Alias("compiledb", env.CompilationDatabase()) |
| 1177 |
env.NoCache(env.CompilationDatabase()) |
| 1178 |
if not env["verbose"]: |
| 1179 |
env["COMPILATIONDB_COMSTR"] = "$GENCOMSTR" |
| 1180 |
|
| 1181 |
if env["ninja"]: |
| 1182 |
if env.scons_version < (4, 2, 0): |
| 1183 |
print_error(f"The `ninja=yes` option requires SCons 4.2 or later, but your version is {scons_raw_version}.") |
| 1184 |
Exit(255) |
| 1185 |
|
| 1186 |
SetOption("experimental", "ninja") |
| 1187 |
env["NINJA_FILE_NAME"] = env["ninja_file"] |
| 1188 |
env["NINJA_DISABLE_AUTO_RUN"] = not env["ninja_auto_run"] |
| 1189 |
env.Tool("ninja", env["ninja_file"]) |
| 1190 |
|
| 1191 |
|
| 1192 |
if env["threads"]: |
| 1193 |
env.Append(CPPDEFINES=["THREADS_ENABLED"]) |
| 1194 |
|
| 1195 |
|
| 1196 |
env.Prepend(LIBEMITTER=[methods.redirect_emitter]) |
| 1197 |
env.Prepend(SHLIBEMITTER=[methods.redirect_emitter]) |
| 1198 |
for key in (emitters := env.StaticObject.builder.emitter): |
| 1199 |
emitters[key] = ListEmitter([methods.redirect_emitter] + env.Flatten(emitters[key])) |
| 1200 |
for key in (emitters := env.SharedObject.builder.emitter): |
| 1201 |
emitters[key] = ListEmitter([methods.redirect_emitter] + env.Flatten(emitters[key])) |
| 1202 |
|
| 1203 |
|
| 1204 |
if "c_compiler_launcher" in env: |
| 1205 |
env["CC"] = " ".join([env["c_compiler_launcher"], env["CC"]]) |
| 1206 |
|
| 1207 |
if "cpp_compiler_launcher" in env: |
| 1208 |
env["CXX"] = " ".join([env["cpp_compiler_launcher"], env["CXX"]]) |
| 1209 |
|
| 1210 |
|
| 1211 |
Export("env") |
| 1212 |
|
| 1213 |
SConscript("core/SCsub") |
| 1214 |
SConscript("servers/SCsub") |
| 1215 |
SConscript("scene/SCsub") |
| 1216 |
if env.editor_build: |
| 1217 |
SConscript("editor/SCsub") |
| 1218 |
SConscript("drivers/SCsub") |
| 1219 |
|
| 1220 |
SConscript("platform/SCsub") |
| 1221 |
SConscript("modules/SCsub") |
| 1222 |
if env["tests"]: |
| 1223 |
SConscript("tests/SCsub") |
| 1224 |
SConscript("main/SCsub") |
| 1225 |
|
| 1226 |
SConscript("platform/" + env["platform"] + "/SCsub") |
| 1227 |
|
| 1228 |
|
| 1229 |
if env["vsproj"]: |
| 1230 |
methods.generate_cpp_hint_file("cpp.hint") |
| 1231 |
env["CPPPATH"] = [Dir(path) for path in env["CPPPATH"]] |
| 1232 |
methods.generate_vs_project(env, ARGUMENTS, env["vsproj_name"]) |
| 1233 |
|
| 1234 |
|
| 1235 |
if not env.GetOption("clean") and not env.GetOption("help"): |
| 1236 |
methods.dump(env) |
| 1237 |
methods.show_progress(env) |
| 1238 |
methods.prepare_purge(env) |
| 1239 |
methods.prepare_timer() |