summaryrefslogtreecommitdiffstats
path: root/tools/bisect_utils.py
diff options
context:
space:
mode:
authorsimonhatch@chromium.org <simonhatch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 21:10:41 +0000
committersimonhatch@chromium.org <simonhatch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 21:10:41 +0000
commit5e3d73f9ad42985a6ca1279d2ee0e4a4093442c2 (patch)
treed33ba01374fe5e4a29e79c4adf671a4113bc3a94 /tools/bisect_utils.py
parent4383f4c3325bb1e11f6f230308ccd2adccff4621 (diff)
downloadchromium_src-5e3d73f9ad42985a6ca1279d2ee0e4a4093442c2.zip
chromium_src-5e3d73f9ad42985a6ca1279d2ee0e4a4093442c2.tar.gz
chromium_src-5e3d73f9ad42985a6ca1279d2ee0e4a4093442c2.tar.bz2
Unset some environment vars so they can be set up via the bisect script.
BUG= NOTRY=true Review URL: https://chromiumcodereview.appspot.com/18991015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211214 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/bisect_utils.py')
-rw-r--r--tools/bisect_utils.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/bisect_utils.py b/tools/bisect_utils.py
index 12d8c78..ab0e889 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()