summaryrefslogtreecommitdiffstats
path: root/build/gyp_helper.py
diff options
context:
space:
mode:
authoriannucci@chromium.org <iannucci@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 04:59:48 +0000
committeriannucci@chromium.org <iannucci@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 04:59:48 +0000
commitabab8d767641f0bebacdd8edfb5bc0a0dbb3647e (patch)
tree6ebaf65da3b214244a19c962bd0308e8f125350b /build/gyp_helper.py
parentcc1073afc7ebf6e28fc3cf0316ca0d783ed5809c (diff)
downloadchromium_src-abab8d767641f0bebacdd8edfb5bc0a0dbb3647e.zip
chromium_src-abab8d767641f0bebacdd8edfb5bc0a0dbb3647e.tar.gz
chromium_src-abab8d767641f0bebacdd8edfb5bc0a0dbb3647e.tar.bz2
Selective build clobbering feature (landmines.py and android build scripts).
Adds the ability for devs/troopers/etc. to set 'landmines' in the tree so that the build will selectively clobber when a builder moves over a revision with such a change. This cl has an basis landmines.py, and hooks the clobber mechanism to the android build scripts. The relevant cl which implements this for compile.py is here: https://chromiumcodereview.appspot.com/11234013/ I'm planning to also implement an informational invocation for gclient to let devs know about any potential landmines so they can decide if they need to clobber. This previously attempted to land as: https://chromiumcodereview.appspot.com/11175016 R=ilevy@chromium.org,maruel@chromium.org BUG=121897 Review URL: https://chromiumcodereview.appspot.com/11377141 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167595 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/gyp_helper.py')
-rw-r--r--build/gyp_helper.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/build/gyp_helper.py b/build/gyp_helper.py
new file mode 100644
index 0000000..69a341d
--- /dev/null
+++ b/build/gyp_helper.py
@@ -0,0 +1,50 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file helps gyp_chromium and landmines correctly set up the gyp
+# environment from chromium.gyp_env on disk
+
+import os
+
+SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
+CHROME_SRC = os.path.dirname(SCRIPT_DIR)
+
+
+def apply_gyp_environment_from_file(file_path):
+ """Reads in a *.gyp_env file and applies the valid keys to os.environ."""
+ if not os.path.exists(file_path):
+ return
+ with open(file_path) as f:
+ file_contents = f.read()
+ try:
+ file_data = eval(file_contents, {'__builtins__': None}, None)
+ except SyntaxError, e:
+ e.filename = os.path.abspath(file_path)
+ raise
+ supported_vars = (
+ 'CC',
+ 'CHROMIUM_GYP_FILE',
+ 'CHROMIUM_GYP_SYNTAX_CHECK',
+ 'CXX',
+ 'GYP_DEFINES',
+ 'GYP_GENERATOR_FLAGS',
+ 'GYP_GENERATOR_OUTPUT',
+ 'GYP_GENERATORS',
+ )
+ for var in supported_vars:
+ file_val = file_data.get(var)
+ if file_val:
+ if var in os.environ:
+ print 'INFO: Environment value for "%s" overrides value in %s.' % (
+ var, os.path.abspath(file_path)
+ )
+ else:
+ os.environ[var] = file_val
+
+
+def apply_chromium_gyp_env():
+ if 'SKIP_CHROMIUM_GYP_ENV' not in os.environ:
+ # Update the environment based on chromium.gyp_env
+ path = os.path.join(os.path.dirname(CHROME_SRC), 'chromium.gyp_env')
+ apply_gyp_environment_from_file(path)