summaryrefslogtreecommitdiff
path: root/site_scons
diff options
context:
space:
mode:
authorRyan Egesdahl <ryan.egesdahl@mongodb.com>2020-06-26 11:01:56 -0700
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-06 04:15:02 +0000
commit873fac7144b8d98587bc7e41a708b3120a1cdd83 (patch)
treedb2a0d677e12664e3298ab9f65e7d39cd3ac6987 /site_scons
parentfa7f6842d53431ef679a587ba20b62cbe49d871c (diff)
downloadmongo-873fac7144b8d98587bc7e41a708b3120a1cdd83.tar.gz
SERVER-48885 Environment variables values with spaces can cause build failures
If any environment variable (including PATH) were to somehow make its way into your build.ninja, it would cause build failures due to the fact that the shell splits it into separate arguments. This can happen sometimes especially on OSX, where the PATHOSX environment variable gets (incorrectly) copied by SCons into the current build environment. Regardless of whatever SCons should be doing, we will quote environment variable values in Ninja builds to ensure it doesn't happen again. (cherry picked from commit c7348f391124e681d9c62aceb0e13e0d07fca8bc)
Diffstat (limited to 'site_scons')
-rw-r--r--site_scons/site_tools/ninja_next.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/site_scons/site_tools/ninja_next.py b/site_scons/site_tools/ninja_next.py
index 3d9c8dd1de5..6b1954397e0 100644
--- a/site_scons/site_tools/ninja_next.py
+++ b/site_scons/site_tools/ninja_next.py
@@ -866,7 +866,13 @@ def get_command_env(env):
if windows:
command_env += "set '{}={}' && ".format(key, value)
else:
- command_env += "{}={} ".format(key, value)
+ # We address here *only* the specific case that a user might have
+ # an environment variable which somehow gets included and has
+ # spaces in the value. These are escapes that Ninja handles. This
+ # doesn't make builds on paths with spaces (Ninja and SCons issues)
+ # nor expanding response file paths with spaces (Ninja issue) work.
+ value = value.replace(r' ', r'$ ')
+ command_env += "{}='{}' ".format(key, value)
env["NINJA_ENV_VAR_CACHE"] = command_env
return command_env