Skip to content

Commit

Permalink
tools: update gyp-next to v0.9.3
Browse files Browse the repository at this point in the history
PR-URL: #39291
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
gengjiawen authored and targos committed Jul 11, 2021
1 parent b168ec2 commit b56a3d9
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 38 deletions.
14 changes: 14 additions & 0 deletions tools/gyp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

### [0.9.3](https://www.github.com/nodejs/gyp-next/compare/v0.9.2...v0.9.3) (2021-07-07)


### Bug Fixes

* build failure with ninja and Python 3 on Windows ([#113](https://www.github.com/nodejs/gyp-next/issues/113)) ([c172d10](https://www.github.com/nodejs/gyp-next/commit/c172d105deff5db4244e583942215918fa80dd3c))

### [0.9.2](https://www.github.com/nodejs/gyp-next/compare/v0.9.1...v0.9.2) (2021-05-21)


### Bug Fixes

* add support of utf8 encoding ([#105](https://www.github.com/nodejs/gyp-next/issues/105)) ([4d0f93c](https://www.github.com/nodejs/gyp-next/commit/4d0f93c249286d1f0c0f665f5fe7346119f98cf1))

### [0.9.1](https://www.github.com/nodejs/gyp-next/compare/v0.9.0...v0.9.1) (2021-05-14)


Expand Down
2 changes: 1 addition & 1 deletion tools/gyp/pylib/gyp/MSVSUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _SuffixName(name, suffix):
Target name with suffix added (foo_suffix#target)
"""
parts = name.rsplit("#", 1)
parts[0] = "{}_{}".format(parts[0], suffix)
parts[0] = f"{parts[0]}_{suffix}"
return "#".join(parts)


Expand Down
2 changes: 1 addition & 1 deletion tools/gyp/pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def pop(self, last=True): # pylint: disable=W0221
def __repr__(self):
if not self:
return f"{self.__class__.__name__}()"
return "{}({!r})".format(self.__class__.__name__, list(self))
return f"{self.__class__.__name__}({list(self)!r})"

def __eq__(self, other):
if isinstance(other, OrderedSet):
Expand Down
11 changes: 8 additions & 3 deletions tools/gyp/pylib/gyp/easy_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys
import re
import os
import locale
Expand Down Expand Up @@ -84,7 +85,7 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0):
rest = specification[1:]
if rest and isinstance(rest[0], dict):
for at, val in sorted(rest[0].items()):
xml_parts.append(' {}="{}"'.format(at, _XmlEscape(val, attr=True)))
xml_parts.append(f' {at}="{_XmlEscape(val, attr=True)}"')
rest = rest[1:]
if rest:
xml_parts.append(">")
Expand All @@ -106,7 +107,8 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0):
xml_parts.append("/>%s" % new_line)


def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False, win32=False):
def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False,
win32=(sys.platform == "win32")):
""" Writes the XML content to disk, touching the file only if it has changed.
Args:
Expand All @@ -121,7 +123,10 @@ def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False, win32=False

default_encoding = locale.getdefaultlocale()[1]
if default_encoding and default_encoding.upper() != encoding.upper():
xml_string = xml_string.encode(encoding)
if win32 and sys.version_info < (3, 7):
xml_string = xml_string.decode("cp1251").encode(encoding)
else:
xml_string = xml_string.encode(encoding)

# Get the old content
try:
Expand Down
6 changes: 3 additions & 3 deletions tools/gyp/pylib/gyp/generator/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def WriteActions(self, actions, extra_sources, extra_outputs):
for output in outputs[1:]:
# Make each output depend on the main output, with an empty command
# to force make to notice that the mtime has changed.
self.WriteLn("{}: {} ;".format(self.LocalPathify(output), main_output))
self.WriteLn(f"{self.LocalPathify(output)}: {main_output} ;")

extra_outputs += outputs
self.WriteLn()
Expand Down Expand Up @@ -616,7 +616,7 @@ def WriteSources(self, spec, configs, extra_sources):
if IsCPPExtension(ext) and ext != local_cpp_extension:
local_file = root + local_cpp_extension
if local_file != source:
self.WriteLn("{}: {}".format(local_file, self.LocalPathify(source)))
self.WriteLn(f"{local_file}: {self.LocalPathify(source)}")
self.WriteLn("\tmkdir -p $(@D); cp $< $@")
origin_src_dirs.append(os.path.dirname(source))
final_generated_sources.append(local_file)
Expand Down Expand Up @@ -908,7 +908,7 @@ def WriteTarget(
if isinstance(v, list):
self.WriteList(v, k)
else:
self.WriteLn("{} := {}".format(k, make.QuoteIfNecessary(v)))
self.WriteLn(f"{k} := {make.QuoteIfNecessary(v)}")
self.WriteLn("")

# Add to the set of targets which represent the gyp 'all' target. We use the
Expand Down
2 changes: 1 addition & 1 deletion tools/gyp/pylib/gyp/generator/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ def WriteSortedXcodeEnv(self, target, env):
# export foo := a\ b
# it does not -- the backslash is written to the env as literal character.
# So don't escape spaces in |env[k]|.
self.WriteLn("{}: export {} := {}".format(QuoteSpaces(target), k, v))
self.WriteLn(f"{QuoteSpaces(target)}: export {k} := {v}")

def Objectify(self, path):
"""Convert a path to its output directory form."""
Expand Down
6 changes: 3 additions & 3 deletions tools/gyp/pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def _ConfigBaseName(config_name, platform_name):

def _ConfigFullName(config_name, config_data):
platform_name = _ConfigPlatform(config_data)
return "{}|{}".format(_ConfigBaseName(config_name, platform_name), platform_name)
return f"{_ConfigBaseName(config_name, platform_name)}|{platform_name}"


def _ConfigWindowsTargetPlatformVersion(config_data, version):
Expand All @@ -335,15 +335,15 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version):
# Find a matching entry in sdk_dir\include.
expected_sdk_dir = r"%s\include" % sdk_dir
names = sorted(
[
(
x
for x in (
os.listdir(expected_sdk_dir)
if os.path.isdir(expected_sdk_dir)
else []
)
if x.startswith(version)
],
),
reverse=True,
)
if names:
Expand Down
3 changes: 1 addition & 2 deletions tools/gyp/pylib/gyp/generator/ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def GenerateDescription(self, verb, message, fallback):
if self.toolset != "target":
verb += "(%s)" % self.toolset
if message:
return "{} {}".format(verb, self.ExpandSpecial(message))
return f"{verb} {self.ExpandSpecial(message)}"
else:
return f"{verb} {self.name}: {fallback}"

Expand Down Expand Up @@ -2389,7 +2389,6 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
)
if flavor == "win":
master_ninja.variable("ld_host", ld_host)
master_ninja.variable("ldxx_host", ldxx_host)
else:
master_ninja.variable(
"ld_host", CommandWithWrapper("LINK", wrappers, ld_host)
Expand Down
2 changes: 1 addition & 1 deletion tools/gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes, is_target, check
return data[build_file_path]

if os.path.exists(build_file_path):
build_file_contents = open(build_file_path).read()
build_file_contents = open(build_file_path, encoding='utf-8').read()
else:
raise GypError(f"{build_file_path} not found (cwd: {os.getcwd()})")

Expand Down
4 changes: 2 additions & 2 deletions tools/gyp/pylib/gyp/msvs_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def _TargetConfig(self, config):
# first level is globally for the configuration (this is what we consider
# "the" config at the gyp level, which will be something like 'Debug' or
# 'Release'), VS2015 and later only use this level
if self.vs_version.short_name >= 2015:
if int(self.vs_version.short_name) >= 2015:
return config
# and a second target-specific configuration, which is an
# override for the global one. |config| is remapped here to take into
Expand Down Expand Up @@ -537,7 +537,7 @@ def GetCflags(self, config):
)
]
)
if self.vs_version.project_version >= 12.0:
if float(self.vs_version.project_version) >= 12.0:
# New flag introduced in VS2013 (project version 12.0) Forces writes to
# the program database (PDB) to be serialized through MSPDBSRV.EXE.
# https://msdn.microsoft.com/en-us/library/dn502518.aspx
Expand Down
5 changes: 3 additions & 2 deletions tools/gyp/pylib/gyp/win_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,9 @@ def ExecLinkWithManifests(
# and sometimes doesn't unfortunately.
with open(our_manifest) as our_f:
with open(assert_manifest) as assert_f:
our_data = our_f.read().translate(None, string.whitespace)
assert_data = assert_f.read().translate(None, string.whitespace)
translator = str.maketrans('', '', string.whitespace)
our_data = our_f.read().translate(translator)
assert_data = assert_f.read().translate(translator)
if our_data != assert_data:
os.unlink(out)

Expand Down
8 changes: 4 additions & 4 deletions tools/gyp/pylib/gyp/xcodeproj_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ def __repr__(self):
try:
name = self.Name()
except NotImplementedError:
return "<{} at 0x{:x}>".format(self.__class__.__name__, id(self))
return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self))
return f"<{self.__class__.__name__} at 0x{id(self):x}>"
return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>"

def Copy(self):
"""Make a copy of this object.
Expand Down Expand Up @@ -2251,7 +2251,7 @@ class PBXContainerItemProxy(XCObject):
def __repr__(self):
props = self._properties
name = "{}.gyp:{}".format(props["containerPortal"].Name(), props["remoteInfo"])
return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self))
return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>"

def Name(self):
# Admittedly not the best name, but it's what Xcode uses.
Expand Down Expand Up @@ -2288,7 +2288,7 @@ class PBXTargetDependency(XCObject):

def __repr__(self):
name = self._properties.get("name") or self._properties["target"].Name()
return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self))
return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>"

def Name(self):
# Admittedly not the best name, but it's what Xcode uses.
Expand Down
2 changes: 1 addition & 1 deletion tools/gyp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name="gyp-next",
version="0.9.1",
version="0.9.3",
description="A fork of the GYP build system for use in the Node.js projects",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
21 changes: 7 additions & 14 deletions tools/gyp/test_gyp.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ def main(argv=None):
if not args.quiet:
runner.print_results()

if runner.failures:
return 1
else:
return 0
return 1 if runner.failures else 0


def print_configuration_info():
Expand All @@ -152,8 +149,8 @@ def print_configuration_info():
sys.path.append(os.path.abspath("test/lib"))
import TestMac

print(" Mac {} {}".format(platform.mac_ver()[0], platform.mac_ver()[2]))
print(" Xcode %s" % TestMac.Xcode.Version())
print(f" Mac {platform.mac_ver()[0]} {platform.mac_ver()[2]}")
print(f" Xcode {TestMac.Xcode.Version()}")
elif sys.platform == "win32":
sys.path.append(os.path.abspath("pylib"))
import gyp.MSVSVersion
Expand All @@ -162,8 +159,8 @@ def print_configuration_info():
print(" MSVS %s" % gyp.MSVSVersion.SelectVisualStudioVersion().Description())
elif sys.platform in ("linux", "linux2"):
print(" Linux %s" % " ".join(platform.linux_distribution()))
print(" Python %s" % platform.python_version())
print(" PYTHONPATH=%s" % os.environ["PYTHONPATH"])
print(f" Python {platform.python_version()}")
print(f" PYTHONPATH={os.environ['PYTHONPATH']}")
print()


Expand Down Expand Up @@ -222,13 +219,9 @@ def run_test(self, test, fmt, i):
res_msg = f" {res} {took:.3f}s"
self.print_(res_msg)

if (
stdout
and not stdout.endswith("PASSED\n")
and not (stdout.endswith("NO RESULT\n"))
):
if stdout and not stdout.endswith(("PASSED\n", "NO RESULT\n")):
print()
print("\n".join(" %s" % line for line in stdout.splitlines()))
print("\n".join(f" {line}" for line in stdout.splitlines()))
elif not self.isatty:
print()

Expand Down

0 comments on commit b56a3d9

Please sign in to comment.