Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: pylib/gyp/generator/make.py

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pylib/gyp/generator/make.py
diff --git a/pylib/gyp/generator/make.py b/pylib/gyp/generator/make.py
index b7da768fb33f5a8e12ec6ffa4c20e2fc6c1434e8..5fd22c57c91c1bf4894b603354c92602f40ef584 100644
--- a/pylib/gyp/generator/make.py
+++ b/pylib/gyp/generator/make.py
@@ -21,6 +21,8 @@
# toplevel Makefile. It may make sense to generate some .mk files on
# the side to keep the the files readable.
+from __future__ import print_function
+
import os
import re
import sys
@@ -645,7 +647,7 @@ def _ValidateSourcesForOSX(spec, all_sources):
basenames.setdefault(basename, []).append(source)
error = ''
- for basename, files in basenames.iteritems():
+ for basename, files in basenames.items():
if len(files) > 1:
error += ' %s: %s\n' % (basename, ' '.join(files))
@@ -793,7 +795,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
gyp.xcode_emulation.MacPrefixHeader(
self.xcode_settings, lambda p: Sourceify(self.Absolutify(p)),
self.Pchify))
- sources = filter(Compilable, all_sources)
+ sources = [x for x in all_sources if Compilable(x)]
if sources:
self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT1)
extensions = set([os.path.splitext(s)[1] for s in sources])
@@ -922,7 +924,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
'%s%s'
% (name, cd_action, command))
self.WriteLn()
- outputs = map(self.Absolutify, outputs)
+ outputs = [self.Absolutify(o) for o in outputs]
# The makefile rules are all relative to the top dir, but the gyp actions
# are defined relative to their containing dir. This replaces the obj
# variable for the action rule with an absolute version so that the output
@@ -1012,7 +1014,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
outputs = [gyp.xcode_emulation.ExpandEnvVars(o, env) for o in outputs]
inputs = [gyp.xcode_emulation.ExpandEnvVars(i, env) for i in inputs]
- outputs = map(self.Absolutify, outputs)
+ outputs = [self.Absolutify(o) for o in outputs]
all_outputs += outputs
# Only write the 'obj' and 'builddir' rules for the "primary" output
# (:1); it's superfluous for the "extra outputs", and this avoids
@@ -1210,11 +1212,11 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
self.WriteList(cflags_objcc, 'CFLAGS_OBJCC_%s' % configname)
includes = config.get('include_dirs')
if includes:
- includes = map(Sourceify, map(self.Absolutify, includes))
+ includes = [Sourceify(self.Absolutify(include)) for include in includes]
self.WriteList(includes, 'INCS_%s' % configname, prefix='-I')
compilable = filter(Compilable, sources)
- objs = map(self.Objectify, map(self.Absolutify, map(Target, compilable)))
+ objs = [self.Objectify(self.Absolutify(Target(x))) for x in compilable]
self.WriteList(objs, 'OBJS')
for obj in objs:
@@ -1286,7 +1288,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
# If there are any object files in our input file list, link them into our
# output.
- extra_link_deps += filter(Linkable, sources)
+ extra_link_deps += [source for source in sources if Linkable(source)]
self.WriteLn()
@@ -1351,8 +1353,8 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
elif self.type == 'none':
target = '%s.stamp' % target
elif self.type != 'executable':
- print ("ERROR: What output file should be generated?",
- "type", self.type, "target", target)
+ print(("ERROR: What output file should be generated?",
+ "type", self.type, "target", target))
target_prefix = spec.get('product_prefix', target_prefix)
target = spec.get('product_name', target)
@@ -1516,9 +1518,9 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
# Postbuilds expect to be run in the gyp file's directory, so insert an
# implicit postbuild to cd to there.
postbuilds.insert(0, gyp.common.EncodePOSIXShellList(['cd', self.path]))
- for i in xrange(len(postbuilds)):
- if not postbuilds[i].startswith('$'):
- postbuilds[i] = EscapeShellArgument(postbuilds[i])
+ for i, postbuild in enumerate(postbuilds):
+ if not postbuild.startswith('$'):
+ postbuilds[i] = EscapeShellArgument(postbuild)
self.WriteLn('%s: builddir := $(abs_builddir)' % QuoteSpaces(self.output))
self.WriteLn('%s: POSTBUILDS := %s' % (
QuoteSpaces(self.output), ' '.join(postbuilds)))
@@ -1608,7 +1610,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
self.WriteDoCmd([self.output_binary], deps, 'touch', part_of_all,
postbuilds=postbuilds)
else:
- print "WARNING: no output for", self.type, target
+ print("WARNING: no output for", self.type, target)
# Add an alias for each target (if there are any outputs).
# Installable target aliases are created below.
@@ -1715,7 +1717,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
output is just a name to run the rule
command: (optional) command name to generate unambiguous labels
"""
- outputs = map(QuoteSpaces, outputs)
+ outputs = [QuoteSpaces(o) for o in outputs]
inputs = map(QuoteSpaces, inputs)
if comment:
@@ -1957,7 +1959,7 @@ def PerformBuild(data, configurations, params):
if options.toplevel_dir and options.toplevel_dir != '.':
arguments += '-C', options.toplevel_dir
arguments.append('BUILDTYPE=' + config)
- print 'Building [%s]: %s' % (config, arguments)
+ print('Building [%s]: %s' % (config, arguments))
subprocess.check_call(arguments)

Powered by Google App Engine
This is Rietveld 408576698