Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: update gyp-next to v0.9.5 #39818

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tools/gyp/.github/workflows/node-gyp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python: [3.6, 3.9]

runs-on: ${{ matrix.os }}
steps:
- name: Clone gyp-next
Expand All @@ -24,7 +26,7 @@ jobs:
node-version: 14.x
- uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
cd node-gyp
Expand Down
16 changes: 16 additions & 0 deletions tools/gyp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

### [0.9.5](https://www.github.com/nodejs/gyp-next/compare/v0.9.4...v0.9.5) (2021-08-18)


### Bug Fixes

* add python 3.6 to node-gyp integration test ([3462d4c](https://www.github.com/nodejs/gyp-next/commit/3462d4ce3c31cce747513dc7ca9760c81d57c60e))
* revert for windows compatibility ([d078e7d](https://www.github.com/nodejs/gyp-next/commit/d078e7d7ae080ddae243188f6415f940376a7368))
* 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))

### [0.9.4](https://www.github.com/nodejs/gyp-next/compare/v0.9.3...v0.9.4) (2021-08-09)


### Bug Fixes

* .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))

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


Expand Down
5 changes: 1 addition & 4 deletions tools/gyp/pylib/gyp/easy_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False,

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

# Get the old content
try:
Expand Down
29 changes: 15 additions & 14 deletions tools/gyp/pylib/gyp/generator/ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,18 +654,18 @@ def WriteActions(
description = self.GenerateDescription(
"ACTION", action.get("message", None), name
)
is_cygwin = (
self.msvs_settings.IsRuleRunUnderCygwin(action)
win_shell_flags = (
self.msvs_settings.GetRuleShellFlags(action)
if self.flavor == "win"
else False
else None
)
args = action["action"]
depfile = action.get("depfile", None)
if depfile:
depfile = self.ExpandSpecial(depfile, self.base_to_build)
pool = "console" if int(action.get("ninja_use_console", 0)) else None
rule_name, _ = self.WriteNewNinjaRule(
name, args, description, is_cygwin, env, pool, depfile=depfile
name, args, description, win_shell_flags, env, pool, depfile=depfile
)

inputs = [self.GypPathToNinja(i, env) for i in action["inputs"]]
Expand Down Expand Up @@ -707,14 +707,14 @@ def WriteRules(
rule.get("message", None),
("%s " + generator_default_variables["RULE_INPUT_PATH"]) % name,
)
is_cygwin = (
self.msvs_settings.IsRuleRunUnderCygwin(rule)
win_shell_flags = (
self.msvs_settings.GetRuleShellFlags(rule)
if self.flavor == "win"
else False
else None
)
pool = "console" if int(rule.get("ninja_use_console", 0)) else None
rule_name, args = self.WriteNewNinjaRule(
name, args, description, is_cygwin, env, pool
name, args, description, win_shell_flags, env, pool
)

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

def cygwin_munge(path):
# pylint: disable=cell-var-from-loop
if is_cygwin:
if win_shell_flags and win_shell_flags.cygwin:
return path.replace("\\", "/")
return path

Expand Down Expand Up @@ -1221,7 +1221,7 @@ def WriteSourcesForArch(
command = "cc_s"
elif (
self.flavor == "win"
and ext == "asm"
and ext in ("asm", "S")
and not self.msvs_settings.HasExplicitAsmRules(spec)
):
command = "asm"
Expand Down Expand Up @@ -1899,7 +1899,7 @@ def WriteVariableList(self, ninja_file, var, values):
ninja_file.variable(var, " ".join(values))

def WriteNewNinjaRule(
self, name, args, description, is_cygwin, env, pool, depfile=None
self, name, args, description, win_shell_flags, env, pool, depfile=None
):
"""Write out a new ninja "rule" statement for a given command.
Expand Down Expand Up @@ -1946,13 +1946,14 @@ def WriteNewNinjaRule(
if self.flavor == "win":
rspfile = rule_name + ".$unique_name.rsp"
# The cygwin case handles this inside the bash sub-shell.
run_in = "" if is_cygwin else " " + self.build_to_base
if is_cygwin:
run_in = "" if win_shell_flags.cygwin else " " + self.build_to_base
if win_shell_flags.cygwin:
rspfile_content = self.msvs_settings.BuildCygwinBashCommandLine(
args, self.build_to_base
)
else:
rspfile_content = gyp.msvs_emulation.EncodeRspFileList(args)
rspfile_content = gyp.msvs_emulation.EncodeRspFileList(
args, win_shell_flags.quote)
command = (
"%s gyp-win-tool action-wrapper $arch " % sys.executable
+ rspfile
Expand Down
45 changes: 31 additions & 14 deletions tools/gyp/pylib/gyp/msvs_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
build systems, primarily ninja.
"""

import collections
import os
import re
import subprocess
Expand All @@ -19,7 +20,7 @@
windows_quoter_regex = re.compile(r'(\\*)"')


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

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

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

return arg

def EncodeRspFileList(args):

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


def _GenericRetrieve(root, default, path):
Expand Down Expand Up @@ -933,13 +941,22 @@ def BuildCygwinBashCommandLine(self, args, path_to_base):
)
return cmd

def IsRuleRunUnderCygwin(self, rule):
"""Determine if an action should be run under cygwin. If the variable is
unset, or set to 1 we use cygwin."""
return (
int(rule.get("msvs_cygwin_shell", self.spec.get("msvs_cygwin_shell", 1)))
!= 0
)
RuleShellFlags = collections.namedtuple("RuleShellFlags", ["cygwin", "quote"])

def GetRuleShellFlags(self, rule):
"""Return RuleShellFlags about how the given rule should be run. This
includes whether it should run under cygwin (msvs_cygwin_shell), and
whether the commands should be quoted (msvs_quote_cmd)."""
# If the variable is unset, or set to 1 we use cygwin
cygwin = int(rule.get("msvs_cygwin_shell",
self.spec.get("msvs_cygwin_shell", 1))) != 0
# Default to quoting. There's only a few special instances where the
# target command uses non-standard command line parsing and handle quotes
# and quote escaping differently.
quote_cmd = int(rule.get("msvs_quote_cmd", 1))
assert quote_cmd != 0 or cygwin != 1, \
"msvs_quote_cmd=0 only applicable for msvs_cygwin_shell=0"
return MsvsSettings.RuleShellFlags(cygwin, quote_cmd)

def _HasExplicitRuleForExtension(self, spec, extension):
"""Determine if there's an explicit rule for a particular extension."""
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.3",
version="0.9.5",
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