summaryrefslogtreecommitdiffstats
path: root/tools/cr
diff options
context:
space:
mode:
authoriancottrell@chromium.org <iancottrell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-25 03:48:44 +0000
committeriancottrell@chromium.org <iancottrell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-25 03:48:44 +0000
commit827237bbd96c827040119460ec681549298e12ed (patch)
tree96cad6652e4678ab532bcf9f0c156bf297b7daa2 /tools/cr
parentb27e085cb6c5e5029528e7196f6aab0a51ed1225 (diff)
downloadchromium_src-827237bbd96c827040119460ec681549298e12ed.zip
chromium_src-827237bbd96c827040119460ec681549298e12ed.tar.gz
chromium_src-827237bbd96c827040119460ec681549298e12ed.tar.bz2
New style goma support, also magical gyp defines
BUG=353992 Review URL: https://codereview.chromium.org/204733005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/cr')
-rw-r--r--tools/cr/cr/actions/gyp.py12
-rw-r--r--tools/cr/cr/actions/ninja.py27
-rw-r--r--tools/cr/cr/base/android.py8
-rw-r--r--tools/cr/cr/base/host.py6
4 files changed, 38 insertions, 15 deletions
diff --git a/tools/cr/cr/actions/gyp.py b/tools/cr/cr/actions/gyp.py
index fc191e3..b50e893 100644
--- a/tools/cr/cr/actions/gyp.py
+++ b/tools/cr/cr/actions/gyp.py
@@ -5,7 +5,9 @@
"""A module to add gyp support to cr."""
import cr
+import os
+GYP_DEFINE_PREFIX = 'GYP_DEF_'
class GypPrepareOut(cr.PrepareOut):
"""A prepare action that runs gyp whenever you select an output directory."""
@@ -13,11 +15,21 @@ class GypPrepareOut(cr.PrepareOut):
ENABLED = cr.Config.From(
GYP_GENERATORS='ninja',
GYP_GENERATOR_FLAGS='output_dir={CR_OUT_BASE} config={CR_BUILDTYPE}',
+ GPP_DEF_target_arch='{CR_ENVSETUP_ARCH}',
)
def Prepare(self):
+ # Collapse GYP_DEFINES from all GYP_DEF prefixes
+ gyp_defines = cr.context.Find('GYP_DEFINES') or ''
+ for key, value in cr.context.exported.items():
+ if key.startswith(GYP_DEFINE_PREFIX):
+ gyp_defines += ' %s=%s' % (key[len(GYP_DEFINE_PREFIX):], value)
+ cr.context['GYP_DEFINES'] = gyp_defines.strip()
+
if cr.context.verbose >= 1:
print cr.context.Substitute('Invoking gyp with {GYP_GENERATOR_FLAGS}')
+ print cr.context.Substitute('GYP_DEFINES = {GYP_DEFINES}')
+
cr.Host.Execute(
'{CR_SRC}/build/gyp_chromium',
'--depth={CR_SRC}',
diff --git a/tools/cr/cr/actions/ninja.py b/tools/cr/cr/actions/ninja.py
index dd324f3..4485834 100644
--- a/tools/cr/cr/actions/ninja.py
+++ b/tools/cr/cr/actions/ninja.py
@@ -18,14 +18,22 @@ class NinjaBuilder(cr.Builder):
# Some basic configuration installed if we are enabled.
ENABLED = cr.Config.From(
NINJA_BINARY=os.path.join('{DEPOT_TOOLS}', 'ninja'),
- NINJA_JOBS=200,
- NINJA_PROCESSORS=12,
+ NINJA_JOBS=10,
+ NINJA_PROCESSORS=4,
NINJA_BUILD_FILE=os.path.join('{CR_BUILD_DIR}', 'build.ninja'),
GOMA_DIR=os.path.join('{GOOGLE_CODE}', 'goma'),
# Don't rename to GOMA_* or Goma will complain: "unkown GOMA_ parameter".
- NINJA_GOMA_CTL=os.path.join('{GOMA_DIR}', 'goma_ctl.py'),
- NINJA_GOMA_CC=os.path.join('{GOMA_DIR}', 'gomacc'),
- NINJA_GOMA_LINE='cc = {NINJA_GOMA_CC} $',
+ NINJA_GOMA_LINE='cc = {CR_GOMA_CC} $',
+ )
+ # A config block only included if goma is detected.
+ GOMA = cr.Config.From(
+ CR_GOMA_CC=os.path.join('{GOMA_DIR}', 'gomacc'),
+ CR_GOMA_CTL=os.path.join('{GOMA_DIR}', 'goma_ctl.py'),
+ GOMA_DIR='{CR_GOMA_DIR}',
+ GYP_DEF_gomadir='{CR_GOMA_DIR}',
+ GYP_DEF_use_goma=1,
+ NINJA_JOBS=200,
+ NINJA_PROCESSORS=12,
)
# A placeholder for the system detected configuration
DETECTED = cr.Config('DETECTED')
@@ -42,7 +50,7 @@ class NinjaBuilder(cr.Builder):
if f.readline().rstrip('\n') == cr.context.Get('NINJA_GOMA_LINE'):
# Goma is active, so make sure it's started.
cr.Host.ExecuteSilently(
- '{NINJA_GOMA_CTL}',
+ '{CR_GOMA_CTL}',
'ensure_start'
)
except IOError:
@@ -97,3 +105,10 @@ class NinjaBuilder(cr.Builder):
ninja_binaries = cr.Host.SearchPath('ninja')
if ninja_binaries:
cls.DETECTED.Set(NINJA_BINARY=ninja_binaries[0])
+
+ goma_binaries = cr.Host.SearchPath('gomacc', [
+ '/usr/local/google/code/goma',
+ os.path.expanduser('~/goma')])
+ if goma_binaries:
+ cls.DETECTED.Set(CR_GOMA_DIR=os.path.dirname(goma_binaries[0]))
+ cls.DETECTED.AddChildren(cls.GOMA)
diff --git a/tools/cr/cr/base/android.py b/tools/cr/cr/base/android.py
index 582d21c..248e4d0 100644
--- a/tools/cr/cr/base/android.py
+++ b/tools/cr/cr/base/android.py
@@ -38,6 +38,7 @@ class AndroidPlatform(cr.Platform):
CR_ADB_GDB=os.path.join('{CR_SRC}', 'build', 'android', 'adb_gdb'),
CHROMIUM_OUT_DIR='{CR_OUT_BASE}',
CR_DEFAULT_TARGET='chrome_shell',
+ GYP_DEF_OS='android'
)
def __init__(self):
@@ -59,8 +60,6 @@ class AndroidPlatform(cr.Platform):
if not self._env_ready:
# See what the env would be without env setup
before = cr.context.exported
- before['GYP_DEFINES'] = before.get(
- 'GYP_DEFINES', '') + ' target_arch={CR_ENVSETUP_ARCH}'
# Run env setup and capture/parse its output
envsetup = 'source {CR_ENVSETUP}'
output = cr.Host.CaptureShell(envsetup + ' > /dev/null && env')
@@ -73,11 +72,6 @@ class AndroidPlatform(cr.Platform):
env_setup[key] = env_setup.ParseValue(value.strip())
if key == 'PATH':
self._env_paths = value.strip().split(os.path.pathsep)
- if key == 'GYP_DEFINES':
- # Make a version of GYP_DEFINES that is the combination of base
- # setting and envsetup, needs to override the overrides
- # Note: Forcing it into the top level scope - sledge-hammer
- cr.context[key] = value.strip() + ' ' + before.get(key, '')
items = env_setup.exported.items()
if not items:
# Because of the way envsetup is run, the exit code does not make it
diff --git a/tools/cr/cr/base/host.py b/tools/cr/cr/base/host.py
index 30ce785..f60b55b5 100644
--- a/tools/cr/cr/base/host.py
+++ b/tools/cr/cr/base/host.py
@@ -159,7 +159,7 @@ class Host(cr.Plugin, cr.Plugin.Type):
return result in ['y', 'yes']
@classmethod
- def SearchPath(cls, name):
+ def SearchPath(cls, name, paths=[]):
"""Searches the PATH for an executable.
Args:
@@ -170,7 +170,9 @@ class Host(cr.Plugin, cr.Plugin.Type):
result = []
extensions = ['']
extensions.extend(os.environ.get('PATHEXT', '').split(os.pathsep))
- for path in os.environ.get('PATH', '').split(os.pathsep):
+ paths = [cr.context.Substitute(path) for path in paths if path]
+ paths = paths + os.environ.get('PATH', '').split(os.pathsep)
+ for path in paths:
partial = os.path.join(path, name)
for extension in extensions:
filename = partial + extension