summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct62
1 files changed, 35 insertions, 27 deletions
diff --git a/SConstruct b/SConstruct
index fe94715bba..9496595a26 100644
--- a/SConstruct
+++ b/SConstruct
@@ -8,6 +8,7 @@ import glob
import os
import pickle
import sys
+from collections import OrderedDict
# Local
import methods
@@ -85,6 +86,7 @@ env_base.__class__.add_library = methods.add_library
env_base.__class__.add_program = methods.add_program
env_base.__class__.CommandNoCache = methods.CommandNoCache
env_base.__class__.disable_warnings = methods.disable_warnings
+env_base.__class__.module_check_dependencies = methods.module_check_dependencies
env_base["x86_libtheora_opt_gcc"] = False
env_base["x86_libtheora_opt_vc"] = False
@@ -180,18 +182,22 @@ for k in platform_opts.keys():
for o in opt_list:
opts.Add(o)
+# Update the environment now as the "custom_modules" option may be
+# defined in a file rather than specified via the command line.
+opts.Update(env_base)
+
# Detect modules.
-modules_detected = {}
+modules_detected = OrderedDict()
module_search_paths = ["modules"] # Built-in path.
-if ARGUMENTS.get("custom_modules"):
- paths = ARGUMENTS.get("custom_modules").split(",")
+if env_base["custom_modules"]:
+ paths = env_base["custom_modules"].split(",")
for p in paths:
try:
module_search_paths.append(methods.convert_custom_modules_path(p))
except ValueError as e:
print(e)
- sys.exit(255)
+ Exit(255)
for path in module_search_paths:
# Note: custom modules can override built-in ones.
@@ -216,8 +222,9 @@ for name, path in modules_detected.items():
methods.write_modules(modules_detected)
-opts.Update(env_base) # update environment
-Help(opts.GenerateHelpText(env_base)) # generate help
+# Update the environment again after all the module options are added.
+opts.Update(env_base)
+Help(opts.GenerateHelpText(env_base))
# add default include paths
@@ -392,7 +399,7 @@ if selected_platform in platform_list:
'newer GCC version, or Clang 6 or later by passing "use_llvm=yes" '
"to the SCons command line."
)
- sys.exit(255)
+ Exit(255)
elif cc_version_major < 7:
print(
"Detected GCC version older than 7, which does not fully support "
@@ -400,7 +407,7 @@ if selected_platform in platform_list:
'version, or Clang 6 or later by passing "use_llvm=yes" to the '
"SCons command line."
)
- sys.exit(255)
+ Exit(255)
elif methods.using_clang(env):
# Apple LLVM versions differ from upstream LLVM version \o/, compare
# in https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
@@ -411,19 +418,19 @@ if selected_platform in platform_list:
"Detected Clang version older than 6, which does not fully support "
"C++17. Supported versions are Clang 6 and later."
)
- sys.exit(255)
+ Exit(255)
elif not vanilla and cc_version_major < 10:
print(
"Detected Apple Clang version older than 10, which does not fully "
"support C++17. Supported versions are Apple Clang 10 and later."
)
- sys.exit(255)
+ Exit(255)
elif cc_version_major < 6:
print(
"Detected Clang version older than 6, which does not fully support "
"C++17. Supported versions are Clang 6 and later."
)
- sys.exit(255)
+ Exit(255)
# Configure compiler warnings
if env.msvc:
@@ -496,7 +503,7 @@ if selected_platform in platform_list:
if env["target"] == "release":
if env["tools"]:
print("Tools can only be built with targets 'debug' and 'release_debug'.")
- sys.exit(255)
+ Exit(255)
suffix += ".opt"
env.Append(CPPDEFINES=["NDEBUG"])
@@ -523,11 +530,11 @@ if selected_platform in platform_list:
sys.path.remove(tmppath)
sys.modules.pop("detect")
- modules_enabled = {}
+ modules_enabled = OrderedDict()
env.module_icons_paths = []
env.doc_class_path = {}
- for name, path in sorted(modules_detected.items()):
+ for name, path in modules_detected.items():
if not env["module_" + name + "_enabled"]:
continue
sys.path.insert(0, path)
@@ -585,7 +592,7 @@ if selected_platform in platform_list:
"Build option 'disable_3d=yes' cannot be used with 'tools=yes' (editor), "
"only with 'tools=no' (export template)."
)
- sys.exit(255)
+ Exit(255)
else:
env.Append(CPPDEFINES=["_3D_DISABLED"])
if env["disable_advanced_gui"]:
@@ -594,21 +601,19 @@ if selected_platform in platform_list:
"Build option 'disable_advanced_gui=yes' cannot be used with 'tools=yes' (editor), "
"only with 'tools=no' (export template)."
)
- sys.exit(255)
+ Exit(255)
else:
env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"])
if env["minizip"]:
env.Append(CPPDEFINES=["MINIZIP_ENABLED"])
editor_module_list = ["regex"]
- for x in editor_module_list:
- if not env["module_" + x + "_enabled"]:
- if env["tools"]:
- print(
- "Build option 'module_" + x + "_enabled=no' cannot be used with 'tools=yes' (editor), "
- "only with 'tools=no' (export template)."
- )
- sys.exit(255)
+ if env["tools"] and not env.module_check_dependencies("tools", editor_module_list):
+ print(
+ "Build option 'module_" + x + "_enabled=no' cannot be used with 'tools=yes' (editor), "
+ "only with 'tools=no' (export template)."
+ )
+ Exit(255)
if not env["verbose"]:
methods.no_verbose(sys, env)
@@ -684,10 +689,13 @@ elif selected_platform != "":
if selected_platform == "list":
# Exit early to suppress the rest of the built-in SCons messages
- sys.exit(0)
+ Exit()
else:
- sys.exit(255)
+ Exit(255)
-# The following only makes sense when the env is defined, and assumes it is
+# The following only makes sense when the 'env' is defined, and assumes it is.
if "env" in locals():
methods.show_progress(env)
+ # TODO: replace this with `env.Dump(format="json")`
+ # once we start requiring SCons 4.0 as min version.
+ methods.dump(env)