Skip to content

Commit b56a3d9

Browse files
gengjiawentargos
authored andcommitted
tools: update gyp-next to v0.9.3
PR-URL: #39291 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent b168ec2 commit b56a3d9

14 files changed

+50
-38
lines changed

Diff for: tools/gyp/CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
### [0.9.3](https://www.github.com/nodejs/gyp-next/compare/v0.9.2...v0.9.3) (2021-07-07)
4+
5+
6+
### Bug Fixes
7+
8+
* 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))
9+
10+
### [0.9.2](https://www.github.com/nodejs/gyp-next/compare/v0.9.1...v0.9.2) (2021-05-21)
11+
12+
13+
### Bug Fixes
14+
15+
* 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))
16+
317
### [0.9.1](https://www.github.com/nodejs/gyp-next/compare/v0.9.0...v0.9.1) (2021-05-14)
418

519

Diff for: tools/gyp/pylib/gyp/MSVSUtil.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _SuffixName(name, suffix):
5555
Target name with suffix added (foo_suffix#target)
5656
"""
5757
parts = name.rsplit("#", 1)
58-
parts[0] = "{}_{}".format(parts[0], suffix)
58+
parts[0] = f"{parts[0]}_{suffix}"
5959
return "#".join(parts)
6060

6161

Diff for: tools/gyp/pylib/gyp/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def pop(self, last=True): # pylint: disable=W0221
562562
def __repr__(self):
563563
if not self:
564564
return f"{self.__class__.__name__}()"
565-
return "{}({!r})".format(self.__class__.__name__, list(self))
565+
return f"{self.__class__.__name__}({list(self)!r})"
566566

567567
def __eq__(self, other):
568568
if isinstance(other, OrderedSet):

Diff for: tools/gyp/pylib/gyp/easy_xml.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5+
import sys
56
import re
67
import os
78
import locale
@@ -84,7 +85,7 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0):
8485
rest = specification[1:]
8586
if rest and isinstance(rest[0], dict):
8687
for at, val in sorted(rest[0].items()):
87-
xml_parts.append(' {}="{}"'.format(at, _XmlEscape(val, attr=True)))
88+
xml_parts.append(f' {at}="{_XmlEscape(val, attr=True)}"')
8889
rest = rest[1:]
8990
if rest:
9091
xml_parts.append(">")
@@ -106,7 +107,8 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0):
106107
xml_parts.append("/>%s" % new_line)
107108

108109

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

122124
default_encoding = locale.getdefaultlocale()[1]
123125
if default_encoding and default_encoding.upper() != encoding.upper():
124-
xml_string = xml_string.encode(encoding)
126+
if win32 and sys.version_info < (3, 7):
127+
xml_string = xml_string.decode("cp1251").encode(encoding)
128+
else:
129+
xml_string = xml_string.encode(encoding)
125130

126131
# Get the old content
127132
try:

Diff for: tools/gyp/pylib/gyp/generator/android.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def WriteActions(self, actions, extra_sources, extra_outputs):
349349
for output in outputs[1:]:
350350
# Make each output depend on the main output, with an empty command
351351
# to force make to notice that the mtime has changed.
352-
self.WriteLn("{}: {} ;".format(self.LocalPathify(output), main_output))
352+
self.WriteLn(f"{self.LocalPathify(output)}: {main_output} ;")
353353

354354
extra_outputs += outputs
355355
self.WriteLn()
@@ -616,7 +616,7 @@ def WriteSources(self, spec, configs, extra_sources):
616616
if IsCPPExtension(ext) and ext != local_cpp_extension:
617617
local_file = root + local_cpp_extension
618618
if local_file != source:
619-
self.WriteLn("{}: {}".format(local_file, self.LocalPathify(source)))
619+
self.WriteLn(f"{local_file}: {self.LocalPathify(source)}")
620620
self.WriteLn("\tmkdir -p $(@D); cp $< $@")
621621
origin_src_dirs.append(os.path.dirname(source))
622622
final_generated_sources.append(local_file)
@@ -908,7 +908,7 @@ def WriteTarget(
908908
if isinstance(v, list):
909909
self.WriteList(v, k)
910910
else:
911-
self.WriteLn("{} := {}".format(k, make.QuoteIfNecessary(v)))
911+
self.WriteLn(f"{k} := {make.QuoteIfNecessary(v)}")
912912
self.WriteLn("")
913913

914914
# Add to the set of targets which represent the gyp 'all' target. We use the

Diff for: tools/gyp/pylib/gyp/generator/make.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ def WriteSortedXcodeEnv(self, target, env):
21332133
# export foo := a\ b
21342134
# it does not -- the backslash is written to the env as literal character.
21352135
# So don't escape spaces in |env[k]|.
2136-
self.WriteLn("{}: export {} := {}".format(QuoteSpaces(target), k, v))
2136+
self.WriteLn(f"{QuoteSpaces(target)}: export {k} := {v}")
21372137

21382138
def Objectify(self, path):
21392139
"""Convert a path to its output directory form."""

Diff for: tools/gyp/pylib/gyp/generator/msvs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def _ConfigBaseName(config_name, platform_name):
314314

315315
def _ConfigFullName(config_name, config_data):
316316
platform_name = _ConfigPlatform(config_data)
317-
return "{}|{}".format(_ConfigBaseName(config_name, platform_name), platform_name)
317+
return f"{_ConfigBaseName(config_name, platform_name)}|{platform_name}"
318318

319319

320320
def _ConfigWindowsTargetPlatformVersion(config_data, version):
@@ -335,15 +335,15 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version):
335335
# Find a matching entry in sdk_dir\include.
336336
expected_sdk_dir = r"%s\include" % sdk_dir
337337
names = sorted(
338-
[
338+
(
339339
x
340340
for x in (
341341
os.listdir(expected_sdk_dir)
342342
if os.path.isdir(expected_sdk_dir)
343343
else []
344344
)
345345
if x.startswith(version)
346-
],
346+
),
347347
reverse=True,
348348
)
349349
if names:

Diff for: tools/gyp/pylib/gyp/generator/ninja.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def GenerateDescription(self, verb, message, fallback):
638638
if self.toolset != "target":
639639
verb += "(%s)" % self.toolset
640640
if message:
641-
return "{} {}".format(verb, self.ExpandSpecial(message))
641+
return f"{verb} {self.ExpandSpecial(message)}"
642642
else:
643643
return f"{verb} {self.name}: {fallback}"
644644

@@ -2389,7 +2389,6 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
23892389
)
23902390
if flavor == "win":
23912391
master_ninja.variable("ld_host", ld_host)
2392-
master_ninja.variable("ldxx_host", ldxx_host)
23932392
else:
23942393
master_ninja.variable(
23952394
"ld_host", CommandWithWrapper("LINK", wrappers, ld_host)

Diff for: tools/gyp/pylib/gyp/input.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes, is_target, check
225225
return data[build_file_path]
226226

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

Diff for: tools/gyp/pylib/gyp/msvs_emulation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def _TargetConfig(self, config):
333333
# first level is globally for the configuration (this is what we consider
334334
# "the" config at the gyp level, which will be something like 'Debug' or
335335
# 'Release'), VS2015 and later only use this level
336-
if self.vs_version.short_name >= 2015:
336+
if int(self.vs_version.short_name) >= 2015:
337337
return config
338338
# and a second target-specific configuration, which is an
339339
# override for the global one. |config| is remapped here to take into
@@ -537,7 +537,7 @@ def GetCflags(self, config):
537537
)
538538
]
539539
)
540-
if self.vs_version.project_version >= 12.0:
540+
if float(self.vs_version.project_version) >= 12.0:
541541
# New flag introduced in VS2013 (project version 12.0) Forces writes to
542542
# the program database (PDB) to be serialized through MSPDBSRV.EXE.
543543
# https://msdn.microsoft.com/en-us/library/dn502518.aspx

Diff for: tools/gyp/pylib/gyp/win_tool.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ def ExecLinkWithManifests(
221221
# and sometimes doesn't unfortunately.
222222
with open(our_manifest) as our_f:
223223
with open(assert_manifest) as assert_f:
224-
our_data = our_f.read().translate(None, string.whitespace)
225-
assert_data = assert_f.read().translate(None, string.whitespace)
224+
translator = str.maketrans('', '', string.whitespace)
225+
our_data = our_f.read().translate(translator)
226+
assert_data = assert_f.read().translate(translator)
226227
if our_data != assert_data:
227228
os.unlink(out)
228229

Diff for: tools/gyp/pylib/gyp/xcodeproj_file.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ def __repr__(self):
299299
try:
300300
name = self.Name()
301301
except NotImplementedError:
302-
return "<{} at 0x{:x}>".format(self.__class__.__name__, id(self))
303-
return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self))
302+
return f"<{self.__class__.__name__} at 0x{id(self):x}>"
303+
return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>"
304304

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

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

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

22932293
def Name(self):
22942294
# Admittedly not the best name, but it's what Xcode uses.

Diff for: tools/gyp/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
setup(
1717
name="gyp-next",
18-
version="0.9.1",
18+
version="0.9.3",
1919
description="A fork of the GYP build system for use in the Node.js projects",
2020
long_description=long_description,
2121
long_description_content_type="text/markdown",

Diff for: tools/gyp/test_gyp.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ def main(argv=None):
140140
if not args.quiet:
141141
runner.print_results()
142142

143-
if runner.failures:
144-
return 1
145-
else:
146-
return 0
143+
return 1 if runner.failures else 0
147144

148145

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

155-
print(" Mac {} {}".format(platform.mac_ver()[0], platform.mac_ver()[2]))
156-
print(" Xcode %s" % TestMac.Xcode.Version())
152+
print(f" Mac {platform.mac_ver()[0]} {platform.mac_ver()[2]}")
153+
print(f" Xcode {TestMac.Xcode.Version()}")
157154
elif sys.platform == "win32":
158155
sys.path.append(os.path.abspath("pylib"))
159156
import gyp.MSVSVersion
@@ -162,8 +159,8 @@ def print_configuration_info():
162159
print(" MSVS %s" % gyp.MSVSVersion.SelectVisualStudioVersion().Description())
163160
elif sys.platform in ("linux", "linux2"):
164161
print(" Linux %s" % " ".join(platform.linux_distribution()))
165-
print(" Python %s" % platform.python_version())
166-
print(" PYTHONPATH=%s" % os.environ["PYTHONPATH"])
162+
print(f" Python {platform.python_version()}")
163+
print(f" PYTHONPATH={os.environ['PYTHONPATH']}")
167164
print()
168165

169166

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

225-
if (
226-
stdout
227-
and not stdout.endswith("PASSED\n")
228-
and not (stdout.endswith("NO RESULT\n"))
229-
):
222+
if stdout and not stdout.endswith(("PASSED\n", "NO RESULT\n")):
230223
print()
231-
print("\n".join(" %s" % line for line in stdout.splitlines()))
224+
print("\n".join(f" {line}" for line in stdout.splitlines()))
232225
elif not self.isatty:
233226
print()
234227

0 commit comments

Comments
 (0)