Skip to content

Commit

Permalink
Fold long lines to max-line-length=88
Browse files Browse the repository at this point in the history
  • Loading branch information
iandrc authored and ryzokuken committed Jul 18, 2020
1 parent 6a0c86f commit 3e580fa
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max-complexity = 101
max-line-length = 180
max-line-length = 88
extend-ignore = E203 # whitespace before ':' to agree with psf/black
9 changes: 6 additions & 3 deletions pylib/gyp/MSVSSettings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ def testConvertToMSBuildSettings_warnings(self):
"MSBuild, index value (21) not in expected range [0, 3)",
"Warning: while converting VCCLCompilerTool/UsePrecompiledHeader to "
"MSBuild, index value (13) not in expected range [0, 3)",
"Warning: while converting VCCLCompilerTool/GeneratePreprocessedFile to "
"Warning: while converting "
"VCCLCompilerTool/GeneratePreprocessedFile to "
"MSBuild, value must be one of [0, 1, 2]; got 14",
"Warning: while converting VCLinkerTool/Driver to "
"MSBuild, index value (10) not in expected range [0, 4)",
Expand Down Expand Up @@ -1348,7 +1349,8 @@ def testConvertToMSBuildSettings_actual(self):
"EmbedManifest": "false",
"GenerateCatalogFiles": "true",
"InputResourceManifests": "asfsfdafs",
"ManifestResourceFile": "$(IntDir)\\$(TargetFileName).embed.manifest.resfdsf",
"ManifestResourceFile":
"$(IntDir)\\$(TargetFileName).embed.manifest.resfdsf",
"OutputManifestFile": "$(TargetPath).manifestdfs",
"RegistrarScriptFile": "sdfsfd",
"ReplacementsFile": "sdffsd",
Expand Down Expand Up @@ -1532,7 +1534,8 @@ def testConvertToMSBuildSettings_actual(self):
"LinkIncremental": "",
},
"ManifestResourceCompile": {
"ResourceOutputFileName": "$(IntDir)$(TargetFileName).embed.manifest.resfdsf"
"ResourceOutputFileName":
"$(IntDir)$(TargetFileName).embed.manifest.resfdsf"
},
}
self.maxDiff = 9999 # on failure display a long diff
Expand Down
24 changes: 15 additions & 9 deletions pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,14 @@ class Writer(object):
"""Wrapper around file which only covers the target if it differs."""

def __init__(self):
# On Cygwin remove the "dir" argument because `C:` prefixed paths are treated as relative,
# consequently ending up with current dir "/cygdrive/c/..." being prefixed to those, which was
# obviously a non-existent path, for example: "/cygdrive/c/<some folder>/C:\<my win style abs path>".
# See https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp for more details
# On Cygwin remove the "dir" argument
# `C:` prefixed paths are treated as relative,
# consequently ending up with current dir "/cygdrive/c/..."
# being prefixed to those, which was
# obviously a non-existent path,
# for example: "/cygdrive/c/<some folder>/C:\<my win style abs path>".
# For more details see:
# https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp
base_temp_dir = "" if IsCygwin() else os.path.dirname(filename)
# Pick temporary file.
tmp_fd, self.tmp_path = tempfile.mkstemp(
Expand Down Expand Up @@ -391,13 +395,15 @@ def close(self):
# one.
os.unlink(self.tmp_path)
else:
# The new file is different from the old one, or there is no old one.
# The new file is different from the old one,
# or there is no old one.
# Rename the new file to the permanent name.
#
# tempfile.mkstemp uses an overly restrictive mode, resulting in a
# file that can only be read by the owner, regardless of the umask.
# There's no reason to not respect the umask here, which means that
# an extra hoop is required to fetch it and reset the new file's mode.
# There's no reason to not respect the umask here,
# which means that an extra hoop is required
# to fetch it and reset the new file's mode.
#
# No way to get the umask without setting a new one? Set a safe one
# and then set it back to the old value.
Expand All @@ -406,8 +412,8 @@ def close(self):
os.chmod(self.tmp_path, 0o666 & ~umask)
if sys.platform == "win32" and os.path.exists(filename):
# NOTE: on windows (but not cygwin) rename will not replace an
# existing file, so it must be preceded with a remove. Sadly there
# is no way to make the switch atomic.
# existing file, so it must be preceded with a remove.
# Sadly there is no way to make the switch atomic.
os.remove(filename)
os.rename(self.tmp_path, filename)
except Exception:
Expand Down
26 changes: 14 additions & 12 deletions pylib/gyp/generator/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def CalculateGeneratorInputInfo(params):
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -o $@ -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
"""
""" # noqa: E501

LINK_COMMANDS_MAC = """\
quiet_cmd_alink = LIBTOOL-STATIC $@
Expand All @@ -191,7 +191,7 @@ def CalculateGeneratorInputInfo(params):
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
"""
""" # noqa: E501

LINK_COMMANDS_ANDROID = """\
quiet_cmd_alink = AR($(TOOLSET)) $@
Expand All @@ -218,7 +218,7 @@ def CalculateGeneratorInputInfo(params):
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
quiet_cmd_solink_module_host = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module_host = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
"""
""" # noqa: E501


LINK_COMMANDS_AIX = """\
Expand All @@ -236,7 +236,7 @@ def CalculateGeneratorInputInfo(params):
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
"""
""" # noqa: E501


LINK_COMMANDS_OS390 = """\
Expand All @@ -254,8 +254,7 @@ def CalculateGeneratorInputInfo(params):
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -Wl,DLL
"""
""" # noqa: E501


# Header of toplevel Makefile.
Expand Down Expand Up @@ -404,7 +403,7 @@ def CalculateGeneratorInputInfo(params):
cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp %(copy_archive_args)s "$<" "$@")
%(link_commands)s
"""
""" # noqa: E501
r"""
# Define an escape_quotes function to escape single quotes.
# This allows us to handle quotes properly as long as we always use
Expand Down Expand Up @@ -503,7 +502,7 @@ def CalculateGeneratorInputInfo(params):
.PHONY: FORCE_DO_CMD
FORCE_DO_CMD:
"""
""" # noqa: E501
)

SHARED_HEADER_MAC_COMMANDS = """
Expand Down Expand Up @@ -534,7 +533,7 @@ def CalculateGeneratorInputInfo(params):
quiet_cmd_infoplist = INFOPLIST $@
cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
"""
""" # noqa: E501


def WriteRootHeaderSuffixRules(writer):
Expand Down Expand Up @@ -1342,7 +1341,10 @@ def WriteSources(
)

if self.flavor == "mac":
cflags = self.xcode_settings.GetCflags(configname, arch=config.get('xcode_configuration_platform'))
cflags = self.xcode_settings.GetCflags(
configname,
arch=config.get('xcode_configuration_platform')
)
cflags_c = self.xcode_settings.GetCflagsC(configname)
cflags_cc = self.xcode_settings.GetCflagsCC(configname)
cflags_objc = self.xcode_settings.GetCflagsObjC(configname)
Expand Down Expand Up @@ -1659,8 +1661,8 @@ def WriteTarget(
ldflags = config.get("ldflags", [])
# Compute an rpath for this output if needed.
if any(dep.endswith(".so") or ".so." in dep for dep in deps):
# We want to get the literal string "$ORIGIN" into the link command,
# so we need lots of escaping.
# We want to get the literal string "$ORIGIN"
# into the link command, so we need lots of escaping.
ldflags.append(r"-Wl,-rpath=\$$ORIGIN/lib.%s/" % self.toolset)
ldflags.append(
r"-Wl,-rpath-link=\$(builddir)/lib.%s/" % self.toolset
Expand Down
14 changes: 8 additions & 6 deletions pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ def _FixPath(path):

def _IsWindowsAbsPath(path):
"""
On Cygwin systems Python needs a little help determining if a path is an absolute Windows path or not, so that
On Cygwin systems Python needs a little help determining if a path
is an absolute Windows path or not, so that
it does not treat those as relative, which results in bad paths like:
'..\\C:\\<some path>\\some_source_code_file.cc'
"""
Expand Down Expand Up @@ -753,7 +754,7 @@ def _EscapeEnvironmentVariableExpansion(s):
Returns:
The escaped string.
"""
""" # noqa: E731,E123,E501
s = s.replace("%", "%%")
return s

Expand Down Expand Up @@ -2374,8 +2375,8 @@ def _GenerateRulesForMSBuild(
):
# MSBuild rules are implemented using three files: an XML file, a .targets
# file and a .props file.
# See http://blogs.msdn.com/b/vcblog/archive/2010/04/21/quick-help-on-vs2010-custom-build-rule.aspx
# for more details.
# For more details see:
# https://devblogs.microsoft.com/cppblog/quick-help-on-vs2010-custom-build-rule/
rules = spec.get("rules", [])
rules_native = [r for r in rules if not int(r.get("msvs_external_rule", 0))]
rules_external = [r for r in rules if int(r.get("msvs_external_rule", 0))]
Expand Down Expand Up @@ -3623,8 +3624,9 @@ def _AddSources2(
if precompiled_source != "":
precompiled_source = _FixPath(precompiled_source)
if not extensions_excluded_from_precompile:
# If the precompiled header is generated by a C source, we must
# not try to use it for C++ sources, and vice versa.
# If the precompiled header is generated by a C source,
# we must not try to use it for C++ sources,
# and vice versa.
basename, extension = os.path.splitext(precompiled_source)
if extension == ".c":
extensions_excluded_from_precompile = [
Expand Down
32 changes: 18 additions & 14 deletions pylib/gyp/generator/ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,10 @@ def cygwin_munge(path):
rule.get("process_outputs_as_mac_bundle_resources", False)
):
extra_mac_bundle_resources += outputs
# Note: This is n_resources * n_outputs_in_rule. Put to-be-removed
# items in a set and remove them all in a single pass if this becomes
# a performance issue.
# Note: This is n_resources * n_outputs_in_rule.
# Put to-be-removed items in a set and
# remove them all in a single pass
# if this becomes a performance issue.
if was_mac_bundle_resource:
mac_bundle_resources.remove(source)

Expand Down Expand Up @@ -816,7 +817,7 @@ def cygwin_munge(path):

outputs = [self.GypPathToNinja(o, env) for o in outputs]
if self.flavor == "win":
# WriteNewNinjaRule uses unique_name for creating an rsp file on win.
# WriteNewNinjaRule uses unique_name to create a rsp file on win.
extra_bindings.append(
("unique_name", hashlib.md5(outputs[0]).hexdigest())
)
Expand Down Expand Up @@ -853,11 +854,12 @@ def WriteCopies(self, copies, prebuild, mac_bundle_depends):
outputs += self.ninja.build(dst, "copy", src, order_only=prebuild)
if self.is_mac_bundle:
# gyp has mac_bundle_resources to copy things into a bundle's
# Resources folder, but there's no built-in way to copy files to other
# places in the bundle. Hence, some targets use copies for this. Check
# if this file is copied into the current bundle, and if so add it to
# the bundle depends so that dependent targets get rebuilt if the copy
# input changes.
# Resources folder, but there's no built-in way to copy files
# to other places in the bundle.
# Hence, some targets use copies for this.
# Check if this file is copied into the current bundle,
# and if so add it to the bundle depends so
# that dependent targets get rebuilt if the copy input changes.
if dst.startswith(
self.xcode_settings.GetBundleContentsFolderPath()
):
Expand Down Expand Up @@ -1513,8 +1515,8 @@ def WriteLinkForArch(
if self.flavor != "win":
link_file_list = output
if self.is_mac_bundle:
# 'Dependency Framework.framework/Versions/A/Dependency Framework' ->
# 'Dependency Framework.framework.rsp'
# 'Dependency Framework.framework/Versions/A/Dependency Framework'
# -> 'Dependency Framework.framework.rsp'
link_file_list = self.xcode_settings.GetWrapperName()
if arch:
link_file_list += "." + arch
Expand Down Expand Up @@ -1628,7 +1630,8 @@ def WriteTarget(self, spec, config_name, config, link_deps, compile_deps):
variables=variables,
)
inputs.append(output)
# TODO: It's not clear if libtool_flags should be passed to the alink
# TODO: It's not clear if
# libtool_flags should be passed to the alink
# call that combines single-arch .a files into a fat .a file.
self.AppendPostbuildVariable(
variables, spec, self.target.binary, self.target.binary
Expand Down Expand Up @@ -2535,9 +2538,10 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
"solink",
description="SOLINK $lib",
restat=True,
command=mtime_preserving_solink_base % {"suffix": "@$link_file_list"},
command=mtime_preserving_solink_base % {"suffix": "@$link_file_list"}, # noqa: E501
rspfile="$link_file_list",
rspfile_content="-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs",
rspfile_content=("-Wl,--whole-archive $in $solibs -Wl,"
"--no-whole-archive $libs"),
pool="link_pool",
)
master_ninja.rule(
Expand Down
11 changes: 6 additions & 5 deletions pylib/gyp/generator/xcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,8 @@ def GenerateOutput(target_list, target_dicts, data, params):
"loadable_module+xcuitest": "com.apple.product-type.bundle.ui-testing",
"shared_library+bundle": "com.apple.product-type.framework",
"executable+extension+bundle": "com.apple.product-type.app-extension",
"executable+watch+extension+bundle": "com.apple.product-type.watchkit-extension",
"executable+watch+extension+bundle":
"com.apple.product-type.watchkit-extension",
"executable+watch+bundle": "com.apple.product-type.application.watchapp",
"mac_kernel_extension+bundle": "com.apple.product-type.kernel-extension",
}
Expand Down Expand Up @@ -1151,8 +1152,8 @@ def GenerateOutput(target_list, target_dicts, data, params):
'\t@mkdir -p "%s"\n' % '" "'.join(concrete_output_dirs)
)

# The rule message and action have already had the necessary variable
# substitutions performed.
# The rule message and action have already had
# the necessary variable substitutions performed.
if message:
# Mark it with note: so Xcode picks it up in build output.
makefile.write("\t@echo note: %s\n" % message)
Expand Down Expand Up @@ -1204,8 +1205,8 @@ def GenerateOutput(target_list, target_dicts, data, params):
support_xct.AppendProperty("buildPhases", ssbp)
else:
# TODO(mark): this assumes too much knowledge of the internals of
# xcodeproj_file; some of these smarts should move into xcodeproj_file
# itself.
# xcodeproj_file; some of these smarts should move
# into xcodeproj_file itself.
xct._properties["buildPhases"].insert(prebuild_index, ssbp)
prebuild_index = prebuild_index + 1

Expand Down
Loading

0 comments on commit 3e580fa

Please sign in to comment.