Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: tools/bisect_utils.py

Issue 18991015: Unset some environment vars so they can be set up via the bisect script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/bisect_utils.py
diff --git a/tools/bisect_utils.py b/tools/bisect_utils.py
index 12d8c78c5f29eb4a5d2eba818aca44ac1ca4d7ca..ab0e889f10e62a80080c98d489533addb4d88282 100644
--- a/tools/bisect_utils.py
+++ b/tools/bisect_utils.py
@@ -41,6 +41,8 @@ REPO_PARAMS = [
REPO_SYNC_COMMAND = 'git checkout -f $(git rev-list --max-count=1 '\
'--before=%d remotes/m/master)'
+ORIGINAL_ENV = {}
+
def OutputAnnotationStepStart(name):
"""Outputs appropriate annotation to signal the start of a step to
a trybot.
@@ -283,6 +285,29 @@ def SetupCrosRepo():
return passed
+def CopyAndSaveOriginalEnvironmentVars():
+ """Makes a copy of the current environment variables."""
+ # TODO: Waiting on crbug.com/255689, will remove this after.
+ vars_to_remove = []
+ for k, v in os.environ.iteritems():
+ if 'ANDROID' in k:
+ vars_to_remove.append(k)
+ vars_to_remove.append('CHROME_SRC')
+ vars_to_remove.append('CHROMIUM_GYP_FILE')
+ vars_to_remove.append('GOMA_DIR')
+ vars_to_remove.append('GYP_CROSSCOMPILE')
+ vars_to_remove.append('GYP_DEFINES')
+ vars_to_remove.append('GYP_GENERATORS')
+ vars_to_remove.append('GYP_GENERATOR_FLAGS')
+ vars_to_remove.append('OBJCOPY')
+ for k in vars_to_remove:
+ if os.environ.has_key(k):
+ del os.environ[k]
+
+ global ORIGINAL_ENV
+ ORIGINAL_ENV = os.environ.copy()
+
+
def SetupAndroidBuildEnvironment(opts):
"""Sets up the android build environment.
@@ -293,6 +318,15 @@ def SetupAndroidBuildEnvironment(opts):
Returns:
True if successful.
"""
+
+ # Revert the environment variables back to default before setting them up
+ # with envsetup.sh.
+ env_vars = os.environ.copy()
+ for k, _ in env_vars.iteritems():
+ del os.environ[k]
+ for k, v in ORIGINAL_ENV.iteritems():
+ os.environ[k] = v
+
path_to_file = os.path.join('build', 'android', 'envsetup.sh')
proc = subprocess.Popen(['bash', '-c', 'source %s && env' % path_to_file],
stdout=subprocess.PIPE,
@@ -317,6 +351,7 @@ def SetupPlatformBuildEnvironment(opts):
True if successful.
"""
if opts.target_platform == 'android':
+ CopyAndSaveOriginalEnvironmentVars()
return SetupAndroidBuildEnvironment(opts)
elif opts.target_platform == 'cros':
return SetupCrosRepo()
« no previous file with comments | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698