SCons: Refactor `selected_platform` conditional

This commit is contained in:
Thaddeus Crews 2024-04-04 12:38:58 -05:00
parent f6a78f83aa
commit c6995be6e4
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
1 changed files with 514 additions and 529 deletions

View File

@ -303,11 +303,6 @@ else:
selected_platform = "macos" selected_platform = "macos"
elif sys.platform == "win32": elif sys.platform == "win32":
selected_platform = "windows" 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 != "": if selected_platform != "":
print("Automatically detected platform: " + selected_platform) print("Automatically detected platform: " + selected_platform)
@ -334,6 +329,16 @@ if selected_platform == "javascript":
print('Platform "javascript" has been renamed to "web" in Godot 4. Building for platform "web".') print('Platform "javascript" has been renamed to "web" in Godot 4. Building for platform "web".')
selected_platform = "web" selected_platform = "web"
if selected_platform not in platform_list:
if selected_platform == "":
print("Could not detect platform automatically.")
elif selected_platform != "list":
print(f'Invalid target platform "{selected_platform}".')
print(f"The following platforms are available:\n\t{'\n\t'.join(platform_list)}\n")
print("Please run SCons again and select a valid platform: platform=<string>.")
Exit(0 if selected_platform == "list" else 255)
# Make sure to update this to the found, valid platform as it's used through the buildsystem as the reference. # 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. # It should always be re-set after calling `opts.Update()` otherwise it uses the original input value.
env_base["platform"] = selected_platform env_base["platform"] = selected_platform
@ -480,20 +485,19 @@ if not env_base["deprecated"]:
if env_base["precision"] == "double": if env_base["precision"] == "double":
env_base.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"]) env_base.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"])
if selected_platform in platform_list: tmppath = "./platform/" + selected_platform
tmppath = "./platform/" + selected_platform sys.path.insert(0, tmppath)
sys.path.insert(0, tmppath) import detect
import detect
env = env_base.Clone() env = env_base.Clone()
# Default num_jobs to local cpu count if not user specified. # Default num_jobs to local cpu count if not user specified.
# SCons has a peculiarity where user-specified options won't be overridden # SCons has a peculiarity where user-specified options won't be overridden
# by SetOption, so we can rely on this to know if we should use our default. # by SetOption, so we can rely on this to know if we should use our default.
initial_num_jobs = env.GetOption("num_jobs") initial_num_jobs = env.GetOption("num_jobs")
altered_num_jobs = initial_num_jobs + 1 altered_num_jobs = initial_num_jobs + 1
env.SetOption("num_jobs", altered_num_jobs) env.SetOption("num_jobs", altered_num_jobs)
if env.GetOption("num_jobs") == altered_num_jobs: if env.GetOption("num_jobs") == altered_num_jobs:
cpu_count = os.cpu_count() cpu_count = os.cpu_count()
if cpu_count is None: if cpu_count is None:
print("Couldn't auto-detect CPU count to configure build parallelism. Specify it with the -j argument.") print("Couldn't auto-detect CPU count to configure build parallelism. Specify it with the -j argument.")
@ -505,21 +509,21 @@ if selected_platform in platform_list:
) )
env.SetOption("num_jobs", safer_cpu_count) env.SetOption("num_jobs", safer_cpu_count)
env.extra_suffix = "" env.extra_suffix = ""
if env["extra_suffix"] != "": if env["extra_suffix"] != "":
env.extra_suffix += "." + env["extra_suffix"] env.extra_suffix += "." + env["extra_suffix"]
# Environment flags # Environment flags
env.Append(CPPDEFINES=env.get("cppdefines", "").split()) env.Append(CPPDEFINES=env.get("cppdefines", "").split())
env.Append(CCFLAGS=env.get("ccflags", "").split()) env.Append(CCFLAGS=env.get("ccflags", "").split())
env.Append(CXXFLAGS=env.get("cxxflags", "").split()) env.Append(CXXFLAGS=env.get("cxxflags", "").split())
env.Append(CFLAGS=env.get("cflags", "").split()) env.Append(CFLAGS=env.get("cflags", "").split())
env.Append(LINKFLAGS=env.get("linkflags", "").split()) env.Append(LINKFLAGS=env.get("linkflags", "").split())
# Feature build profile # Feature build profile
disabled_classes = [] disabled_classes = []
if env["build_profile"] != "": if env["build_profile"] != "":
print("Using feature build profile: " + env["build_profile"]) print("Using feature build profile: " + env["build_profile"])
import json import json
@ -534,32 +538,32 @@ if selected_platform in platform_list:
except: except:
print("Error opening feature build profile: " + env["build_profile"]) print("Error opening feature build profile: " + env["build_profile"])
Exit(255) Exit(255)
methods.write_disabled_classes(disabled_classes) methods.write_disabled_classes(disabled_classes)
# Platform specific flags. # Platform specific flags.
# These can sometimes override default options. # These can sometimes override default options.
flag_list = platform_flags[selected_platform] flag_list = platform_flags[selected_platform]
for f in flag_list: for f in flag_list:
if not (f[0] in ARGUMENTS) or ARGUMENTS[f[0]] == "auto": # 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] env[f[0]] = f[1]
# 'dev_mode' and 'production' are aliases to set default options if they haven't been # 'dev_mode' and 'production' are aliases to set default options if they haven't been
# set manually by the user. # set manually by the user.
# These need to be checked *after* platform specific flags so that different # These need to be checked *after* platform specific flags so that different
# default values can be set (e.g. to keep LTO off for `production` on some platforms). # default values can be set (e.g. to keep LTO off for `production` on some platforms).
if env["dev_mode"]: if env["dev_mode"]:
env["verbose"] = methods.get_cmdline_bool("verbose", True) env["verbose"] = methods.get_cmdline_bool("verbose", True)
env["warnings"] = ARGUMENTS.get("warnings", "extra") env["warnings"] = ARGUMENTS.get("warnings", "extra")
env["werror"] = methods.get_cmdline_bool("werror", True) env["werror"] = methods.get_cmdline_bool("werror", True)
env["tests"] = methods.get_cmdline_bool("tests", True) env["tests"] = methods.get_cmdline_bool("tests", True)
if env["production"]: if env["production"]:
env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True) env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True)
env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False) env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False)
# LTO "auto" means we handle the preferred option in each platform detect.py. # LTO "auto" means we handle the preferred option in each platform detect.py.
env["lto"] = ARGUMENTS.get("lto", "auto") env["lto"] = ARGUMENTS.get("lto", "auto")
# Run SCU file generation script if in a SCU build. # Run SCU file generation script if in a SCU build.
if env["scu_build"]: if env["scu_build"]:
max_includes_per_scu = 8 max_includes_per_scu = 8
if env_base.dev_build == True: if env_base.dev_build == True:
max_includes_per_scu = 1024 max_includes_per_scu = 1024
@ -571,18 +575,18 @@ if selected_platform in platform_list:
methods.set_scu_folders(scu_builders.generate_scu_files(max_includes_per_scu)) methods.set_scu_folders(scu_builders.generate_scu_files(max_includes_per_scu))
# Must happen after the flags' definition, as configure is when most flags # Must happen after the flags' definition, as configure is when most flags
# are actually handled to change compile options, etc. # are actually handled to change compile options, etc.
detect.configure(env) detect.configure(env)
print(f'Building for platform "{selected_platform}", architecture "{env["arch"]}", target "{env["target"]}".') print(f'Building for platform "{selected_platform}", architecture "{env["arch"]}", target "{env["target"]}".')
if env.dev_build: if env.dev_build:
print("NOTE: Developer build, with debug optimization level and debug symbols (unless overridden).") print("NOTE: Developer build, with debug optimization level and debug symbols (unless overridden).")
# Set optimize and debug_symbols flags. # Set optimize and debug_symbols flags.
# "custom" means do nothing and let users set their own optimization flags. # "custom" means do nothing and let users set their own optimization flags.
# Needs to happen after configure to have `env.msvc` defined. # Needs to happen after configure to have `env.msvc` defined.
if env.msvc: if env.msvc:
if env["debug_symbols"]: if env["debug_symbols"]:
env.Append(CCFLAGS=["/Zi", "/FS"]) env.Append(CCFLAGS=["/Zi", "/FS"])
env.Append(LINKFLAGS=["/DEBUG:FULL"]) env.Append(LINKFLAGS=["/DEBUG:FULL"])
@ -600,7 +604,7 @@ if selected_platform in platform_list:
env.Append(LINKFLAGS=["/OPT:REF"]) env.Append(LINKFLAGS=["/OPT:REF"])
elif env["optimize"] == "debug" or env["optimize"] == "none": elif env["optimize"] == "debug" or env["optimize"] == "none":
env.Append(CCFLAGS=["/Od"]) env.Append(CCFLAGS=["/Od"])
else: else:
if env["debug_symbols"]: if env["debug_symbols"]:
# Adding dwarf-4 explicitly makes stacktraces work with clang builds, # Adding dwarf-4 explicitly makes stacktraces work with clang builds,
# otherwise addr2line doesn't understand them # otherwise addr2line doesn't understand them
@ -628,38 +632,38 @@ if selected_platform in platform_list:
elif env["optimize"] == "none": elif env["optimize"] == "none":
env.Append(CCFLAGS=["-O0"]) env.Append(CCFLAGS=["-O0"])
# Needs to happen after configure to handle "auto". # Needs to happen after configure to handle "auto".
if env["lto"] != "none": if env["lto"] != "none":
print("Using LTO: " + env["lto"]) print("Using LTO: " + env["lto"])
# Set our C and C++ standard requirements. # Set our C and C++ standard requirements.
# C++17 is required as we need guaranteed copy elision as per GH-36436. # C++17 is required as we need guaranteed copy elision as per GH-36436.
# Prepending to make it possible to override. # Prepending to make it possible to override.
# This needs to come after `configure`, otherwise we don't have env.msvc. # This needs to come after `configure`, otherwise we don't have env.msvc.
if not env.msvc: if not env.msvc:
# Specifying GNU extensions support explicitly, which are supported by # Specifying GNU extensions support explicitly, which are supported by
# both GCC and Clang. Both currently default to gnu11 and gnu++14. # both GCC and Clang. Both currently default to gnu11 and gnu++14.
env.Prepend(CFLAGS=["-std=gnu11"]) env.Prepend(CFLAGS=["-std=gnu11"])
env.Prepend(CXXFLAGS=["-std=gnu++17"]) env.Prepend(CXXFLAGS=["-std=gnu++17"])
else: else:
# MSVC doesn't have clear C standard support, /std only covers C++. # MSVC doesn't have clear C standard support, /std only covers C++.
# We apply it to CCFLAGS (both C and C++ code) in case it impacts C features. # We apply it to CCFLAGS (both C and C++ code) in case it impacts C features.
env.Prepend(CCFLAGS=["/std:c++17"]) env.Prepend(CCFLAGS=["/std:c++17"])
# Enforce our minimal compiler version requirements # Enforce our minimal compiler version requirements
cc_version = methods.get_compiler_version(env) or { cc_version = methods.get_compiler_version(env) or {
"major": None, "major": None,
"minor": None, "minor": None,
"patch": None, "patch": None,
"metadata1": None, "metadata1": None,
"metadata2": None, "metadata2": None,
"date": None, "date": None,
} }
cc_version_major = int(cc_version["major"] or -1) cc_version_major = int(cc_version["major"] or -1)
cc_version_minor = int(cc_version["minor"] or -1) cc_version_minor = int(cc_version["minor"] or -1)
cc_version_metadata1 = cc_version["metadata1"] or "" cc_version_metadata1 = cc_version["metadata1"] or ""
if methods.using_gcc(env): if methods.using_gcc(env):
if cc_version_major == -1: if cc_version_major == -1:
print( print(
"Couldn't detect compiler version, skipping version checks. " "Couldn't detect compiler version, skipping version checks. "
@ -691,7 +695,7 @@ if selected_platform in platform_list:
"to switch to posix threads." "to switch to posix threads."
) )
Exit(255) Exit(255)
elif methods.using_clang(env): elif methods.using_clang(env):
if cc_version_major == -1: if cc_version_major == -1:
print( print(
"Couldn't detect compiler version, skipping version checks. " "Couldn't detect compiler version, skipping version checks. "
@ -720,18 +724,18 @@ if selected_platform in platform_list:
) )
Exit(255) Exit(255)
# Disable exception handling. Godot doesn't use exceptions anywhere, and this # Disable exception handling. Godot doesn't use exceptions anywhere, and this
# saves around 20% of binary size and very significant build time (GH-80513). # saves around 20% of binary size and very significant build time (GH-80513).
if env["disable_exceptions"]: if env["disable_exceptions"]:
if env.msvc: if env.msvc:
env.Append(CPPDEFINES=[("_HAS_EXCEPTIONS", 0)]) env.Append(CPPDEFINES=[("_HAS_EXCEPTIONS", 0)])
else: else:
env.Append(CXXFLAGS=["-fno-exceptions"]) env.Append(CXXFLAGS=["-fno-exceptions"])
elif env.msvc: elif env.msvc:
env.Append(CXXFLAGS=["/EHsc"]) env.Append(CXXFLAGS=["/EHsc"])
# Configure compiler warnings # Configure compiler warnings
if env.msvc: # MSVC if env.msvc: # MSVC
if env["warnings"] == "no": if env["warnings"] == "no":
env.Append(CCFLAGS=["/w"]) env.Append(CCFLAGS=["/w"])
else: else:
@ -762,7 +766,7 @@ if selected_platform in platform_list:
if env["werror"]: if env["werror"]:
env.Append(CCFLAGS=["/WX"]) env.Append(CCFLAGS=["/WX"])
env.Append(LINKFLAGS=["/WX"]) env.Append(LINKFLAGS=["/WX"])
else: # GCC, Clang else: # GCC, Clang
common_warnings = [] common_warnings = []
if methods.using_gcc(env): if methods.using_gcc(env):
@ -813,34 +817,34 @@ if selected_platform in platform_list:
if env["werror"]: if env["werror"]:
env.Append(CCFLAGS=["-Werror"]) env.Append(CCFLAGS=["-Werror"])
if hasattr(detect, "get_program_suffix"): if hasattr(detect, "get_program_suffix"):
suffix = "." + detect.get_program_suffix() suffix = "." + detect.get_program_suffix()
else: else:
suffix = "." + selected_platform suffix = "." + selected_platform
suffix += "." + env["target"] suffix += "." + env["target"]
if env.dev_build: if env.dev_build:
suffix += ".dev" suffix += ".dev"
if env_base["precision"] == "double": if env_base["precision"] == "double":
suffix += ".double" suffix += ".double"
suffix += "." + env["arch"] suffix += "." + env["arch"]
if not env["threads"]: if not env["threads"]:
suffix += ".nothreads" suffix += ".nothreads"
suffix += env.extra_suffix suffix += env.extra_suffix
sys.path.remove(tmppath) sys.path.remove(tmppath)
sys.modules.pop("detect") sys.modules.pop("detect")
modules_enabled = OrderedDict() modules_enabled = OrderedDict()
env.module_dependencies = {} env.module_dependencies = {}
env.module_icons_paths = [] env.module_icons_paths = []
env.doc_class_path = platform_doc_class_path env.doc_class_path = platform_doc_class_path
for name, path in modules_detected.items(): for name, path in modules_detected.items():
if not env["module_" + name + "_enabled"]: if not env["module_" + name + "_enabled"]:
continue continue
sys.path.insert(0, path) sys.path.insert(0, path)
@ -873,10 +877,10 @@ if selected_platform in platform_list:
sys.path.remove(path) sys.path.remove(path)
sys.modules.pop("config") sys.modules.pop("config")
env.module_list = modules_enabled env.module_list = modules_enabled
methods.sort_module_list(env) methods.sort_module_list(env)
if env.editor_build: if env.editor_build:
# Add editor-specific dependencies to the dependency graph. # Add editor-specific dependencies to the dependency graph.
env.module_add_dependencies("editor", ["freetype", "svg"]) env.module_add_dependencies("editor", ["freetype", "svg"])
@ -885,34 +889,34 @@ if selected_platform in platform_list:
print("Not all modules required by editor builds are enabled.") print("Not all modules required by editor builds are enabled.")
Exit(255) Exit(255)
methods.generate_version_header(env.module_version_string) methods.generate_version_header(env.module_version_string)
env["PROGSUFFIX_WRAP"] = suffix + env.module_version_string + ".console" + env["PROGSUFFIX"] env["PROGSUFFIX_WRAP"] = suffix + env.module_version_string + ".console" + env["PROGSUFFIX"]
env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"] env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"]
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
# (SH)LIBSUFFIX will be used for our own built libraries # (SH)LIBSUFFIX will be used for our own built libraries
# LIBSUFFIXES contains LIBSUFFIX and SHLIBSUFFIX by default, # LIBSUFFIXES contains LIBSUFFIX and SHLIBSUFFIX by default,
# so we need to append the default suffixes to keep the ability # so we need to append the default suffixes to keep the ability
# to link against thirdparty libraries (.a, .so, .lib, etc.). # to link against thirdparty libraries (.a, .so, .lib, etc.).
if os.name == "nt": if os.name == "nt":
# On Windows, only static libraries and import libraries can be # On Windows, only static libraries and import libraries can be
# statically linked - both using .lib extension # statically linked - both using .lib extension
env["LIBSUFFIXES"] += [env["LIBSUFFIX"]] env["LIBSUFFIXES"] += [env["LIBSUFFIX"]]
else: else:
env["LIBSUFFIXES"] += [env["LIBSUFFIX"], env["SHLIBSUFFIX"]] env["LIBSUFFIXES"] += [env["LIBSUFFIX"], env["SHLIBSUFFIX"]]
env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"] env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"]
env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"] env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"]
env["OBJPREFIX"] = env["object_prefix"] env["OBJPREFIX"] = env["object_prefix"]
env["SHOBJPREFIX"] = env["object_prefix"] env["SHOBJPREFIX"] = env["object_prefix"]
if env["disable_3d"]: if env["disable_3d"]:
if env.editor_build: if env.editor_build:
print("Build option 'disable_3d=yes' cannot be used for editor builds, only for export template builds.") print("Build option 'disable_3d=yes' cannot be used for editor builds, only for export template builds.")
Exit(255) Exit(255)
else: else:
env.Append(CPPDEFINES=["_3D_DISABLED"]) env.Append(CPPDEFINES=["_3D_DISABLED"])
if env["disable_advanced_gui"]: if env["disable_advanced_gui"]:
if env.editor_build: if env.editor_build:
print( print(
"Build option 'disable_advanced_gui=yes' cannot be used for editor builds, " "Build option 'disable_advanced_gui=yes' cannot be used for editor builds, "
@ -921,15 +925,15 @@ if selected_platform in platform_list:
Exit(255) Exit(255)
else: else:
env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"]) env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"])
if env["minizip"]: if env["minizip"]:
env.Append(CPPDEFINES=["MINIZIP_ENABLED"]) env.Append(CPPDEFINES=["MINIZIP_ENABLED"])
if env["brotli"]: if env["brotli"]:
env.Append(CPPDEFINES=["BROTLI_ENABLED"]) env.Append(CPPDEFINES=["BROTLI_ENABLED"])
if not env["verbose"]: if not env["verbose"]:
methods.no_verbose(sys, env) methods.no_verbose(sys, env)
GLSL_BUILDERS = { GLSL_BUILDERS = {
"RD_GLSL": env.Builder( "RD_GLSL": env.Builder(
action=env.Run(glsl_builders.build_rd_headers), action=env.Run(glsl_builders.build_rd_headers),
suffix="glsl.gen.h", suffix="glsl.gen.h",
@ -945,32 +949,32 @@ if selected_platform in platform_list:
suffix="glsl.gen.h", suffix="glsl.gen.h",
src_suffix=".glsl", src_suffix=".glsl",
), ),
} }
env.Append(BUILDERS=GLSL_BUILDERS) env.Append(BUILDERS=GLSL_BUILDERS)
scons_cache_path = os.environ.get("SCONS_CACHE") scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path != None: if scons_cache_path != None:
CacheDir(scons_cache_path) CacheDir(scons_cache_path)
print("Scons cache enabled... (path: '" + scons_cache_path + "')") print("Scons cache enabled... (path: '" + scons_cache_path + "')")
if env["vsproj"]: if env["vsproj"]:
env.vs_incs = [] env.vs_incs = []
env.vs_srcs = [] env.vs_srcs = []
# CompileDB and Ninja are only available with certain SCons versions which # CompileDB and Ninja are only available with certain SCons versions which
# not everybody might have yet, so we have to check. # not everybody might have yet, so we have to check.
from SCons import __version__ as scons_raw_version from SCons import __version__ as scons_raw_version
scons_ver = env._get_major_minor_revision(scons_raw_version) scons_ver = env._get_major_minor_revision(scons_raw_version)
if env["compiledb"] and scons_ver < (4, 0, 0): if env["compiledb"] and scons_ver < (4, 0, 0):
# Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later. # Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later.
print("The `compiledb=yes` option requires SCons 4.0 or later, but your version is %s." % scons_raw_version) print("The `compiledb=yes` option requires SCons 4.0 or later, but your version is %s." % scons_raw_version)
Exit(255) Exit(255)
if scons_ver >= (4, 0, 0): if scons_ver >= (4, 0, 0):
env.Tool("compilation_db") env.Tool("compilation_db")
env.Alias("compiledb", env.CompilationDatabase()) env.Alias("compiledb", env.CompilationDatabase())
if env["ninja"]: if env["ninja"]:
if scons_ver < (4, 2, 0): if scons_ver < (4, 2, 0):
print("The `ninja=yes` option requires SCons 4.2 or later, but your version is %s." % scons_raw_version) print("The `ninja=yes` option requires SCons 4.2 or later, but your version is %s." % scons_raw_version)
Exit(255) Exit(255)
@ -984,67 +988,48 @@ if selected_platform in platform_list:
env.Tool("ninja") env.Tool("ninja")
# Threads # Threads
if env["threads"]: if env["threads"]:
env.Append(CPPDEFINES=["THREADS_ENABLED"]) env.Append(CPPDEFINES=["THREADS_ENABLED"])
# Build subdirs, the build order is dependent on link order. # Build subdirs, the build order is dependent on link order.
Export("env") Export("env")
SConscript("core/SCsub") SConscript("core/SCsub")
SConscript("servers/SCsub") SConscript("servers/SCsub")
SConscript("scene/SCsub") SConscript("scene/SCsub")
if env.editor_build: if env.editor_build:
SConscript("editor/SCsub") SConscript("editor/SCsub")
SConscript("drivers/SCsub") SConscript("drivers/SCsub")
SConscript("platform/SCsub") SConscript("platform/SCsub")
SConscript("modules/SCsub") SConscript("modules/SCsub")
if env["tests"]: if env["tests"]:
SConscript("tests/SCsub") SConscript("tests/SCsub")
SConscript("main/SCsub") SConscript("main/SCsub")
SConscript("platform/" + selected_platform + "/SCsub") # Build selected platform. SConscript("platform/" + selected_platform + "/SCsub") # Build selected platform.
# Microsoft Visual Studio Project Generation # Microsoft Visual Studio Project Generation
if env["vsproj"]: if env["vsproj"]:
env["CPPPATH"] = [Dir(path) for path in env["CPPPATH"]] env["CPPPATH"] = [Dir(path) for path in env["CPPPATH"]]
methods.generate_vs_project(env, ARGUMENTS, env["vsproj_name"]) methods.generate_vs_project(env, ARGUMENTS, env["vsproj_name"])
methods.generate_cpp_hint_file("cpp.hint") methods.generate_cpp_hint_file("cpp.hint")
# Check for the existence of headers # Check for the existence of headers
conf = Configure(env) conf = Configure(env)
if "check_c_headers" in env: if "check_c_headers" in env:
headers = env["check_c_headers"] headers = env["check_c_headers"]
for header in headers: for header in headers:
if conf.CheckCHeader(header): if conf.CheckCHeader(header):
env.AppendUnique(CPPDEFINES=[headers[header]]) env.AppendUnique(CPPDEFINES=[headers[header]])
elif selected_platform != "":
if selected_platform == "list":
print("The following platforms are available:\n")
else:
print('Invalid target platform "' + selected_platform + '".')
print("The following platforms were detected:\n")
for x in platform_list: # FIXME: This method mixes both cosmetic progress stuff and cache handling...
print("\t" + x) methods.show_progress(env)
# TODO: replace this with `env.Dump(format="json")`
print("\nPlease run SCons again and select a valid platform: platform=<string>") # once we start requiring SCons 4.0 as min version.
methods.dump(env)
if selected_platform == "list":
# Exit early to suppress the rest of the built-in SCons messages
Exit()
else:
Exit(255)
# The following only makes sense when the 'env' is defined, and assumes it is.
if "env" in locals():
# FIXME: This method mixes both cosmetic progress stuff and cache handling...
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)
def print_elapsed_time(): def print_elapsed_time():