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"
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)
@ -334,6 +329,16 @@ if selected_platform == "javascript":
print('Platform "javascript" has been renamed to "web" in Godot 4. Building for 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.
# It should always be re-set after calling `opts.Update()` otherwise it uses the original input value.
env_base["platform"] = selected_platform
@ -480,7 +485,6 @@ if not env_base["deprecated"]:
if env_base["precision"] == "double":
env_base.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"])
if selected_platform in platform_list:
tmppath = "./platform/" + selected_platform
sys.path.insert(0, tmppath)
import detect
@ -1020,26 +1024,7 @@ if selected_platform in platform_list:
if conf.CheckCHeader(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:
print("\t" + x)
print("\nPlease run SCons again and select a valid platform: platform=<string>")
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")`