summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjustincohen@chromium.org <justincohen@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af>2014-05-06 16:21:14 +0000
committerjustincohen@chromium.org <justincohen@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af>2014-05-06 16:21:14 +0000
commit03c3c47fb42e87eb4cf6dcc71919f90107d688dd (patch)
tree0f2deeb27998be6d12631538bde68804e3f2f02e
parent11b270c9c7d5ff8728031a0229a853cfeb87c40d (diff)
downloadgyp-03c3c47fb42e87eb4cf6dcc71919f90107d688dd.tar.gz
Add xcode_ninja_target_pattern to xcode-ninja generator
Adds new GYP_GENERATOR_FLAG xcode_ninja_target_pattern. This customization allows for non-executable targets in the xcode_ninja wrapper. Also changes the name of xcode_ninja_target_filter to xcode_ninja_executable_target_pattern. xcode_ninja_executable_target_pattern (default all) - Restrict executable targets to this pattern, if set. xcode_ninja_target_pattern (default none) - Include extra targets, such as non-executable targets based on this pattern, if set. BUG=None TEST=None R=mark@chromium.org Review URL: https://codereview.chromium.org/234843005 git-svn-id: http://gyp.googlecode.com/svn/trunk@1914 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r--pylib/gyp/xcode_ninja.py47
1 files changed, 37 insertions, 10 deletions
diff --git a/pylib/gyp/xcode_ninja.py b/pylib/gyp/xcode_ninja.py
index c8867989..0e5a70c7 100644
--- a/pylib/gyp/xcode_ninja.py
+++ b/pylib/gyp/xcode_ninja.py
@@ -112,6 +112,32 @@ def _TargetFromSpec(old_spec, params):
ninja_target['actions'][0]['action'].extend(('-j', jobs))
return ninja_target
+def IsValidTargetForWrapper(target_extras, executable_target_pattern, spec):
+ """Limit targets for Xcode wrapper.
+
+ Xcode sometimes performs poorly with too many targets, so only include
+ proper executable targets, with filters to customize.
+ Arguments:
+ target_extras: Regular expression to always add, matching any target.
+ executable_target_pattern: Regular expression limiting executable targets.
+ spec: Specifications for target.
+ """
+ target_name = spec.get('target_name')
+ # Always include targets matching target_extras.
+ if target_extras is not None and re.search(target_extras, target_name):
+ return True
+
+ # Otherwise just show executable targets.
+ if spec.get('type', '') == 'executable' and \
+ spec.get('product_extension', '') != 'bundle':
+
+ # If there is a filter and the target does not match, exclude the target.
+ if executable_target_pattern is not None:
+ if not re.search(executable_target_pattern, target_name):
+ return False
+ return True
+ return False
+
def CreateWrapper(target_list, target_dicts, data, params):
"""Initialize targets for the ninja wrapper.
@@ -148,20 +174,21 @@ def CreateWrapper(target_list, target_dicts, data, params):
new_data[main_gyp]['xcode_settings'] = \
data[orig_gyp].get('xcode_settings', {})
+ # Normally the xcode-ninja generator includes only valid executable targets.
+ # If |xcode_ninja_executable_target_pattern| is set, that list is reduced to
+ # executable targets that match the pattern. (Default all)
+ executable_target_pattern = \
+ generator_flags.get('xcode_ninja_executable_target_pattern', None)
+
+ # For including other non-executable targets, add the matching target name
+ # to the |xcode_ninja_target_pattern| regular expression. (Default none)
+ target_extras = generator_flags.get('xcode_ninja_target_pattern', None)
+
for old_qualified_target in target_list:
spec = target_dicts[old_qualified_target]
- if spec.get('type', '') == 'executable' and \
- spec.get('product_extension', '') != 'bundle':
-
+ if IsValidTargetForWrapper(target_extras, executable_target_pattern, spec):
# Add to new_target_list.
target_name = spec.get('target_name')
-
- # Filter target names if requested.
- target_filter = generator_flags.get('xcode_ninja_target_filter', None)
- if target_filter is not None:
- if not re.search(target_filter, target_name):
- continue;
-
new_target_name = '%s:%s#target' % (main_gyp, target_name)
new_target_list.append(new_target_name)