summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct92
1 files changed, 47 insertions, 45 deletions
diff --git a/SConstruct b/SConstruct
index 6aeb79e483..2281b8a77f 100644
--- a/SConstruct
+++ b/SConstruct
@@ -115,7 +115,6 @@ 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("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))
@@ -131,14 +130,13 @@ 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))
@@ -176,16 +174,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()
@@ -225,6 +261,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
@@ -261,41 +298,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)