Skip to content

Commit 0e65632

Browse files
feat: update gyp-next to v0.20.2 (#3169)
* feat: update gyp-next to v0.20.2
1 parent 7d883b5 commit 0e65632

26 files changed

+122
-106
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ jobs:
1414
python-version: ["3.9", "3.11", "3.13"]
1515
include:
1616
- node-version: "22"
17-
os: macos-13
17+
os: macos-13 # macOS on Intel
1818
python-version: "3.13"
1919
- node-version: "22"
20-
os: windows-2025
20+
os: ubuntu-24.04-arm # Ubuntu on ARM
21+
python-version: "3.13"
22+
- node-version: "22"
23+
os: windows-11-arm # Windows on ARM
2124
python-version: "3.13"
2225
runs-on: ${{ matrix.os }}
2326
steps:

gyp/.github/workflows/nodejs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ jobs:
1212
os: [macos-latest, ubuntu-latest, windows-latest]
1313
python: ["3.9", "3.11", "3.13"]
1414
include:
15-
- os: macos-13
15+
- os: macos-13 # macOS on Intel
1616
python-version: "3.13"
17-
- os: windows-2025
17+
- os: ubuntu-24.04-arm # Ubuntu on ARM
18+
python-version: "3.13"
19+
- os: windows-11-arm # Windows on ARM
1820
python-version: "3.13"
1921

2022
runs-on: ${{ matrix.os }}

gyp/.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.20.0"
2+
".": "0.20.2"
33
}

gyp/CHANGELOG.md

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

3+
## [0.20.2](https://github.com/nodejs/gyp-next/compare/v0.20.1...v0.20.2) (2025-06-22)
4+
5+
6+
### Bug Fixes
7+
8+
* Python lint import-outside-top-level ruff rule PLC0415 ([#298](https://github.com/nodejs/gyp-next/issues/298)) ([34f4df6](https://github.com/nodejs/gyp-next/commit/34f4df614936ee6a056e47406ebbe7e3c1cb6540))
9+
10+
## [0.20.1](https://github.com/nodejs/gyp-next/compare/v0.20.0...v0.20.1) (2025-06-06)
11+
12+
13+
### Bug Fixes
14+
15+
* Ensure Consistent Order of build_files in WriteAutoRegenerationRule ([#293](https://github.com/nodejs/gyp-next/issues/293)) ([59b5903](https://github.com/nodejs/gyp-next/commit/59b59035f4ae63419343ffdafe0f0ff511ada17d))
16+
* ignore failure of `GetCompilerPredefines` ([#295](https://github.com/nodejs/gyp-next/issues/295)) ([0eaea29](https://github.com/nodejs/gyp-next/commit/0eaea297f0fbb0869597aa162f66f78eb2468fad))
17+
318
## [0.20.0](https://github.com/nodejs/gyp-next/compare/v0.19.1...v0.20.0) (2025-03-27)
419

520

gyp/pylib/gyp/MSVSSettings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ def _ValidateExclusionSetting(setting, settings, error_msg, stderr=sys.stderr):
396396
# This may be unrecognized because it's an exclusion list. If the
397397
# setting name has the _excluded suffix, then check the root name.
398398
unrecognized = True
399-
m = re.match(_EXCLUDED_SUFFIX_RE, setting)
400-
if m:
399+
if m := re.match(_EXCLUDED_SUFFIX_RE, setting):
401400
root_setting = m.group(1)
402401
unrecognized = root_setting not in settings
403402

gyp/pylib/gyp/MSVSVersion.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def _RegistryGetValueUsingWinReg(key, value):
219219
contents of the registry key's value, or None on failure. Throws
220220
ImportError if winreg is unavailable.
221221
"""
222-
from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
222+
from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx # noqa: PLC0415
223223
try:
224224
root, subkey = key.split("\\", 1)
225225
assert root == "HKLM" # Only need HKLM for now.
@@ -552,8 +552,7 @@ def SelectVisualStudioVersion(version="auto", allow_fallback=True):
552552
"2019": ("16.0",),
553553
"2022": ("17.0",),
554554
}
555-
override_path = os.environ.get("GYP_MSVS_OVERRIDE_PATH")
556-
if override_path:
555+
if override_path := os.environ.get("GYP_MSVS_OVERRIDE_PATH"):
557556
msvs_version = os.environ.get("GYP_MSVS_VERSION")
558557
if not msvs_version:
559558
raise ValueError(

gyp/pylib/gyp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def gyp_main(args):
489489

490490
options, build_files_arg = parser.parse_args(args)
491491
if options.version:
492-
import pkg_resources
492+
import pkg_resources # noqa: PLC0415
493493
print(f"v{pkg_resources.get_distribution('gyp-next').version}")
494494
return 0
495495
build_files = build_files_arg

gyp/pylib/gyp/common.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,9 @@ def EnsureDirExists(path):
421421
except OSError:
422422
pass
423423

424-
def GetCrossCompilerPredefines(): # -> dict
424+
def GetCompilerPredefines(): # -> dict
425425
cmd = []
426+
defines = {}
426427

427428
# shlex.split() will eat '\' in posix mode, but
428429
# setting posix=False will preserve extra '"' cause CreateProcess fail on Windows
@@ -439,7 +440,7 @@ def replace_sep(s):
439440
if CXXFLAGS := os.environ.get("CXXFLAGS"):
440441
cmd += shlex.split(replace_sep(CXXFLAGS))
441442
else:
442-
return {}
443+
return defines
443444

444445
if sys.platform == "win32":
445446
fd, input = tempfile.mkstemp(suffix=".c")
@@ -450,17 +451,33 @@ def replace_sep(s):
450451
real_cmd, shell=True,
451452
capture_output=True, check=True
452453
).stdout
454+
except subprocess.CalledProcessError as e:
455+
print(
456+
"Warning: failed to get compiler predefines\n"
457+
"cmd: %s\n"
458+
"status: %d" % (e.cmd, e.returncode),
459+
file=sys.stderr
460+
)
461+
return defines
453462
finally:
454463
os.unlink(input)
455464
else:
456465
input = "/dev/null"
457466
real_cmd = [*cmd, "-dM", "-E", "-x", "c", input]
458-
stdout = subprocess.run(
459-
real_cmd, shell=False,
460-
capture_output=True, check=True
461-
).stdout
467+
try:
468+
stdout = subprocess.run(
469+
real_cmd, shell=False,
470+
capture_output=True, check=True
471+
).stdout
472+
except subprocess.CalledProcessError as e:
473+
print(
474+
"Warning: failed to get compiler predefines\n"
475+
"cmd: %s\n"
476+
"status: %d" % (e.cmd, e.returncode),
477+
file=sys.stderr
478+
)
479+
return defines
462480

463-
defines = {}
464481
lines = stdout.decode("utf-8").replace("\r\n", "\n").split("\n")
465482
for line in lines:
466483
if (line or "").startswith("#define "):
@@ -499,7 +516,7 @@ def GetFlavor(params):
499516
if "flavor" in params:
500517
return params["flavor"]
501518

502-
defines = GetCrossCompilerPredefines()
519+
defines = GetCompilerPredefines()
503520
if "__EMSCRIPTEN__" in defines:
504521
return "emscripten"
505522
if "__wasm__" in defines:
@@ -566,7 +583,8 @@ def uniquer(seq, idfun=lambda x: x):
566583

567584

568585
# Based on http://code.activestate.com/recipes/576694/.
569-
class OrderedSet(MutableSet):
586+
class OrderedSet(MutableSet): # noqa: PLW1641
587+
# TODO (cclauss): Fix eq-without-hash ruff rule PLW1641
570588
def __init__(self, iterable=None):
571589
self.end = end = []
572590
end += [None, end, end] # sentinel node for doubly linked list

gyp/pylib/gyp/common_test.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""Unit tests for the common.py file."""
88

99
import os
10+
import subprocess
1011
import sys
1112
import unittest
1213
from unittest.mock import MagicMock, patch
@@ -85,22 +86,34 @@ def decode(self, encoding):
8586
@patch("os.close")
8687
@patch("os.unlink")
8788
@patch("tempfile.mkstemp")
88-
def test_GetCrossCompilerPredefines(self, mock_mkstemp, mock_unlink, mock_close):
89+
def test_GetCompilerPredefines(self, mock_mkstemp, mock_unlink, mock_close):
8990
mock_close.return_value = None
9091
mock_unlink.return_value = None
9192
mock_mkstemp.return_value = (0, "temp.c")
9293

93-
def mock_run(env, defines_stdout, expected_cmd):
94+
def mock_run(env, defines_stdout, expected_cmd, throws=False):
9495
with patch("subprocess.run") as mock_run:
95-
mock_process = MagicMock()
96-
mock_process.returncode = 0
97-
mock_process.stdout = TestGetFlavor.MockCommunicate(defines_stdout)
98-
mock_run.return_value = mock_process
9996
expected_input = "temp.c" if sys.platform == "win32" else "/dev/null"
97+
if throws:
98+
mock_run.side_effect = subprocess.CalledProcessError(
99+
returncode=1,
100+
cmd=[
101+
*expected_cmd,
102+
"-dM", "-E", "-x", "c", expected_input
103+
]
104+
)
105+
else:
106+
mock_process = MagicMock()
107+
mock_process.returncode = 0
108+
mock_process.stdout = TestGetFlavor.MockCommunicate(defines_stdout)
109+
mock_run.return_value = mock_process
100110
with patch.dict(os.environ, env):
101-
defines = gyp.common.GetCrossCompilerPredefines()
111+
try:
112+
defines = gyp.common.GetCompilerPredefines()
113+
except Exception as e:
114+
self.fail(f"GetCompilerPredefines raised an exception: {e}")
102115
flavor = gyp.common.GetFlavor({})
103-
if env.get("CC_target"):
116+
if env.get("CC_target") or env.get("CC"):
104117
mock_run.assert_called_with(
105118
[
106119
*expected_cmd,
@@ -110,6 +123,9 @@ def mock_run(env, defines_stdout, expected_cmd):
110123
capture_output=True, check=True)
111124
return [defines, flavor]
112125

126+
[defines0, _] = mock_run({ "CC": "cl.exe" }, "", ["cl.exe"], True)
127+
assert defines0 == {}
128+
113129
[defines1, _] = mock_run({}, "", [])
114130
assert defines1 == {}
115131

gyp/pylib/gyp/generator/android.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,7 @@ def WriteTarget(
900900
if self.type != "none":
901901
self.WriteTargetFlags(spec, configs, link_deps)
902902

903-
settings = spec.get("aosp_build_settings", {})
904-
if settings:
903+
if settings := spec.get("aosp_build_settings", {}):
905904
self.WriteLn("### Set directly by aosp_build_settings.")
906905
for k, v in settings.items():
907906
if isinstance(v, list):

0 commit comments

Comments
 (0)