diff options
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 148 |
1 files changed, 86 insertions, 62 deletions
diff --git a/SConstruct b/SConstruct index 46e0da89e8..000c918808 100644 --- a/SConstruct +++ b/SConstruct @@ -67,7 +67,6 @@ if "TERM" in os.environ: env_base.AppendENVPath("PATH", os.getenv("PATH")) env_base.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) env_base.disabled_modules = [] -env_base.use_ptrcall = False env_base.module_version_string = "" env_base.msvc = False @@ -106,17 +105,15 @@ if profile: opts = Variables(customs, ARGUMENTS) # Target build options -opts.Add("arch", "Platform-dependent architecture (arm/arm64/x86/x64/mips/...)", "") -opts.Add(EnumVariable("bits", "Target platform bits", "default", ("default", "32", "64"))) opts.Add("p", "Platform (alias for 'platform')", "") opts.Add("platform", "Target platform (%s)" % ("|".join(platform_list),), "") +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("optimize", "Optimization type", "speed", ("speed", "size"))) - -opts.Add(BoolVariable("tools", "Build the tools (a.k.a. the Godot editor)", True)) -opts.Add(BoolVariable("tests", "Build the unit tests", False)) +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(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False)) # Components opts.Add(BoolVariable("deprecated", "Enable deprecated features", True)) @@ -126,26 +123,29 @@ opts.Add("custom_modules", "A list of comma-separated directory paths containing opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True)) # Advanced options -opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False)) +opts.Add(BoolVariable("dev", "If yes, alias for verbose=yes warnings=extra werror=yes", False)) opts.Add(BoolVariable("progress", "Show a progress indicator during compilation", True)) +opts.Add(BoolVariable("tests", "Build the unit tests", False)) +opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False)) opts.Add(EnumVariable("warnings", "Level of compilation warnings", "all", ("extra", "all", "moderate", "no"))) opts.Add(BoolVariable("werror", "Treat compiler warnings as errors", False)) -opts.Add(BoolVariable("dev", "If yes, alias for verbose=yes warnings=extra werror=yes", False)) opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files", "") opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False)) -opts.Add(EnumVariable("macports_clang", "Build using Clang from MacPorts", "no", ("no", "5.0", "devel"))) opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False)) opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False)) opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", False)) opts.Add("system_certs_path", "Use this path as SSL certificates default for editor (for package maintainers)", "") +opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False)) # Thirdparty libraries -# opts.Add(BoolVariable('builtin_assimp', "Use the built-in Assimp library", True)) opts.Add(BoolVariable("builtin_bullet", "Use the built-in Bullet library", True)) opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", True)) opts.Add(BoolVariable("builtin_enet", "Use the built-in ENet library", True)) opts.Add(BoolVariable("builtin_freetype", "Use the built-in FreeType library", True)) opts.Add(BoolVariable("builtin_glslang", "Use the built-in glslang library", True)) +opts.Add(BoolVariable("builtin_graphite", "Use the built-in Graphite library", True)) +opts.Add(BoolVariable("builtin_harfbuzz", "Use the built-in HarfBuzz library", True)) +opts.Add(BoolVariable("builtin_icu", "Use the built-in ICU library", True)) opts.Add(BoolVariable("builtin_libogg", "Use the built-in libogg library", True)) opts.Add(BoolVariable("builtin_libpng", "Use the built-in libpng library", True)) opts.Add(BoolVariable("builtin_libtheora", "Use the built-in libtheora library", True)) @@ -175,16 +175,54 @@ opts.Add("CFLAGS", "Custom flags for the C compiler") opts.Add("CXXFLAGS", "Custom flags for the C++ compiler") opts.Add("LINKFLAGS", "Custom flags for the linker") -# add platform specific options +# Update the environment to have all above options defined +# in following code (especially platform and custom_modules). +opts.Update(env_base) + +# Platform selection: validate input, and add options. + +selected_platform = "" + +if env_base["platform"] != "": + selected_platform = env_base["platform"] +elif env_base["p"] != "": + selected_platform = env_base["p"] +else: + # Missing `platform` argument, try to detect platform automatically + if sys.platform.startswith("linux"): + selected_platform = "linuxbsd" + elif sys.platform == "darwin": + selected_platform = "osx" + elif sys.platform == "win32": + selected_platform = "windows" + else: + print("Could not detect platform automatically. Supported platforms:") + for x in platform_list: + print("\t" + x) + print("\nPlease run SCons again and select a valid platform: platform=<string>") + + if selected_platform != "": + print("Automatically detected platform: " + selected_platform) + +if selected_platform in ["linux", "bsd", "x11"]: + if selected_platform == "x11": + # Deprecated alias kept for compatibility. + print('Platform "x11" has been renamed to "linuxbsd" in Godot 4.0. Building for platform "linuxbsd".') + # Alias for convenience. + selected_platform = "linuxbsd" + +# Make sure to update this to the found, valid platform as it's used through the buildsystem as the reference. +# It should always be re-set after calling `opts.Update()` otherwise it uses the original input value. +env_base["platform"] = selected_platform -for k in platform_opts.keys(): - opt_list = platform_opts[k] - for o in opt_list: - opts.Add(o) +# Add platform-specific options. +if selected_platform in platform_opts: + for opt in platform_opts[selected_platform]: + opts.Add(opt) -# Update the environment now as the "custom_modules" option may be -# defined in a file rather than specified via the command line. +# Update the environment to take platform-specific options into account. opts.Update(env_base) +env_base["platform"] = selected_platform # Must always be re-set after calling opts.Update(). # Detect modules. modules_detected = OrderedDict() @@ -230,6 +268,7 @@ methods.write_modules(modules_detected) # Update the environment again after all the module options are added. opts.Update(env_base) +env_base["platform"] = selected_platform # Must always be re-set after calling opts.Update(). Help(opts.GenerateHelpText(env_base)) # add default include paths @@ -266,41 +305,6 @@ if env_base["no_editor_splash"]: if not env_base["deprecated"]: env_base.Append(CPPDEFINES=["DISABLE_DEPRECATED"]) -env_base.platforms = {} - -selected_platform = "" - -if env_base["platform"] != "": - selected_platform = env_base["platform"] -elif env_base["p"] != "": - selected_platform = env_base["p"] - env_base["platform"] = selected_platform -else: - # Missing `platform` argument, try to detect platform automatically - if sys.platform.startswith("linux"): - selected_platform = "linuxbsd" - elif sys.platform == "darwin": - selected_platform = "osx" - elif sys.platform == "win32": - selected_platform = "windows" - else: - print("Could not detect platform automatically. Supported platforms:") - for x in platform_list: - print("\t" + x) - print("\nPlease run SCons again and select a valid platform: platform=<string>") - - if selected_platform != "": - print("Automatically detected platform: " + selected_platform) - env_base["platform"] = selected_platform - -if selected_platform in ["linux", "bsd", "x11"]: - if selected_platform == "x11": - # Deprecated alias kept for compatibility. - print('Platform "x11" has been renamed to "linuxbsd" in Godot 4.0. Building for platform "linuxbsd".') - # Alias for convenience. - selected_platform = "linuxbsd" - env_base["platform"] = selected_platform - if selected_platform in platform_list: tmppath = "./platform/" + selected_platform sys.path.insert(0, tmppath) @@ -311,7 +315,7 @@ if selected_platform in platform_list: else: env = env_base.Clone() - # Compilation DB requires SCons 3.1.1+. + # 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) @@ -320,12 +324,34 @@ if selected_platform in platform_list: 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. We use `ARGUMENTS.get()` to check if they were manually set. if env["dev"]: - env["verbose"] = True - env["warnings"] = "extra" - env["werror"] = True + env["verbose"] = ARGUMENTS.get("verbose", True) + env["warnings"] = ARGUMENTS.get("warnings", "extra") + env["werror"] = ARGUMENTS.get("werror", True) if env["tools"]: - env["tests"] = True + env["tests"] = ARGUMENTS.get("tests", True) + if env["production"]: + env["use_static_cpp"] = ARGUMENTS.get("use_static_cpp", True) + env["use_lto"] = ARGUMENTS.get("use_lto", True) + env["debug_symbols"] = ARGUMENTS.get("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 = "" @@ -535,13 +561,13 @@ if selected_platform in platform_list: doc_path = config.get_doc_path() for c in doc_classes: env.doc_class_path[c] = path + "/" + doc_path - except: + except Exception: pass # Get icon paths (if present) try: icons_path = config.get_icons_path() env.module_icons_paths.append(path + "/" + icons_path) - except: + except Exception: # Default path for module icons env.module_icons_paths.append(path + "/" + "icons") modules_enabled[name] = path @@ -568,8 +594,6 @@ if selected_platform in platform_list: env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"] env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"] - if env.use_ptrcall: - env.Append(CPPDEFINES=["PTRCALL_ENABLED"]) if env["tools"]: env.Append(CPPDEFINES=["TOOLS_ENABLED"]) if env["disable_3d"]: |