Commit 5a278665 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

cr: Remove references to envsetup.sh, and to gyp.

Bug: 330631
Change-Id: I762d739912102b324677baf2be9db9c91a13b6ac
Reviewed-on: https://chromium-review.googlesource.com/579938Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488312}
parent a31ad588
# Copyright 2013 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.
"""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."""
ACTIVE = cr.Config.From(
GYP_GENERATORS='ninja',
GYP_GENERATOR_FLAGS='output_dir={CR_OUT_BASE} config={CR_BUILDTYPE}',
GYP_DEF_target_arch='{CR_ENVSETUP_ARCH}',
)
def UpdateContext(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('GYP_DEFINES = {GYP_DEFINES}')
def Prepare(self):
if cr.context.verbose >= 1:
print cr.context.Substitute('Invoking gyp with {GYP_GENERATOR_FLAGS}')
cr.Host.Execute(
'{CR_SRC}/build/gyp_chromium',
'--depth={CR_SRC}',
'--check'
)
......@@ -35,8 +35,6 @@ class NinjaBuilder(cr.Builder):
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=multiprocessing.cpu_count() * 10,
)
# A placeholder for the system detected configuration
......
......@@ -9,22 +9,10 @@ import subprocess
import cr
# This is the set of environment variables that are not automatically
# copied back from the envsetup shell
_IGNORE_ENV = [
'SHLVL', # Because it's nothing to do with envsetup
'GYP_GENERATOR_FLAGS', # because we set them in they gyp handler
'GYP_GENERATORS', # because we set them in they gyp handler
'PATH', # Because it gets a special merge handler
'GYP_DEFINES', # Because it gets a special merge handler
]
class AndroidPlatform(cr.Platform):
"""The implementation of Platform for the android target."""
ACTIVE = cr.Config.From(
CR_ENVSETUP=os.path.join('{CR_SRC}', 'build', 'android', 'envsetup.sh'),
CR_ADB=os.path.join('{CR_SRC}', 'third_party', 'android_tools', 'sdk',
'platform-tools', 'adb'),
CR_TARGET_SUFFIX='_apk',
......@@ -38,7 +26,6 @@ class AndroidPlatform(cr.Platform):
'{CR_SRC}', 'build', 'android', 'test_runner.py'),
CR_ADB_GDB=os.path.join('{CR_SRC}', 'build', 'android', 'adb_gdb'),
CR_DEFAULT_TARGET='chrome_public',
GYP_DEF_OS='android',
GN_ARG_target_os='"android"'
)
......@@ -46,51 +33,14 @@ class AndroidPlatform(cr.Platform):
super(AndroidPlatform, self).__init__()
self._env = cr.Config('android-env', literal=True, export=True)
self.detected_config.AddChild(self._env)
self._env_ready = False
self._env_paths = []
@property
def priority(self):
return super(AndroidPlatform, self).priority + 1
def Prepare(self):
"""Override Prepare from cr.Platform."""
super(AndroidPlatform, self).Prepare()
try:
# capture the result of env setup if we have not already done so
if not self._env_ready:
# See what the env would be without env setup
before = cr.context.exported
# Run env setup and capture/parse its output
envsetup = 'source {CR_ENVSETUP}'
output = cr.Host.CaptureShell(envsetup + ' > /dev/null && env')
env_setup = cr.Config('envsetup', literal=True, export=True)
for line in output.split('\n'):
(key, op, value) = line.partition('=')
if op:
key = key.strip()
if key not in _IGNORE_ENV:
env_setup[key] = env_setup.ParseValue(value.strip())
if key == 'PATH':
self._env_paths = value.strip().split(os.path.pathsep)
items = env_setup.exported.items()
if not items:
# Because of the way envsetup is run, the exit code does not make it
# back to us. Instead, we assume if we got no environment at all, it
# must have failed.
print 'Envsetup failed!'
exit(1)
# Find all the things that envsetup changed
for key, value in env_setup.exported.items():
if str(value) != str(before.get(key, None)):
self._env[key] = value
self._env_ready = True
except subprocess.CalledProcessError, e:
exit(e.returncode)
@property
def paths(self):
return self._env_paths
return []
class AndroidInitHook(cr.InitHook):
......
......@@ -14,7 +14,6 @@ class LinuxChromeOSPlatform(cr.Platform):
ACTIVE = cr.Config.From(
CR_BINARY=os.path.join('{CR_BUILD_DIR}', '{CR_BUILD_TARGET}'),
CHROME_DEVEL_SANDBOX='/usr/local/sbin/chrome-devel-sandbox',
GYP_DEF_chromeos=1,
GN_ARG_target_os='"chromeos"',
)
......
......@@ -23,7 +23,7 @@ class PrepareCommand(cr.Command):
self.help = 'Prepares an output directory'
self.description = ("""
This does any preparation needed for the output directory, such as
running gyp.
running gn.
""")
def Run(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment