Browse Source

Merge pull request #70770 from vnen/scons-clone-env-vars

Add option in SCons to clone env variables
Yuri Sizov 1 year ago
parent
commit
e7a1eae4e6
1 changed files with 7 additions and 0 deletions
  1. 7 0
      SConstruct

+ 7 - 0
SConstruct

@@ -212,6 +212,7 @@ opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all
 opts.Add("object_prefix", "Custom prefix added to the base filename of all generated object files", "")
 opts.Add("object_prefix", "Custom prefix added to the base filename of all generated object files", "")
 opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False))
 opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False))
 opts.Add("vsproj_name", "Name of the Visual Studio solution", "godot")
 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_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("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 feature build profile", "")
@@ -270,6 +271,12 @@ opts.Add("LINKFLAGS", "Custom flags for the linker")
 # in following code (especially platform and custom_modules).
 # in following code (especially platform and custom_modules).
 opts.Update(env_base)
 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.
 # Platform selection: validate input, and add options.
 
 
 selected_platform = ""
 selected_platform = ""