| Index: pylib/gyp/generator/xcode.py
|
| diff --git a/pylib/gyp/generator/xcode.py b/pylib/gyp/generator/xcode.py
|
| index 0e3fb9301ecb9e6a6a4700ad063ae9742ab0181f..27ec1eeef620f6df7f1e6de3706f578fe868ec29 100644
|
| --- a/pylib/gyp/generator/xcode.py
|
| +++ b/pylib/gyp/generator/xcode.py
|
| @@ -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
|
| @@ -128,7 +130,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
|
|
|
| @@ -182,7 +184,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(
|
| @@ -196,7 +198,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(
|
| @@ -272,7 +274,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
|
| @@ -443,7 +445,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()
|
| @@ -453,7 +455,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
|
|
|
| @@ -472,10 +474,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:
|
| @@ -565,7 +567,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
|
| @@ -576,7 +578,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)
|
|
|
|
|
| @@ -624,7 +626,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
|
| @@ -736,7 +738,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
|
| @@ -1005,22 +1007,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:
|
| @@ -1036,8 +1037,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:
|
| @@ -1055,8 +1056,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:
|
| @@ -1277,7 +1277,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(
|
| @@ -1285,7 +1285,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)
|
|
|
|
|