Backport SCons environment variable import option
authorTravis Wrightsman <travis@wrightsman.org>
Wed, 11 Dec 2024 01:38:21 +0000 (17:38 -0800)
committerOtto Kekäläinen <otto@debian.org>
Tue, 31 Dec 2024 05:13:41 +0000 (21:13 -0800)
Origin: backport: https://github.com/godotengine/godot/commit/ed52ac9b5df5bae8836b309f1d55f928ebc58481
Forwarded: non-needed
Applied-Upstream: 4.3

Gbp-Pq: Name Backport-SCons-environment-variable-import-option.patch

SConstruct

index d0ffcde3e35b735bb4693e831f6a3a27bace5922..7a16cd0bdf7b257e1201ea71f4de64455e85a7eb 100644 (file)
@@ -152,6 +152,7 @@ opts.Add(
         False,
     )
 )
+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(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True))
@@ -206,6 +207,12 @@ opts.Add("LINKFLAGS", "Custom flags for the linker")
 # in following code (especially platform and custom_modules).
 opts.Update(env_base)
 
+# Copy custom environment variables if set.
+if env_base["import_env_vars"]:
+    for env_var in str(env_base["import_env_vars"]).split(","):
+        if env_var in os.environ:
+            env_base["ENV"][env_var] = os.environ[env_var]
+
 # Platform selection: validate input, and add options.
 
 selected_platform = ""