From ee8ddb40856e38316c3c2dc23d0fd2d1160016c1 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Wed, 26 Aug 2026 00:11:49 +0000 Subject: [PATCH 1/3] feat: update gyp-next to v0.22.2 --- gyp/.github/dependabot.yml | 4 ---- gyp/.github/workflows/node-gyp.yml | 10 ++++------ gyp/.github/workflows/nodejs.yml | 8 +++----- gyp/.github/workflows/python_tests.yml | 16 ++++++---------- gyp/.github/workflows/release-please.yml | 19 ++++++++----------- 5 files changed, 21 insertions(+), 36 deletions(-) diff --git a/gyp/.github/dependabot.yml b/gyp/.github/dependabot.yml index 1a5cdb30bd..58d68276fc 100644 --- a/gyp/.github/dependabot.yml +++ b/gyp/.github/dependabot.yml @@ -10,8 +10,6 @@ updates: - "*" # Group all Actions updates into a single larger pull request schedule: interval: weekly - cooldown: - default-days: 7 - package-ecosystem: "pip" directory: "/" groups: @@ -20,5 +18,3 @@ updates: - "*" # Group all pip updates into a single larger pull request schedule: interval: weekly - cooldown: - default-days: 7 diff --git a/gyp/.github/workflows/node-gyp.yml b/gyp/.github/workflows/node-gyp.yml index 1271ff3487..016d2e0abc 100644 --- a/gyp/.github/workflows/node-gyp.yml +++ b/gyp/.github/workflows/node-gyp.yml @@ -21,20 +21,18 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Clone gyp-next - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + uses: actions/checkout@v6 with: path: gyp-next - persist-credentials: false - name: Clone nodejs/node-gyp - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + uses: actions/checkout@v6 with: repository: nodejs/node-gyp path: node-gyp - persist-credentials: false - - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 + - uses: actions/setup-node@v6 with: node-version: "lts/*" - - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 + - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} allow-prereleases: true diff --git a/gyp/.github/workflows/nodejs.yml b/gyp/.github/workflows/nodejs.yml index b464063231..c88fe7bcf2 100644 --- a/gyp/.github/workflows/nodejs.yml +++ b/gyp/.github/workflows/nodejs.yml @@ -22,17 +22,15 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Clone gyp-next - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + uses: actions/checkout@v6 with: path: gyp-next - persist-credentials: false - name: Clone nodejs/node - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + uses: actions/checkout@v6 with: repository: nodejs/node path: node - persist-credentials: false - - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 + - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} allow-prereleases: true diff --git a/gyp/.github/workflows/python_tests.yml b/gyp/.github/workflows/python_tests.yml index 0b335e5ca1..47f6e5e77c 100644 --- a/gyp/.github/workflows/python_tests.yml +++ b/gyp/.github/workflows/python_tests.yml @@ -10,13 +10,11 @@ jobs: Python_lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - with: - persist-credentials: false + - uses: actions/checkout@v6 - name: Lint with ruff # See pyproject.toml for settings - uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 # v3.6.1 + uses: astral-sh/ruff-action@v3 - run: ruff format --check --diff - - uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1 + - uses: wagoid/commitlint-github-action@v6 Python_tests: runs-on: ${{ matrix.os }} @@ -33,15 +31,13 @@ jobs: - os: windows-11-arm # Windows on ARM python-version: 3.x steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - with: - persist-credentials: false + - uses: actions/checkout@v6 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} allow-prereleases: true - - uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6 + - uses: seanmiddleditch/gha-setup-ninja@v6 - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/gyp/.github/workflows/release-please.yml b/gyp/.github/workflows/release-please.yml index 5182bee742..0022a3d894 100644 --- a/gyp/.github/workflows/release-please.yml +++ b/gyp/.github/workflows/release-please.yml @@ -14,7 +14,7 @@ jobs: contents: write pull-requests: write steps: - - uses: google-github-actions/release-please-action@e4dc86ba9405554aeba3c6bb2d169500e7d3b4ee # v4.1.1 + - uses: google-github-actions/release-please-action@v4 id: release build: @@ -24,13 +24,11 @@ jobs: if: ${{ needs.release-please.outputs.release_created }} # only publish on release runs-on: ubuntu-latest steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - with: - persist-credentials: false + - uses: actions/checkout@v6 - name: Build a binary wheel and a source tarball run: pipx run build - name: Store the distribution packages - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@v7 with: name: python-package-distributions path: dist/ @@ -50,12 +48,12 @@ jobs: id-token: write # IMPORTANT: mandatory for trusted publishing steps: - name: Download all the dists - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + uses: actions/download-artifact@v8 with: name: python-package-distributions path: dist/ - name: Publish distribution to PyPI - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 + uses: pypa/gh-action-pypi-publish@release/v1 github-release: name: >- @@ -70,12 +68,12 @@ jobs: id-token: write # IMPORTANT: mandatory for sigstore steps: - name: Download all the dists - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + uses: actions/download-artifact@v8 with: name: python-package-distributions path: dist/ - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@04cffa1d795717b140764e8b640de88853c92acc # v3.3.0 + uses: sigstore/gh-action-sigstore-python@v3.3.0 with: inputs: >- ./dist/*.tar.gz @@ -83,11 +81,10 @@ jobs: - name: Upload artifact signatures to GitHub Release env: GITHUB_TOKEN: ${{ github.token }} - TAG_NAME: ${{ needs.release-please.outputs.tag_name }} # Upload to GitHub Release using the `gh` CLI. # `dist/` contains the built packages, and the # sigstore-produced signatures and certificates. run: >- gh release upload - ${TAG_NAME} dist/** + ${{ needs.release-please.outputs.tag_name }} dist/** --repo '${{ github.repository }}' From a74462914ae905bcff04f19de2abb622f4042de0 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Wed, 30 Sep 2026 00:27:01 +0000 Subject: [PATCH 2/3] feat: update gyp-next to v0.22.3 --- gyp/.github/workflows/node-gyp.yml | 29 ++++--- gyp/.github/workflows/nodejs.yml | 23 ++--- gyp/.github/workflows/python_tests.yml | 22 +++-- gyp/.github/workflows/release-please.yml | 11 ++- gyp/.release-please-manifest.json | 2 +- gyp/CHANGELOG.md | 14 +++ gyp/README.md | 2 +- gyp/commitlint.config.js | 6 ++ gyp/pylib/gyp/generator/cmake.py | 33 +++---- gyp/pylib/gyp/generator/cmake_test.py | 105 +++++++++++++++++++++++ gyp/pylib/gyp/msvs_emulation.py | 9 +- gyp/pyproject.toml | 2 +- 12 files changed, 202 insertions(+), 56 deletions(-) create mode 100644 gyp/commitlint.config.js create mode 100644 gyp/pylib/gyp/generator/cmake_test.py diff --git a/gyp/.github/workflows/node-gyp.yml b/gyp/.github/workflows/node-gyp.yml index 016d2e0abc..e38d9c8fa2 100644 --- a/gyp/.github/workflows/node-gyp.yml +++ b/gyp/.github/workflows/node-gyp.yml @@ -4,35 +4,41 @@ on: pull_request: workflow_dispatch: +permissions: + contents: read + jobs: node-gyp-integration: strategy: fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] - python-version: ["3.10", "3.12", "3.14"] + python-version: ["3.11", "3.13", "3.15"] include: - - os: macos-15-intel # macOS on Intel - python-version: "3.14" + - os: macos-26-intel # macOS on Intel + python-version: 3.x - os: ubuntu-24.04-arm # Ubuntu on ARM - python-version: "3.14" + python-version: 3.x - os: windows-11-arm # Windows on ARM - python-version: "3.14" + python-version: 3.x + - os: windows-2025-vs2026 # Windows with Visual Studio 2026 + python-version: 3.x runs-on: ${{ matrix.os }} steps: - name: Clone gyp-next - uses: actions/checkout@v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: path: gyp-next - name: Clone nodejs/node-gyp - uses: actions/checkout@v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: nodejs/node-gyp path: node-gyp - - uses: actions/setup-node@v6 + persist-credentials: false + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: "lts/*" - - uses: actions/setup-python@v6 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: ${{ matrix.python-version }} allow-prereleases: true @@ -44,6 +50,7 @@ jobs: pip uninstall -y gyp-next - name: Install Node.js dependencies run: | + npm install --global npm@12 cd node-gyp npm install --no-progress - name: Replace gyp in node-gyp @@ -55,10 +62,10 @@ jobs: if: runner.os != 'Windows' run: | cd node-gyp - npm test --python="${pythonLocation}/python" + npm test - name: Run tests (Windows) if: runner.os == 'Windows' shell: pwsh run: | cd node-gyp - npm run test --python="${env:pythonLocation}\\python.exe" + npm run test diff --git a/gyp/.github/workflows/nodejs.yml b/gyp/.github/workflows/nodejs.yml index c88fe7bcf2..12849c809d 100644 --- a/gyp/.github/workflows/nodejs.yml +++ b/gyp/.github/workflows/nodejs.yml @@ -3,34 +3,37 @@ on: push: pull_request: workflow_dispatch: - +permissions: {} jobs: nodejs-integration: strategy: fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] - python-version: ["3.10", "3.12", "3.14"] + python-version: ["3.11", "3.13", "3.15"] include: - - os: macos-15-intel # macOS on Intel - python-version: "3.14" + - os: macos-26-intel # macOS on Intel + python-version: 3.x - os: ubuntu-24.04-arm # Ubuntu on ARM - python-version: "3.14" + python-version: 3.x - os: windows-11-arm # Windows on ARM - python-version: "3.14" + python-version: 3.x + - os: windows-2025-vs2026 # Windows with Visual Studio 2026 + python-version: 3.x runs-on: ${{ matrix.os }} steps: - name: Clone gyp-next - uses: actions/checkout@v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: path: gyp-next - name: Clone nodejs/node - uses: actions/checkout@v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: nodejs/node path: node - - uses: actions/setup-python@v6 + persist-credentials: false + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: ${{ matrix.python-version }} allow-prereleases: true @@ -52,7 +55,7 @@ jobs: if: runner.os == 'Windows' run: choco install nasm - name: Run configure - if: runner.os == 'Windows' + if: runner.os == 'Windows' && matrix.python-version != '3.15' run: | cd node ./vcbuild.bat nobuild diff --git a/gyp/.github/workflows/python_tests.yml b/gyp/.github/workflows/python_tests.yml index 47f6e5e77c..d73c6121c1 100644 --- a/gyp/.github/workflows/python_tests.yml +++ b/gyp/.github/workflows/python_tests.yml @@ -5,14 +5,16 @@ on: push: pull_request: workflow_dispatch: - +permissions: {} jobs: Python_lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Lint with ruff # See pyproject.toml for settings - uses: astral-sh/ruff-action@v3 + uses: astral-sh/ruff-action@278981a28ce3188b1e39527901f38254bf3aac89 # v4.1.0 - run: ruff format --check --diff - uses: wagoid/commitlint-github-action@v6 @@ -21,19 +23,23 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-15-intel, macos-latest, ubuntu-latest, windows-latest] - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] + os: [macos-latest, ubuntu-latest, windows-latest] + python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"] include: - - os: macos-26 + - os: macos-26-intel # macOS on Intel python-version: 3.x - os: ubuntu-24.04-arm # Ubuntu on ARM python-version: 3.x - os: windows-11-arm # Windows on ARM python-version: 3.x + - os: windows-2025-vs2026 # Windows with Visual Studio 2026 + python-version: 3.x steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v6 + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: ${{ matrix.python-version }} allow-prereleases: true diff --git a/gyp/.github/workflows/release-please.yml b/gyp/.github/workflows/release-please.yml index 0022a3d894..7e3b2e8f08 100644 --- a/gyp/.github/workflows/release-please.yml +++ b/gyp/.github/workflows/release-please.yml @@ -3,6 +3,8 @@ on: branches: - main +permissions: {} + name: release-please jobs: release-please: @@ -24,7 +26,9 @@ jobs: if: ${{ needs.release-please.outputs.release_created }} # only publish on release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Build a binary wheel and a source tarball run: pipx run build - name: Store the distribution packages @@ -73,7 +77,7 @@ jobs: name: python-package-distributions path: dist/ - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@v3.3.0 + uses: sigstore/gh-action-sigstore-python@790bc6befb9d733738f18d8f895854b453640ec9 # v3.5.0 with: inputs: >- ./dist/*.tar.gz @@ -81,10 +85,11 @@ jobs: - name: Upload artifact signatures to GitHub Release env: GITHUB_TOKEN: ${{ github.token }} + NEEDS_RELEASE_PLEASE_OUTPUTS_TAG_NAME: ${{ needs.release-please.outputs.tag_name }} # Upload to GitHub Release using the `gh` CLI. # `dist/` contains the built packages, and the # sigstore-produced signatures and certificates. run: >- gh release upload - ${{ needs.release-please.outputs.tag_name }} dist/** + ${NEEDS_RELEASE_PLEASE_OUTPUTS_TAG_NAME} dist/** --repo '${{ github.repository }}' diff --git a/gyp/.release-please-manifest.json b/gyp/.release-please-manifest.json index 762fc35f4c..b78500f8e2 100644 --- a/gyp/.release-please-manifest.json +++ b/gyp/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.22.2" + ".": "0.22.3" } diff --git a/gyp/CHANGELOG.md b/gyp/CHANGELOG.md index c6686c4784..e590b6fdb8 100644 --- a/gyp/CHANGELOG.md +++ b/gyp/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [0.22.3](https://github.com/nodejs/gyp-next/compare/v0.22.2...v0.22.3) (2026-09-29) + + +### Bug Fixes + +* add Python 3.15 beta to the testing ([#344](https://github.com/nodejs/gyp-next/issues/344)) ([bb6522f](https://github.com/nodejs/gyp-next/commit/bb6522fbacc620da2cc382484d75c75ee35d780c)) +* **ci:** add zizmor security linter for github actions ([#358](https://github.com/nodejs/gyp-next/issues/358)) ([3d4c42b](https://github.com/nodejs/gyp-next/commit/3d4c42b386582df54368c29fcd7c3121737451a2)) +* **ci:** enable Python 3.15 release candidate on Windows ([#357](https://github.com/nodejs/gyp-next/issues/357)) ([e2080d2](https://github.com/nodejs/gyp-next/commit/e2080d25c31a0c1f08178a52802be7fd56848376)) +* **ci:** test on npm@12 ([#359](https://github.com/nodejs/gyp-next/issues/359)) ([1729f6e](https://github.com/nodejs/gyp-next/commit/1729f6e3bf8071d95cda85129cdf4ebab0a877ef)) +* **ci:** update ruff github aactio to v4.0.0 ([#348](https://github.com/nodejs/gyp-next/issues/348)) ([8d213cd](https://github.com/nodejs/gyp-next/commit/8d213cd35cec96e91dc98359ccd247404f71f27b)) +* **cmake:** add a dummy source to libraries without sources ([#362](https://github.com/nodejs/gyp-next/issues/362)) ([391165e](https://github.com/nodejs/gyp-next/commit/391165e76f682a318216b8b5c6ca1de0ef5f8f24)) +* **cmake:** require CMake 3.10 and quote custom command comments ([#361](https://github.com/nodejs/gyp-next/issues/361)) ([b418211](https://github.com/nodejs/gyp-next/commit/b418211c49705c0fb42177b666c140cf96d0149f)) +* write pch cflags as a list instead of a map object ([#355](https://github.com/nodejs/gyp-next/issues/355)) ([fe8188c](https://github.com/nodejs/gyp-next/commit/fe8188c6af0cf53488960b0ec655b1dcc01a7c94)) + ## [0.22.2](https://github.com/nodejs/gyp-next/compare/v0.22.1...v0.22.2) (2026-04-22) diff --git a/gyp/README.md b/gyp/README.md index 6360a6c334..9f8b1e6119 100644 --- a/gyp/README.md +++ b/gyp/README.md @@ -11,7 +11,7 @@ When used as a command line utility, __gyp-next__ can also be installed with [pi * `uv tool install gyp-next` ``` Installing to a new venv 'gyp-next' - installed package gyp-next 0.13.0, installed using Python 3.10.6 + installed package gyp-next 0.13.0, installed using Python 3.14.7 These apps are now globally available - gyp done! ✨ 🌟 ✨ diff --git a/gyp/commitlint.config.js b/gyp/commitlint.config.js new file mode 100644 index 0000000000..c7a07938b9 --- /dev/null +++ b/gyp/commitlint.config.js @@ -0,0 +1,6 @@ +export default { + extends: ['@commitlint/config-conventional'], + rules: { + 'body-max-line-length': [0, 'always'], + }, +}; diff --git a/gyp/pylib/gyp/generator/cmake.py b/gyp/pylib/gyp/generator/cmake.py index dc9ea39acb..1028272a41 100644 --- a/gyp/pylib/gyp/generator/cmake.py +++ b/gyp/pylib/gyp/generator/cmake.py @@ -304,12 +304,9 @@ def WriteActions(target_name, actions, extra_sources, extra_deps, path_to_gyp, o output.write(path_to_gyp) output.write("\n") - output.write(" COMMENT ") - if "message" in action: - output.write(action["message"]) - else: - output.write(action_target_name) - output.write("\n") + output.write(' COMMENT "') + output.write(CMakeStringEscape(action.get("message", action_target_name))) + output.write('"\n') output.write(" VERBATIM\n") output.write(")\n") @@ -415,12 +412,9 @@ def WriteRules(target_name, rules, extra_sources, extra_deps, path_to_gyp, outpu output.write(path_to_gyp) output.write("\n") - output.write(" COMMENT ") - if "message" in rule: - output.write(rule["message"]) - else: - output.write(action_name) - output.write("\n") + output.write(' COMMENT "') + output.write(CMakeStringEscape(rule.get("message", action_name))) + output.write('"\n') output.write(" VERBATIM\n") output.write(")\n") @@ -537,9 +531,9 @@ def __init__(self, ext, command): output.write(path_to_gyp) output.write("\n") - output.write("COMMENT Copying for ") - output.write(target_name) - output.write("\n") + output.write('COMMENT "Copying for ') + output.write(CMakeStringEscape(target_name)) + output.write('"\n') output.write("VERBATIM\n") output.write(")\n") @@ -779,8 +773,10 @@ def WriteTarget( other_sources_name = cmake_target_name + "__other_srcs" SetVariableList(output, other_sources_name, other_sources) - # CMake gets upset when executable targets provide no sources. + # CMake gets upset when executable or library targets provide no sources. # http://www.cmake.org/pipermail/cmake/2010-July/038461.html + # Libraries without sources are used to aggregate dependencies; build an + # empty library for them, as the make generator does. dummy_sources_name = None has_sources = ( s_sources_name @@ -789,7 +785,7 @@ def WriteTarget( or linkable_sources_name or other_sources_name ) - if target_type == "executable" and not has_sources: + if target_type != "none" and not has_sources: dummy_sources_name = cmake_target_name + "__dummy_srcs" SetVariable( output, dummy_sources_name, "${obj}.${TOOLSET}/${TARGET}/genc/dummy.c" @@ -1160,8 +1156,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_to_u gyp.common.EnsureDirExists(output_file) output = open(output_file, "w") - output.write("cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)\n") - output.write("cmake_policy(VERSION 2.8.8)\n") + output.write("cmake_minimum_required(VERSION 3.10)\n") gyp_file, project_target, _ = gyp.common.ParseQualifiedTarget(target_list[-1]) output.write("project(") diff --git a/gyp/pylib/gyp/generator/cmake_test.py b/gyp/pylib/gyp/generator/cmake_test.py new file mode 100644 index 0000000000..fe45cd6d92 --- /dev/null +++ b/gyp/pylib/gyp/generator/cmake_test.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 + +"""Unit tests for the cmake.py file.""" + +import io +import types +import unittest + +from gyp.generator import cmake + + +class TestCustomCommandComment(unittest.TestCase): + def test_ActionMessageIsQuotedAndEscaped(self): + output = io.StringIO() + action = { + "action_name": "gen", + "inputs": ["in.txt"], + "outputs": ["out.txt"], + "action": ["python", "gen.py"], + "message": 'Generating "out.txt"; (see #1)', + } + cmake.WriteActions("tgt", [action], [], [], ".", output) + self.assertIn( + ' COMMENT "Generating \\"out.txt\\"\\; (see #1)"\n', output.getvalue() + ) + + def test_ActionWithoutMessageUsesTargetName(self): + output = io.StringIO() + action = { + "action_name": "gen", + "inputs": [], + "outputs": ["out.txt"], + "action": ["python", "gen.py"], + } + cmake.WriteActions("tgt", [action], [], [], ".", output) + self.assertIn(' COMMENT "tgt__gen"\n', output.getvalue()) + + def test_RuleMessageKeepsVariableReferences(self): + output = io.StringIO() + rule = { + "rule_name": "compile", + "outputs": ["${RULE_INPUT_ROOT}.o"], + "action": ["cc", "${RULE_INPUT_PATH}"], + "rule_sources": ["foo.c"], + "message": "Compiling ${RULE_INPUT_NAME}", + } + cmake.WriteRules("tgt", [rule], [], [], ".", output) + self.assertIn(' COMMENT "Compiling ${RULE_INPUT_NAME}"\n', output.getvalue()) + + def test_CopiesMessageIsQuoted(self): + output = io.StringIO() + copies = [{"files": ["a.txt"], "destination": "out"}] + cmake.WriteCopies("tgt", copies, [], ".", output) + self.assertIn('COMMENT "Copying for tgt"\n', output.getvalue()) + + +class TestTargetWithoutSources(unittest.TestCase): + def _WriteTarget(self, target_type, sources=()): + qualified_target = "foo.gyp:foo#target" + spec = { + "target_name": "foo", + "type": target_type, + "toolset": "target", + "sources": list(sources), + } + output = io.StringIO() + cmake.WriteTarget( + cmake.CMakeNamer([qualified_target]), + qualified_target, + {qualified_target: spec}, + "out/Default", + "Default", + types.SimpleNamespace(toplevel_dir="."), + {}, + [qualified_target], + "linux", + output, + ) + return output.getvalue() + + def test_DummySourceForEmptyTargets(self): + for target_type, add_target in ( + ("executable", "add_executable(foo"), + ("static_library", "add_library(foo STATIC"), + ("shared_library", "add_library(foo SHARED"), + ("loadable_module", "add_library(foo MODULE"), + ): + with self.subTest(target_type=target_type): + output = self._WriteTarget(target_type) + self.assertIn(' file(WRITE "${foo__dummy_srcs}" "")\n', output) + self.assertIn(add_target + " ${foo__dummy_srcs})\n", output) + + def test_NoDummySourceForLibraryWithSources(self): + output = self._WriteTarget("static_library", ["foo.c"]) + self.assertIn("add_library(foo STATIC ${foo__c_srcs})\n", output) + self.assertNotIn("dummy", output) + + def test_NoDummySourceForNoneTarget(self): + output = self._WriteTarget("none") + self.assertIn("add_custom_target(foo SOURCES)\n", output) + self.assertNotIn("dummy", output) + + +if __name__ == "__main__": + unittest.main() diff --git a/gyp/pylib/gyp/msvs_emulation.py b/gyp/pylib/gyp/msvs_emulation.py index f1c1581981..84e0b4f327 100644 --- a/gyp/pylib/gyp/msvs_emulation.py +++ b/gyp/pylib/gyp/msvs_emulation.py @@ -1057,13 +1057,18 @@ def GetFlagsModifications( pch_output = ["/Yc" + self._PchHeader()] if command == "cxx": return ( - [("cflags_cc", map(expand_special, cflags_cc + pch_output))], + [ + ( + "cflags_cc", + [expand_special(x) for x in cflags_cc + pch_output], + ) + ], self.output_obj, [], ) elif command == "cc": return ( - [("cflags_c", map(expand_special, cflags_c + pch_output))], + [("cflags_c", [expand_special(x) for x in cflags_c + pch_output])], self.output_obj, [], ) diff --git a/gyp/pyproject.toml b/gyp/pyproject.toml index 487cb75002..9ce52a6785 100644 --- a/gyp/pyproject.toml +++ b/gyp/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "gyp-next" -version = "0.22.2" +version = "0.22.3" authors = [ { name="Node.js contributors", email="ryzokuken@disroot.org" }, ] From 12c6842965b2f6b0297832c1177e62946528b7ac Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Wed, 30 Sep 2026 14:08:22 +0800 Subject: [PATCH 3/3] chore: ignore vendored gyp directory in eslint --- eslint.config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eslint.config.js b/eslint.config.js index 5212dc93d5..18c8964e1f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,3 +1,6 @@ 'use strict' -module.exports = require('neostandard')({}) +module.exports = require('neostandard')({ + // gyp/ is vendored from gyp-next and follows its own style + ignores: ['gyp/**'] +})