diff options
Diffstat (limited to 'SConstruct')
| -rw-r--r-- | SConstruct | 110 |
1 files changed, 57 insertions, 53 deletions
diff --git a/SConstruct b/SConstruct index d0d03bd8dc..f7504f72e1 100644 --- a/SConstruct +++ b/SConstruct @@ -55,6 +55,7 @@ _helper_module("modules.modules_builders", "modules/modules_builders.py") import methods import glsl_builders import gles3_builders +from platform_methods import architectures, architecture_aliases if methods.get_cmdline_bool("tools", True): _helper_module("editor.editor_builders", "editor/editor_builders.py") @@ -105,7 +106,7 @@ platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False)) if platform_arg == "android": custom_tools = ["clang", "clang++", "as", "ar", "link"] -elif platform_arg == "javascript": +elif platform_arg == "web": # Use generic POSIX build toolchain for Emscripten. custom_tools = ["cc", "c++", "ar", "link", "textfile", "zip"] elif os.name == "nt" and methods.get_cmdline_bool("use_mingw", False): @@ -161,16 +162,15 @@ if profile: opts = Variables(customs, ARGUMENTS) # Target build options -opts.Add("p", "Platform (alias for 'platform')", "") opts.Add("platform", "Target platform (%s)" % ("|".join(platform_list),), "") +opts.Add("p", "Platform (alias for 'platform')", "") opts.Add(BoolVariable("tools", "Build the tools (a.k.a. the Godot editor)", True)) opts.Add(EnumVariable("target", "Compilation target", "debug", ("debug", "release_debug", "release"))) -opts.Add("arch", "Platform-dependent architecture (arm/arm64/x86/x64/mips/...)", "") -opts.Add(EnumVariable("bits", "Target platform bits", "default", ("default", "32", "64"))) -opts.Add(EnumVariable("float", "Floating-point precision", "default", ("default", "32", "64"))) +opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectures, architecture_aliases)) +opts.Add(EnumVariable("float", "Floating-point precision", "32", ("32", "64"))) opts.Add(EnumVariable("optimize", "Optimization type", "speed", ("speed", "size", "none"))) opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False)) -opts.Add(BoolVariable("use_lto", "Use link-time optimization", False)) +opts.Add(EnumVariable("lto", "Link-time optimization (for production buids)", "none", ("none", "thin", "full"))) # Components opts.Add(BoolVariable("deprecated", "Enable compatibility code for deprecated and removed features", True)) @@ -438,45 +438,6 @@ if selected_platform in platform_list: ) env.SetOption("num_jobs", safer_cpu_count) - if env["compiledb"]: - # Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later. - from SCons import __version__ as scons_raw_version - - scons_ver = env._get_major_minor_revision(scons_raw_version) - - if scons_ver >= (4, 0, 0): - env.Tool("compilation_db") - env.Alias("compiledb", env.CompilationDatabase()) - - # 'dev' and 'production' are aliases to set default options if they haven't been set - # manually by the user. - if env["dev"]: - env["verbose"] = methods.get_cmdline_bool("verbose", True) - env["warnings"] = ARGUMENTS.get("warnings", "extra") - env["werror"] = methods.get_cmdline_bool("werror", True) - if env["tools"]: - env["tests"] = methods.get_cmdline_bool("tests", True) - if env["production"]: - env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True) - env["use_lto"] = methods.get_cmdline_bool("use_lto", True) - env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False) - if not env["tools"] and env["target"] == "debug": - print( - "WARNING: Requested `production` build with `tools=no target=debug`, " - "this will give you a full debug template (use `target=release_debug` " - "for an optimized template with debug features)." - ) - if env.msvc: - print( - "WARNING: For `production` Windows builds, you should use MinGW with GCC " - "or Clang instead of Visual Studio, as they can better optimize the " - "GDScript VM in a very significant way. MSVC LTO also doesn't work " - "reliably for our use case." - "If you want to use MSVC nevertheless for production builds, set " - "`debug_symbols=no use_lto=no` instead of the `production=yes` option." - ) - Exit(255) - env.extra_suffix = "" if env["extra_suffix"] != "": @@ -502,12 +463,17 @@ if selected_platform in platform_list: # Platform specific flags flag_list = platform_flags[selected_platform] for f in flag_list: - if not (f[0] in ARGUMENTS): # allow command line to override platform flags + if not (f[0] in ARGUMENTS) or ARGUMENTS[f[0]] == "auto": # Allow command line to override platform flags env[f[0]] = f[1] # Must happen after the flags' definition, so that they can be used by platform detect detect.configure(env) + print( + 'Building for platform "%s", architecture "%s", %s, target "%s".' + % (selected_platform, env["arch"], "editor" if env["tools"] else "template", env["target"]) + ) + # Set our C and C++ standard requirements. # C++17 is required as we need guaranteed copy elision as per GH-36436. # Prepending to make it possible to override. @@ -522,6 +488,37 @@ if selected_platform in platform_list: # We apply it to CCFLAGS (both C and C++ code) in case it impacts C features. env.Prepend(CCFLAGS=["/std:c++17"]) + # 'dev' and 'production' are aliases to set default options if they haven't been set + # manually by the user. + if env["dev"]: + env["verbose"] = methods.get_cmdline_bool("verbose", True) + env["warnings"] = ARGUMENTS.get("warnings", "extra") + env["werror"] = methods.get_cmdline_bool("werror", True) + if env["tools"]: + env["tests"] = methods.get_cmdline_bool("tests", True) + if env["production"]: + env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True) + env["lto"] = ARGUMENTS.get("lto", "full") + env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False) + if not env["tools"] and env["target"] == "debug": + print( + "WARNING: Requested `production` build with `tools=no target=debug`, " + "this will give you a full debug template (use `target=release_debug` " + "for an optimized template with debug features)." + ) + if env.msvc: + print( + "WARNING: For `production` Windows builds, you should use MinGW with GCC " + "or Clang instead of Visual Studio, as they can better optimize the " + "GDScript VM in a very significant way. MSVC LTO also doesn't work " + "reliably for our use case." + "If you want to use MSVC nevertheless for production builds, set " + "`debug_symbols=no lto=none` instead of the `production=yes` option." + ) + Exit(255) + if env["lto"] != "none": + print("Using LTO: " + env["lto"]) + # Enforce our minimal compiler version requirements cc_version = methods.get_compiler_version(env) or { "major": None, @@ -693,13 +690,7 @@ if selected_platform in platform_list: ) suffix += ".debug" - if env["arch"] != "": - suffix += "." + env["arch"] - elif env["bits"] == "32": - suffix += ".32" - elif env["bits"] == "64": - suffix += ".64" - + suffix += "." + env["arch"] suffix += env.extra_suffix sys.path.remove(tmppath) @@ -838,6 +829,19 @@ if selected_platform in platform_list: env.vs_incs = [] env.vs_srcs = [] + if env["compiledb"]: + # Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later. + from SCons import __version__ as scons_raw_version + + scons_ver = env._get_major_minor_revision(scons_raw_version) + + if scons_ver < (4, 0, 0): + print("The `compiledb=yes` option requires SCons 4.0 or later, but your version is %s." % scons_raw_version) + Exit(255) + + env.Tool("compilation_db") + env.Alias("compiledb", env.CompilationDatabase()) + Export("env") # Build subdirs, the build order is dependent on link order. |