Source release 15.0.0
This commit is contained in:
61
third_party/gyp/generator/xcode.py
vendored
61
third_party/gyp/generator/xcode.py
vendored
@@ -2,6 +2,8 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import filecmp
|
||||
import gyp.common
|
||||
import gyp.xcodeproj_file
|
||||
@@ -129,7 +131,7 @@ class XcodeProject(object):
|
||||
try:
|
||||
os.makedirs(self.path)
|
||||
self.created_dir = True
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
@@ -183,7 +185,7 @@ class XcodeProject(object):
|
||||
# the tree tree view for UI display.
|
||||
# Any values set globally are applied to all configurations, then any
|
||||
# per-configuration values are applied.
|
||||
for xck, xcv in self.build_file_dict.get('xcode_settings', {}).iteritems():
|
||||
for xck, xcv in self.build_file_dict.get('xcode_settings', {}).items():
|
||||
xccl.SetBuildSetting(xck, xcv)
|
||||
if 'xcode_config_file' in self.build_file_dict:
|
||||
config_ref = self.project.AddOrGetFileInRootGroup(
|
||||
@@ -197,7 +199,7 @@ class XcodeProject(object):
|
||||
if build_file_configuration_named:
|
||||
xcc = xccl.ConfigurationNamed(config_name)
|
||||
for xck, xcv in build_file_configuration_named.get('xcode_settings',
|
||||
{}).iteritems():
|
||||
{}).items():
|
||||
xcc.SetBuildSetting(xck, xcv)
|
||||
if 'xcode_config_file' in build_file_configuration_named:
|
||||
config_ref = self.project.AddOrGetFileInRootGroup(
|
||||
@@ -273,7 +275,7 @@ class XcodeProject(object):
|
||||
script = script + "\n".join(
|
||||
['export %s="%s"' %
|
||||
(key, gyp.xcodeproj_file.ConvertVariablesToShellSyntax(val))
|
||||
for (key, val) in command.get('environment').iteritems()]) + "\n"
|
||||
for (key, val) in command.get('environment').items()]) + "\n"
|
||||
|
||||
# Some test end up using sockets, files on disk, etc. and can get
|
||||
# confused if more then one test runs at a time. The generator
|
||||
@@ -444,7 +446,7 @@ sys.exit(subprocess.call(sys.argv[1:]))" """
|
||||
dir=self.path)
|
||||
|
||||
try:
|
||||
output_file = os.fdopen(output_fd, 'wb')
|
||||
output_file = os.fdopen(output_fd, 'w')
|
||||
|
||||
self.project_file.Print(output_file)
|
||||
output_file.close()
|
||||
@@ -454,7 +456,7 @@ sys.exit(subprocess.call(sys.argv[1:]))" """
|
||||
same = False
|
||||
try:
|
||||
same = filecmp.cmp(pbxproj_path, new_pbxproj_path, False)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
|
||||
@@ -473,10 +475,10 @@ sys.exit(subprocess.call(sys.argv[1:]))" """
|
||||
#
|
||||
# No way to get the umask without setting a new one? Set a safe one
|
||||
# and then set it back to the old value.
|
||||
umask = os.umask(077)
|
||||
umask = os.umask(0o77)
|
||||
os.umask(umask)
|
||||
|
||||
os.chmod(new_pbxproj_path, 0666 & ~umask)
|
||||
os.chmod(new_pbxproj_path, 0o666 & ~umask)
|
||||
os.rename(new_pbxproj_path, pbxproj_path)
|
||||
|
||||
except Exception:
|
||||
@@ -566,7 +568,7 @@ def EscapeXcodeDefine(s):
|
||||
def PerformBuild(data, configurations, params):
|
||||
options = params['options']
|
||||
|
||||
for build_file, build_file_dict in data.iteritems():
|
||||
for build_file, build_file_dict in data.items():
|
||||
(build_file_root, build_file_ext) = os.path.splitext(build_file)
|
||||
if build_file_ext != '.gyp':
|
||||
continue
|
||||
@@ -577,7 +579,7 @@ def PerformBuild(data, configurations, params):
|
||||
for config in configurations:
|
||||
arguments = ['xcodebuild', '-project', xcodeproj_path]
|
||||
arguments += ['-configuration', config]
|
||||
print "Building [%s]: %s" % (config, arguments)
|
||||
print("Building [%s]: %s" % (config, arguments))
|
||||
subprocess.check_call(arguments)
|
||||
|
||||
|
||||
@@ -625,7 +627,7 @@ def GenerateOutput(target_list, target_dicts, data, params):
|
||||
skip_excluded_files = \
|
||||
not generator_flags.get('xcode_list_excluded_files', True)
|
||||
xcode_projects = {}
|
||||
for build_file, build_file_dict in data.iteritems():
|
||||
for build_file, build_file_dict in data.items():
|
||||
(build_file_root, build_file_ext) = os.path.splitext(build_file)
|
||||
if build_file_ext != '.gyp':
|
||||
continue
|
||||
@@ -710,7 +712,7 @@ def GenerateOutput(target_list, target_dicts, data, params):
|
||||
type = spec['type']
|
||||
is_xctest = int(spec.get('mac_xctest_bundle', 0))
|
||||
is_xcuitest = int(spec.get('mac_xcuitest_bundle', 0))
|
||||
is_bundle = int(spec.get('mac_bundle', 0)) or is_xctest
|
||||
is_bundle = int(spec.get('mac_bundle', 0)) or is_xctest or is_xcuitest
|
||||
is_app_extension = int(spec.get('ios_app_extension', 0))
|
||||
is_watchkit_extension = int(spec.get('ios_watchkit_extension', 0))
|
||||
is_watch_app = int(spec.get('ios_watch_app', 0))
|
||||
@@ -744,7 +746,7 @@ def GenerateOutput(target_list, target_dicts, data, params):
|
||||
xctarget_type = gyp.xcodeproj_file.PBXNativeTarget
|
||||
try:
|
||||
target_properties['productType'] = _types[type_bundle_key]
|
||||
except KeyError, e:
|
||||
except KeyError as e:
|
||||
gyp.common.ExceptionAppend(e, "-- unknown product type while "
|
||||
"writing target %s" % target_name)
|
||||
raise
|
||||
@@ -1016,22 +1018,21 @@ def GenerateOutput(target_list, target_dicts, data, params):
|
||||
makefile_name)
|
||||
# TODO(mark): try/close? Write to a temporary file and swap it only
|
||||
# if it's got changes?
|
||||
makefile = open(makefile_path, 'wb')
|
||||
makefile = open(makefile_path, 'w')
|
||||
|
||||
# make will build the first target in the makefile by default. By
|
||||
# convention, it's called "all". List all (or at least one)
|
||||
# concrete output for each rule source as a prerequisite of the "all"
|
||||
# target.
|
||||
makefile.write('all: \\\n')
|
||||
for concrete_output_index in \
|
||||
xrange(0, len(concrete_outputs_by_rule_source)):
|
||||
for concrete_output_index, concrete_output_by_rule_source in \
|
||||
enumerate(concrete_outputs_by_rule_source):
|
||||
# Only list the first (index [0]) concrete output of each input
|
||||
# in the "all" target. Otherwise, a parallel make (-j > 1) would
|
||||
# attempt to process each input multiple times simultaneously.
|
||||
# Otherwise, "all" could just contain the entire list of
|
||||
# concrete_outputs_all.
|
||||
concrete_output = \
|
||||
concrete_outputs_by_rule_source[concrete_output_index][0]
|
||||
concrete_output = concrete_output_by_rule_source[0]
|
||||
if concrete_output_index == len(concrete_outputs_by_rule_source) - 1:
|
||||
eol = ''
|
||||
else:
|
||||
@@ -1047,8 +1048,8 @@ def GenerateOutput(target_list, target_dicts, data, params):
|
||||
# rule source. Collect the names of the directories that are
|
||||
# required.
|
||||
concrete_output_dirs = []
|
||||
for concrete_output_index in xrange(0, len(concrete_outputs)):
|
||||
concrete_output = concrete_outputs[concrete_output_index]
|
||||
for concrete_output_index, concrete_output in \
|
||||
enumerate(concrete_outputs):
|
||||
if concrete_output_index == 0:
|
||||
bol = ''
|
||||
else:
|
||||
@@ -1066,8 +1067,7 @@ def GenerateOutput(target_list, target_dicts, data, params):
|
||||
# the set of additional rule inputs, if any.
|
||||
prerequisites = [rule_source]
|
||||
prerequisites.extend(rule.get('inputs', []))
|
||||
for prerequisite_index in xrange(0, len(prerequisites)):
|
||||
prerequisite = prerequisites[prerequisite_index]
|
||||
for prerequisite_index, prerequisite in enumerate(prerequisites):
|
||||
if prerequisite_index == len(prerequisites) - 1:
|
||||
eol = ''
|
||||
else:
|
||||
@@ -1094,17 +1094,6 @@ def GenerateOutput(target_list, target_dicts, data, params):
|
||||
# work if there ever was a concrete output that had an input-dependent
|
||||
# variable anywhere other than in the leaf position.
|
||||
|
||||
# Don't declare any inputPaths or outputPaths. If they're present,
|
||||
# Xcode will provide a slight optimization by only running the script
|
||||
# phase if any output is missing or outdated relative to any input.
|
||||
# Unfortunately, it will also assume that all outputs are touched by
|
||||
# the script, and if the outputs serve as files in a compilation
|
||||
# phase, they will be unconditionally rebuilt. Since make might not
|
||||
# rebuild everything that could be declared here as an output, this
|
||||
# extra compilation activity is unnecessary. With inputPaths and
|
||||
# outputPaths not supplied, make will always be called, but it knows
|
||||
# enough to not do anything when everything is up-to-date.
|
||||
|
||||
# To help speed things up, pass -j COUNT to make so it does some work
|
||||
# in parallel. Don't use ncpus because Xcode will build ncpus targets
|
||||
# in parallel and if each target happens to have a rules step, there
|
||||
@@ -1120,7 +1109,9 @@ exec xcrun make -f "${PROJECT_FILE_PATH}/%s" -j "${JOB_COUNT}"
|
||||
exit 1
|
||||
""" % makefile_name
|
||||
ssbp = gyp.xcodeproj_file.PBXShellScriptBuildPhase({
|
||||
'inputPaths': rule['rule_sources'],
|
||||
'name': 'Rule "' + rule['rule_name'] + '"',
|
||||
'outputPaths': concrete_outputs_all,
|
||||
'shellScript': script,
|
||||
'showEnvVarsInLog': 0,
|
||||
})
|
||||
@@ -1288,7 +1279,7 @@ exit 1
|
||||
set_define = EscapeXcodeDefine(define)
|
||||
xcbc.AppendBuildSetting('GCC_PREPROCESSOR_DEFINITIONS', set_define)
|
||||
if 'xcode_settings' in configuration:
|
||||
for xck, xcv in configuration['xcode_settings'].iteritems():
|
||||
for xck, xcv in configuration['xcode_settings'].items():
|
||||
xcbc.SetBuildSetting(xck, xcv)
|
||||
if 'xcode_config_file' in configuration:
|
||||
config_ref = pbxp.AddOrGetFileInRootGroup(
|
||||
@@ -1296,7 +1287,7 @@ exit 1
|
||||
xcbc.SetBaseConfiguration(config_ref)
|
||||
|
||||
build_files = []
|
||||
for build_file, build_file_dict in data.iteritems():
|
||||
for build_file, build_file_dict in data.items():
|
||||
if build_file.endswith('.gyp'):
|
||||
build_files.append(build_file)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user