diff --git a/SConstruct b/SConstruct index 117528de37c3..09f96a161f87 100644 --- a/SConstruct +++ b/SConstruct @@ -178,16 +178,7 @@ env.SConsignFile(File("#.sconsign{0}.dblite".format(pickle.HIGHEST_PROTOCOL)).ab # Build options -customs = ["custom.py"] - -profile = ARGUMENTS.get("profile", "") -if profile: - if os.path.isfile(profile): - customs.append(profile) - elif os.path.isfile(profile + ".py"): - customs.append(profile + ".py") - -opts = Variables(customs, ARGUMENTS) +opts = Variables(args=ARGUMENTS) # Target build options if env.scons_version >= (4, 3): @@ -209,6 +200,11 @@ opts.Add(BoolVariable("debug_paths_relative", "Make file paths in debug symbols opts.Add(EnumVariable("lto", "Link-time optimization (production builds)", "none", ("none", "auto", "thin", "full"))) opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False)) opts.Add(BoolVariable("threads", "Enable threading support", True)) +opts.Add( + "profile", + "Path to one or several comma-separated Python files with variable declarations to override default arguments", + "custom.py", +) # Components opts.Add(BoolVariable("deprecated", "Enable compatibility code for deprecated and removed features", True)) @@ -242,7 +238,7 @@ opts.Add("vsproj_name", "Name of the Visual Studio solution", "godot") opts.Add("import_env_vars", "A comma-separated list of environment variables to copy from the outer environment.", "") 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("build_profile", "Path to a file containing a feature build profile", "") +opts.Add("build_profile", "Path to a file containing a JSON feature build profile generated by Godot", "") opts.Add(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True)) opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", True)) opts.Add( @@ -305,6 +301,25 @@ opts.Add("rcflags", "Custom flags for Windows resource compiler") # in following code (especially platform and custom_modules). opts.Update(env) +# Process user profiles with custom arguments. +custom_profiles = env["profile"].split(",") +profiles_to_load = [] +custom_args = {} +for profile in custom_profiles: + if os.path.isfile(profile): + profiles_to_load.append(profile) + elif os.path.isfile(profile + ".py"): + profiles_to_load.append(profile + ".py") +if profiles_to_load: + for profile in profiles_to_load: + profile_args = {} + with open(profile, "r", encoding="utf-8") as f: + code = f.read() + exec(code, {}, profile_args) + custom_args = {**custom_args, **profile_args} + # Update the variables based on the profiles. + opts.Update(env, {**ARGUMENTS, **custom_args, **env}) + # Copy custom environment variables if set. if env["import_env_vars"]: for env_var in str(env["import_env_vars"]).split(","): @@ -374,6 +389,15 @@ if env["platform"] in platform_opts: for opt in platform_opts[env["platform"]]: opts.Add(opt) +# Platform-specific flags. +# These can sometimes override default options, so they need to be processed +# as early as possible to ensure that we're using the correct values. +flag_list = platform_flags[env["platform"]] +for key, value in flag_list.items(): + # Allow command line and profiles to override platform flags. + if (key not in ARGUMENTS or ARGUMENTS[key] == "auto") and key not in custom_args: + env[key] = value + # Update the environment to take platform-specific options into account. opts.Update(env, {**ARGUMENTS, **env.Dictionary()}) @@ -568,17 +592,8 @@ if env["build_profile"] != "": print_error('Failed to open feature build profile: "{}"'.format(env["build_profile"])) Exit(255) -# Platform specific flags. -# These can sometimes override default options. -flag_list = platform_flags[env["platform"]] -for key, value in flag_list.items(): - if key not in ARGUMENTS or ARGUMENTS[key] == "auto": # Allow command line to override platform flags - env[key] = value - # 'dev_mode' and 'production' are aliases to set default options if they haven't been # set manually by the user. -# 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). if env["dev_mode"]: env["verbose"] = methods.get_cmdline_bool("verbose", True) env["warnings"] = ARGUMENTS.get("warnings", "extra") diff --git a/platform/android/detect.py b/platform/android/detect.py index ed0ceb5862c0..0b182aca90ef 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -68,7 +68,7 @@ def get_min_target_api(): def get_flags(): return { - "arch": "arm64", # Default for convenience. + "arch": "arm64", "target": "template_debug", "supported": ["mono"], } diff --git a/platform/ios/detect.py b/platform/ios/detect.py index 35e1b9cd6d08..53b367a0a7f2 100644 --- a/platform/ios/detect.py +++ b/platform/ios/detect.py @@ -48,7 +48,7 @@ def get_doc_path(): def get_flags(): return { - "arch": "arm64", # Default for convenience. + "arch": "arm64", "target": "template_debug", "use_volk": False, "supported": ["mono"],