Skip to content

Commit d82ee96

Browse files
gengjiawentargos
authored andcommitted
tools: update gyp-next to v0.9.5
PR-URL: #39818 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 208305f commit d82ee96

File tree

6 files changed

+67
-34
lines changed

6 files changed

+67
-34
lines changed

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

+3-1
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

tools/gyp/CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
### [0.9.5](https://www.github.com/nodejs/gyp-next/compare/v0.9.4...v0.9.5) (2021-08-18)
4+
5+
6+
### Bug Fixes
7+
8+
* add python 3.6 to node-gyp integration test ([3462d4c](https://www.github.com/nodejs/gyp-next/commit/3462d4ce3c31cce747513dc7ca9760c81d57c60e))
9+
* revert for windows compatibility ([d078e7d](https://www.github.com/nodejs/gyp-next/commit/d078e7d7ae080ddae243188f6415f940376a7368))
10+
* 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))
11+
12+
### [0.9.4](https://www.github.com/nodejs/gyp-next/compare/v0.9.3...v0.9.4) (2021-08-09)
13+
14+
15+
### Bug Fixes
16+
17+
* .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))
18+
319
### [0.9.3](https://www.github.com/nodejs/gyp-next/compare/v0.9.2...v0.9.3) (2021-07-07)
420

521

tools/gyp/pylib/gyp/easy_xml.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,7 @@ def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False,
123123

124124
default_encoding = locale.getdefaultlocale()[1]
125125
if default_encoding and default_encoding.upper() != encoding.upper():
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)
126+
xml_string = xml_string.encode(encoding)
130127

131128
# Get the old content
132129
try:

tools/gyp/pylib/gyp/generator/ninja.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -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

tools/gyp/pylib/gyp/msvs_emulation.py

+31-14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
build systems, primarily ninja.
88
"""
99

10+
import collections
1011
import os
1112
import re
1213
import subprocess
@@ -19,7 +20,7 @@
1920
windows_quoter_regex = re.compile(r'(\\*)"')
2021

2122

22-
def QuoteForRspFile(arg):
23+
def QuoteForRspFile(arg, quote_cmd=True):
2324
"""Quote a command line argument so that it appears as one argument when
2425
processed via cmd.exe and parsed by CommandLineToArgvW (as is typical for
2526
Windows programs)."""
@@ -36,7 +37,8 @@ def QuoteForRspFile(arg):
3637
# For a literal quote, CommandLineToArgvW requires 2n+1 backslashes
3738
# preceding it, and results in n backslashes + the quote. So we substitute
3839
# in 2* what we match, +1 more, plus the quote.
39-
arg = windows_quoter_regex.sub(lambda mo: 2 * mo.group(1) + '\\"', arg)
40+
if quote_cmd:
41+
arg = windows_quoter_regex.sub(lambda mo: 2 * mo.group(1) + '\\"', arg)
4042

4143
# %'s also need to be doubled otherwise they're interpreted as batch
4244
# positional arguments. Also make sure to escape the % so that they're
@@ -48,12 +50,17 @@ def QuoteForRspFile(arg):
4850
# These commands are used in rsp files, so no escaping for the shell (via ^)
4951
# is necessary.
5052

51-
# Finally, wrap the whole thing in quotes so that the above quote rule
52-
# applies and whitespace isn't a word break.
53-
return '"' + arg + '"'
53+
# As a workaround for programs that don't use CommandLineToArgvW, gyp
54+
# supports msvs_quote_cmd=0, which simply disables all quoting.
55+
if quote_cmd:
56+
# Finally, wrap the whole thing in quotes so that the above quote rule
57+
# applies and whitespace isn't a word break.
58+
return f'"{arg}"'
5459

60+
return arg
5561

56-
def EncodeRspFileList(args):
62+
63+
def EncodeRspFileList(args, quote_cmd):
5764
"""Process a list of arguments using QuoteCmdExeArgument."""
5865
# Note that the first argument is assumed to be the command. Don't add
5966
# quotes around it because then built-ins like 'echo', etc. won't work.
@@ -67,7 +74,8 @@ def EncodeRspFileList(args):
6774
program = call + " " + os.path.normpath(program)
6875
else:
6976
program = os.path.normpath(args[0])
70-
return program + " " + " ".join(QuoteForRspFile(arg) for arg in args[1:])
77+
return (program + " " +
78+
" ".join(QuoteForRspFile(arg, quote_cmd) for arg in args[1:]))
7179

7280

7381
def _GenericRetrieve(root, default, path):
@@ -933,13 +941,22 @@ def BuildCygwinBashCommandLine(self, args, path_to_base):
933941
)
934942
return cmd
935943

936-
def IsRuleRunUnderCygwin(self, rule):
937-
"""Determine if an action should be run under cygwin. If the variable is
938-
unset, or set to 1 we use cygwin."""
939-
return (
940-
int(rule.get("msvs_cygwin_shell", self.spec.get("msvs_cygwin_shell", 1)))
941-
!= 0
942-
)
944+
RuleShellFlags = collections.namedtuple("RuleShellFlags", ["cygwin", "quote"])
945+
946+
def GetRuleShellFlags(self, rule):
947+
"""Return RuleShellFlags about how the given rule should be run. This
948+
includes whether it should run under cygwin (msvs_cygwin_shell), and
949+
whether the commands should be quoted (msvs_quote_cmd)."""
950+
# If the variable is unset, or set to 1 we use cygwin
951+
cygwin = int(rule.get("msvs_cygwin_shell",
952+
self.spec.get("msvs_cygwin_shell", 1))) != 0
953+
# Default to quoting. There's only a few special instances where the
954+
# target command uses non-standard command line parsing and handle quotes
955+
# and quote escaping differently.
956+
quote_cmd = int(rule.get("msvs_quote_cmd", 1))
957+
assert quote_cmd != 0 or cygwin != 1, \
958+
"msvs_quote_cmd=0 only applicable for msvs_cygwin_shell=0"
959+
return MsvsSettings.RuleShellFlags(cygwin, quote_cmd)
943960

944961
def _HasExplicitRuleForExtension(self, spec, extension):
945962
"""Determine if there's an explicit rule for a particular extension."""

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.3",
18+
version="0.9.5",
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",

0 commit comments

Comments
 (0)