Skip to content

Commit ed9a9ed

Browse files
authored
feat(gyp): update gyp to v0.9.6 (#2481)
1 parent 660dd7b commit ed9a9ed

File tree

16 files changed

+137
-73
lines changed

16 files changed

+137
-73
lines changed

gyp/.github/workflows/Python_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
python -m pip install --upgrade pip
2424
pip install -r requirements_dev.txt
2525
- name: Lint with flake8
26-
run: flake8 . --count --show-source --statistics
26+
run: flake8 . --ignore=E203,W503 --max-complexity=101 --max-line-length=88 --show-source --statistics
2727
- name: Test with pytest
2828
run: pytest
2929
# - name: Run doctests with pytest

gyp/.github/workflows/node-gyp.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
fail-fast: false
99
matrix:
1010
os: [macos-latest, ubuntu-latest, windows-latest]
11+
python: [3.6, 3.9]
12+
1113
runs-on: ${{ matrix.os }}
1214
steps:
1315
- name: Clone gyp-next
@@ -24,7 +26,7 @@ jobs:
2426
node-version: 14.x
2527
- uses: actions/setup-python@v2
2628
with:
27-
python-version: 3.9
29+
python-version: ${{ matrix.python }}
2830
- name: Install dependencies
2931
run: |
3032
cd node-gyp

gyp/CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Changelog
22

3+
### [0.9.6](https://www.github.com/nodejs/gyp-next/compare/v0.9.5...v0.9.6) (2021-08-23)
4+
5+
6+
### Bug Fixes
7+
8+
* align flake8 test ([#122](https://www.github.com/nodejs/gyp-next/issues/122)) ([f1faa8d](https://www.github.com/nodejs/gyp-next/commit/f1faa8d3081e1a47e917ff910892f00dff16cf8a))
9+
* **msvs:** fix paths again in action command arguments ([#121](https://www.github.com/nodejs/gyp-next/issues/121)) ([7159dfb](https://www.github.com/nodejs/gyp-next/commit/7159dfbc5758c9ec717e215f2c36daf482c846a1))
10+
11+
### [0.9.5](https://www.github.com/nodejs/gyp-next/compare/v0.9.4...v0.9.5) (2021-08-18)
12+
13+
14+
### Bug Fixes
15+
16+
* add python 3.6 to node-gyp integration test ([3462d4c](https://www.github.com/nodejs/gyp-next/commit/3462d4ce3c31cce747513dc7ca9760c81d57c60e))
17+
* revert for windows compatibility ([d078e7d](https://www.github.com/nodejs/gyp-next/commit/d078e7d7ae080ddae243188f6415f940376a7368))
18+
* support msvs_quote_cmd in ninja generator ([#117](https://www.github.com/nodejs/gyp-next/issues/117)) ([46486ac](https://www.github.com/nodejs/gyp-next/commit/46486ac6e9329529d51061e006a5b39631e46729))
19+
20+
### [0.9.4](https://www.github.com/nodejs/gyp-next/compare/v0.9.3...v0.9.4) (2021-08-09)
21+
22+
23+
### Bug Fixes
24+
25+
* .S is an extension for asm file on Windows ([#115](https://www.github.com/nodejs/gyp-next/issues/115)) ([d2fad44](https://www.github.com/nodejs/gyp-next/commit/d2fad44ef3a79ca8900f1307060153ded57053fc))
26+
27+
### [0.9.3](https://www.github.com/nodejs/gyp-next/compare/v0.9.2...v0.9.3) (2021-07-07)
28+
29+
30+
### Bug Fixes
31+
32+
* 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))
33+
34+
### [0.9.2](https://www.github.com/nodejs/gyp-next/compare/v0.9.1...v0.9.2) (2021-05-21)
35+
36+
37+
### Bug Fixes
38+
39+
* 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))
40+
341
### [0.9.1](https://www.github.com/nodejs/gyp-next/compare/v0.9.0...v0.9.1) (2021-05-14)
442

543

gyp/pylib/gyp/MSVSUtil.py

Lines changed: 1 addition & 1 deletion
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

gyp/pylib/gyp/common.py

Lines changed: 1 addition & 1 deletion
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):

gyp/pylib/gyp/easy_xml.py

Lines changed: 4 additions & 2 deletions
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:

gyp/pylib/gyp/generator/android.py

Lines changed: 3 additions & 3 deletions
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

gyp/pylib/gyp/generator/make.py

Lines changed: 1 addition & 1 deletion
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."""

gyp/pylib/gyp/generator/msvs.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _NormalizedSource(source):
152152
return source
153153

154154

155-
def _FixPath(path):
155+
def _FixPath(path, separator="\\"):
156156
"""Convert paths to a form that will make sense in a vcproj file.
157157
158158
Arguments:
@@ -168,9 +168,12 @@ def _FixPath(path):
168168
and not _IsWindowsAbsPath(path)
169169
):
170170
path = os.path.join(fixpath_prefix, path)
171-
path = path.replace("/", "\\")
171+
if separator == "\\":
172+
path = path.replace("/", "\\")
172173
path = _NormalizedSource(path)
173-
if path and path[-1] == "\\":
174+
if separator == "/":
175+
path = path.replace("\\", "/")
176+
if path and path[-1] == separator:
174177
path = path[:-1]
175178
return path
176179

@@ -185,9 +188,9 @@ def _IsWindowsAbsPath(path):
185188
return path.startswith("c:") or path.startswith("C:")
186189

187190

188-
def _FixPaths(paths):
191+
def _FixPaths(paths, separator="\\"):
189192
"""Fix each of the paths of the list."""
190-
return [_FixPath(i) for i in paths]
193+
return [_FixPath(i, separator) for i in paths]
191194

192195

193196
def _ConvertSourcesToFilterHierarchy(
@@ -314,7 +317,7 @@ def _ConfigBaseName(config_name, platform_name):
314317

315318
def _ConfigFullName(config_name, config_data):
316319
platform_name = _ConfigPlatform(config_data)
317-
return "{}|{}".format(_ConfigBaseName(config_name, platform_name), platform_name)
320+
return f"{_ConfigBaseName(config_name, platform_name)}|{platform_name}"
318321

319322

320323
def _ConfigWindowsTargetPlatformVersion(config_data, version):
@@ -335,15 +338,15 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version):
335338
# Find a matching entry in sdk_dir\include.
336339
expected_sdk_dir = r"%s\include" % sdk_dir
337340
names = sorted(
338-
[
341+
(
339342
x
340343
for x in (
341344
os.listdir(expected_sdk_dir)
342345
if os.path.isdir(expected_sdk_dir)
343346
else []
344347
)
345348
if x.startswith(version)
346-
],
349+
),
347350
reverse=True,
348351
)
349352
if names:
@@ -418,7 +421,15 @@ def _BuildCommandLineForRuleRaw(
418421
# file out of the raw command string, and some commands (like python) are
419422
# actually batch files themselves.
420423
command.insert(0, "call")
421-
arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in cmd[1:]]
424+
# Fix the paths
425+
# TODO(quote): This is a really ugly heuristic, and will miss path fixing
426+
# for arguments like "--arg=path" or "/opt:path".
427+
# If the argument starts with a slash or dash, it's probably a command line
428+
# switch
429+
# Return the path with forward slashes because the command using it might
430+
# not support backslashes.
431+
arguments = [i if (i[:1] in "/-") else _FixPath(i, "/") for i in cmd[1:]]
432+
arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in arguments]
422433
arguments = [MSVSSettings.FixVCMacroSlashes(i) for i in arguments]
423434
if quote_cmd:
424435
# Support a mode for using cmd directly.

gyp/pylib/gyp/generator/ninja.py

Lines changed: 16 additions & 16 deletions
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

@@ -654,18 +654,18 @@ def WriteActions(
654654
description = self.GenerateDescription(
655655
"ACTION", action.get("message", None), name
656656
)
657-
is_cygwin = (
658-
self.msvs_settings.IsRuleRunUnderCygwin(action)
657+
win_shell_flags = (
658+
self.msvs_settings.GetRuleShellFlags(action)
659659
if self.flavor == "win"
660-
else False
660+
else None
661661
)
662662
args = action["action"]
663663
depfile = action.get("depfile", None)
664664
if depfile:
665665
depfile = self.ExpandSpecial(depfile, self.base_to_build)
666666
pool = "console" if int(action.get("ninja_use_console", 0)) else None
667667
rule_name, _ = self.WriteNewNinjaRule(
668-
name, args, description, is_cygwin, env, pool, depfile=depfile
668+
name, args, description, win_shell_flags, env, pool, depfile=depfile
669669
)
670670

671671
inputs = [self.GypPathToNinja(i, env) for i in action["inputs"]]
@@ -707,14 +707,14 @@ def WriteRules(
707707
rule.get("message", None),
708708
("%s " + generator_default_variables["RULE_INPUT_PATH"]) % name,
709709
)
710-
is_cygwin = (
711-
self.msvs_settings.IsRuleRunUnderCygwin(rule)
710+
win_shell_flags = (
711+
self.msvs_settings.GetRuleShellFlags(rule)
712712
if self.flavor == "win"
713-
else False
713+
else None
714714
)
715715
pool = "console" if int(rule.get("ninja_use_console", 0)) else None
716716
rule_name, args = self.WriteNewNinjaRule(
717-
name, args, description, is_cygwin, env, pool
717+
name, args, description, win_shell_flags, env, pool
718718
)
719719

720720
# TODO: if the command references the outputs directly, we should
@@ -733,7 +733,7 @@ def WriteRules(
733733

734734
def cygwin_munge(path):
735735
# pylint: disable=cell-var-from-loop
736-
if is_cygwin:
736+
if win_shell_flags and win_shell_flags.cygwin:
737737
return path.replace("\\", "/")
738738
return path
739739

@@ -1221,7 +1221,7 @@ def WriteSourcesForArch(
12211221
command = "cc_s"
12221222
elif (
12231223
self.flavor == "win"
1224-
and ext == "asm"
1224+
and ext in ("asm", "S")
12251225
and not self.msvs_settings.HasExplicitAsmRules(spec)
12261226
):
12271227
command = "asm"
@@ -1899,7 +1899,7 @@ def WriteVariableList(self, ninja_file, var, values):
18991899
ninja_file.variable(var, " ".join(values))
19001900

19011901
def WriteNewNinjaRule(
1902-
self, name, args, description, is_cygwin, env, pool, depfile=None
1902+
self, name, args, description, win_shell_flags, env, pool, depfile=None
19031903
):
19041904
"""Write out a new ninja "rule" statement for a given command.
19051905
@@ -1946,13 +1946,14 @@ def WriteNewNinjaRule(
19461946
if self.flavor == "win":
19471947
rspfile = rule_name + ".$unique_name.rsp"
19481948
# The cygwin case handles this inside the bash sub-shell.
1949-
run_in = "" if is_cygwin else " " + self.build_to_base
1950-
if is_cygwin:
1949+
run_in = "" if win_shell_flags.cygwin else " " + self.build_to_base
1950+
if win_shell_flags.cygwin:
19511951
rspfile_content = self.msvs_settings.BuildCygwinBashCommandLine(
19521952
args, self.build_to_base
19531953
)
19541954
else:
1955-
rspfile_content = gyp.msvs_emulation.EncodeRspFileList(args)
1955+
rspfile_content = gyp.msvs_emulation.EncodeRspFileList(
1956+
args, win_shell_flags.quote)
19561957
command = (
19571958
"%s gyp-win-tool action-wrapper $arch " % sys.executable
19581959
+ rspfile
@@ -2389,7 +2390,6 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
23892390
)
23902391
if flavor == "win":
23912392
master_ninja.variable("ld_host", ld_host)
2392-
master_ninja.variable("ldxx_host", ldxx_host)
23932393
else:
23942394
master_ninja.variable(
23952395
"ld_host", CommandWithWrapper("LINK", wrappers, ld_host)

0 commit comments

Comments
 (0)