Add build/ios/mac_build.gypi for building Mac components used by iOS build
The mac_build.gypi is used to build Mac targets via ninja. The template runs gyp_chromium to generate a ninja project file, then gyp target that includes the template should include an action to run ninja for the desired targets. BUG=None Review URL: https://chromiumcodereview.appspot.com/10826169 git-svn-id: http://src.chromium.org/svn/trunk/src/build@150357 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
b0492632b3
Коммит
5341ab9eac
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/python
|
||||
# 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.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def Main(argv):
|
||||
"""This is like 'env -i', but it uses a whitelist of env variables to allow
|
||||
through to the command being run. It attempts to strip off Xcode-added
|
||||
values from PATH.
|
||||
"""
|
||||
# Note: An attempt was made to do something like: env -i bash -lc '[command]'
|
||||
# but that fails to set the things set by login (USER, etc.), so instead
|
||||
# the only approach that seems to work is to have a whitelist.
|
||||
env_key_whitelist = (
|
||||
'HOME',
|
||||
'LOGNAME',
|
||||
# 'PATH' added below (but filtered).
|
||||
'PWD',
|
||||
'SHELL',
|
||||
'TEMP',
|
||||
'TMPDIR',
|
||||
'USER'
|
||||
)
|
||||
|
||||
# Need something to run.
|
||||
# TODO(lliabraa): Make this output a usage string and exit (here and below).
|
||||
assert(len(argv) > 0)
|
||||
|
||||
add_to_path = [];
|
||||
first_entry = argv[0];
|
||||
if first_entry.startswith('ADD_TO_PATH='):
|
||||
argv = argv[1:];
|
||||
add_to_path = first_entry.replace('ADD_TO_PATH=', '', 1).split(':')
|
||||
|
||||
# Still need something to run.
|
||||
assert(len(argv) > 0)
|
||||
|
||||
clean_env = {}
|
||||
|
||||
# Pull over the whitelisted keys.
|
||||
for key in env_key_whitelist:
|
||||
val = os.environ.get(key, None)
|
||||
if not val is None:
|
||||
clean_env[key] = val
|
||||
|
||||
# Collect the developer dir as set via Xcode, defaulting it.
|
||||
dev_prefix = os.environ.get('DEVELOPER_DIR', '/Developer/')
|
||||
if dev_prefix[-1:] != '/':
|
||||
dev_prefix += '/'
|
||||
|
||||
# Now pull in PATH, but remove anything Xcode might have added.
|
||||
initial_path = os.environ.get('PATH', '')
|
||||
filtered_chunks = \
|
||||
[x for x in initial_path.split(':') if not x.startswith(dev_prefix)]
|
||||
if filtered_chunks:
|
||||
clean_env['PATH'] = ':'.join(add_to_path + filtered_chunks)
|
||||
|
||||
# Add any KEY=VALUE args before the command to the cleaned environment.
|
||||
args = argv[:]
|
||||
while '=' in args[0]:
|
||||
(key, val) = args[0].split('=', 1)
|
||||
clean_env[key] = val
|
||||
args = args[1:]
|
||||
|
||||
# Still need something to run.
|
||||
assert(len(args) > 0)
|
||||
|
||||
# Off it goes...
|
||||
os.execvpe(args[0], args, clean_env)
|
||||
# Should never get here, so return a distinctive, non-zero status code.
|
||||
return 66
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(Main(sys.argv[1:]))
|
|
@ -0,0 +1,79 @@
|
|||
# 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.
|
||||
|
||||
# Xcode throws an error if an iOS target depends on a Mac OS X target. So
|
||||
# any place a utility program needs to be build and run, an action is
|
||||
# used to run ninja as script to work around this.
|
||||
# Example:
|
||||
# {
|
||||
# 'target_name': 'foo',
|
||||
# 'type': 'none',
|
||||
# 'variables': {
|
||||
# # The name of a directory used for ninja. This cannot be shared with
|
||||
# # another mac build.
|
||||
# 'ninja_output_dir': 'ninja-foo',
|
||||
# # The list of all the gyp files that contain the targets to run.
|
||||
# 're_run_targets': [
|
||||
# 'foo.gyp',
|
||||
# ],
|
||||
# },
|
||||
# 'includes': ['path_to/mac_build.gypi'],
|
||||
# 'actions': [
|
||||
# {
|
||||
# 'action_name': 'compile foo',
|
||||
# 'inputs': [],
|
||||
# 'outputs': [],
|
||||
# 'action': [
|
||||
# '<@(ninja_cmd)',
|
||||
# # All the targets to build.
|
||||
# 'foo1',
|
||||
# 'foo2',
|
||||
# ],
|
||||
# },
|
||||
# ],
|
||||
# }
|
||||
{
|
||||
'variables': {
|
||||
# Convenience variable pointing to the ninja product directory.
|
||||
'ninja_product_dir':
|
||||
'<(DEPTH)/xcodebuild/<(ninja_output_dir)/<(CONFIGURATION_NAME)',
|
||||
|
||||
# Common ninja command line flags.
|
||||
'ninja_cmd': [
|
||||
# Bounce through clean_env to clean up the environment so things
|
||||
# set by the iOS build don't pollute the Mac build.
|
||||
'<(DEPTH)/build/ios/clean_env.py',
|
||||
# ninja must be found in the PATH.
|
||||
'ADD_TO_PATH=<!(echo $PATH)',
|
||||
'ninja',
|
||||
'-C',
|
||||
'<(ninja_product_dir)',
|
||||
],
|
||||
|
||||
# Common syntax to rerun gyp to generate the Mac projects.
|
||||
're_run_gyp': [
|
||||
'build/gyp_chromium',
|
||||
# Don't use anything set for the iOS side of things.
|
||||
'--ignore-environment',
|
||||
# Generate for ninja
|
||||
'--format=ninja',
|
||||
# Generate files into xcodebuild/ninja
|
||||
'-Goutput_dir=xcodebuild/<(ninja_output_dir)',
|
||||
# nacl isn't in the iOS checkout, make sure it's turned off
|
||||
'-Ddisable_nacl=1',
|
||||
# Add a variable to handle specific cases for mac_build.
|
||||
'-Dios_mac_build=1',
|
||||
# Pass through the Mac SDK version.
|
||||
'-Dmac_sdk=<(mac_sdk)',
|
||||
],
|
||||
|
||||
# Rerun gyp for each of the projects needed. This is what actually
|
||||
# generates the projects on disk.
|
||||
're_run_gyp_execution':
|
||||
'<!(cd <(DEPTH) && <@(re_run_gyp) <@(re_run_targets))',
|
||||
},
|
||||
# Since these are used to generate things needed by other targets, make
|
||||
# them hard dependencies so they are always built first.
|
||||
'hard_dependency': 1,
|
||||
}
|
Загрузка…
Ссылка в новой задаче