From dfa252d03019135ab10d68fbe81ae6b14a77a14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 30 Aug 2021 16:53:08 +0200 Subject: [PATCH 1/3] tools: update gyp-next to v0.10.0 --- tools/gyp/.github/workflows/Python_tests.yml | 2 +- tools/gyp/CHANGELOG.md | 15 +++++++++++++ tools/gyp/pylib/gyp/MSVSVersion.py | 17 ++++++++++++++- tools/gyp/pylib/gyp/generator/msvs.py | 23 +++++++++++++++----- tools/gyp/pylib/gyp/msvs_emulation.py | 4 ++-- tools/gyp/setup.py | 2 +- 6 files changed, 52 insertions(+), 11 deletions(-) diff --git a/tools/gyp/.github/workflows/Python_tests.yml b/tools/gyp/.github/workflows/Python_tests.yml index 649251c8dd05f5..92303b635f2cfa 100644 --- a/tools/gyp/.github/workflows/Python_tests.yml +++ b/tools/gyp/.github/workflows/Python_tests.yml @@ -23,7 +23,7 @@ jobs: python -m pip install --upgrade pip pip install -r requirements_dev.txt - name: Lint with flake8 - run: flake8 . --count --show-source --statistics + run: flake8 . --ignore=E203,W503 --max-complexity=101 --max-line-length=88 --show-source --statistics - name: Test with pytest run: pytest # - name: Run doctests with pytest diff --git a/tools/gyp/CHANGELOG.md b/tools/gyp/CHANGELOG.md index 141da1f589a3ec..b7d55ed65551b6 100644 --- a/tools/gyp/CHANGELOG.md +++ b/tools/gyp/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [0.10.0](https://www.github.com/nodejs/gyp-next/compare/v0.9.6...v0.10.0) (2021-08-26) + + +### Features + +* **msvs:** add support for Visual Studio 2022 ([#124](https://www.github.com/nodejs/gyp-next/issues/124)) ([4bd9215](https://www.github.com/nodejs/gyp-next/commit/4bd9215c44d300f06e916aec1d6327c22b78272d)) + +### [0.9.6](https://www.github.com/nodejs/gyp-next/compare/v0.9.5...v0.9.6) (2021-08-23) + + +### Bug Fixes + +* align flake8 test ([#122](https://www.github.com/nodejs/gyp-next/issues/122)) ([f1faa8d](https://www.github.com/nodejs/gyp-next/commit/f1faa8d3081e1a47e917ff910892f00dff16cf8a)) +* **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)) + ### [0.9.5](https://www.github.com/nodejs/gyp-next/compare/v0.9.4...v0.9.5) (2021-08-18) diff --git a/tools/gyp/pylib/gyp/MSVSVersion.py b/tools/gyp/pylib/gyp/MSVSVersion.py index 134b35557b5224..8d7f21e82dd2f8 100644 --- a/tools/gyp/pylib/gyp/MSVSVersion.py +++ b/tools/gyp/pylib/gyp/MSVSVersion.py @@ -269,6 +269,18 @@ def _CreateVersion(name, path, sdk_based=False): if path: path = os.path.normpath(path) versions = { + "2022": VisualStudioVersion( + "2022", + "Visual Studio 2022", + solution_version="12.00", + project_version="17.0", + flat_sln=False, + uses_vcxproj=True, + path=path, + sdk_based=sdk_based, + default_toolset="v143", + compatible_sdks=["v8.1", "v10.0"], + ), "2019": VisualStudioVersion( "2019", "Visual Studio 2019", @@ -436,6 +448,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express): 2015 - Visual Studio 2015 (14) 2017 - Visual Studio 2017 (15) 2019 - Visual Studio 2019 (16) + 2022 - Visual Studio 2022 (17) Where (e) is e for express editions of MSVS and blank otherwise. """ version_to_year = { @@ -447,6 +460,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express): "14.0": "2015", "15.0": "2017", "16.0": "2019", + "17.0": "2022", } versions = [] for version in versions_to_check: @@ -522,7 +536,7 @@ def SelectVisualStudioVersion(version="auto", allow_fallback=True): if version == "auto": version = os.environ.get("GYP_MSVS_VERSION", "auto") version_map = { - "auto": ("16.0", "15.0", "14.0", "12.0", "10.0", "9.0", "8.0", "11.0"), + "auto": ("17.0", "16.0", "15.0", "14.0", "12.0", "10.0", "9.0", "8.0", "11.0"), "2005": ("8.0",), "2005e": ("8.0",), "2008": ("9.0",), @@ -536,6 +550,7 @@ def SelectVisualStudioVersion(version="auto", allow_fallback=True): "2015": ("14.0",), "2017": ("15.0",), "2019": ("16.0",), + "2022": ("17.0",), } override_path = os.environ.get("GYP_MSVS_OVERRIDE_PATH") if override_path: diff --git a/tools/gyp/pylib/gyp/generator/msvs.py b/tools/gyp/pylib/gyp/generator/msvs.py index 31d5396fe56978..8308fa8433352c 100644 --- a/tools/gyp/pylib/gyp/generator/msvs.py +++ b/tools/gyp/pylib/gyp/generator/msvs.py @@ -152,7 +152,7 @@ def _NormalizedSource(source): return source -def _FixPath(path): +def _FixPath(path, separator="\\"): """Convert paths to a form that will make sense in a vcproj file. Arguments: @@ -168,9 +168,12 @@ def _FixPath(path): and not _IsWindowsAbsPath(path) ): path = os.path.join(fixpath_prefix, path) - path = path.replace("/", "\\") + if separator == "\\": + path = path.replace("/", "\\") path = _NormalizedSource(path) - if path and path[-1] == "\\": + if separator == "/": + path = path.replace("\\", "/") + if path and path[-1] == separator: path = path[:-1] return path @@ -185,9 +188,9 @@ def _IsWindowsAbsPath(path): return path.startswith("c:") or path.startswith("C:") -def _FixPaths(paths): +def _FixPaths(paths, separator="\\"): """Fix each of the paths of the list.""" - return [_FixPath(i) for i in paths] + return [_FixPath(i, separator) for i in paths] def _ConvertSourcesToFilterHierarchy( @@ -418,7 +421,15 @@ def _BuildCommandLineForRuleRaw( # file out of the raw command string, and some commands (like python) are # actually batch files themselves. command.insert(0, "call") - arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in cmd[1:]] + # Fix the paths + # TODO(quote): This is a really ugly heuristic, and will miss path fixing + # for arguments like "--arg=path" or "/opt:path". + # If the argument starts with a slash or dash, it's probably a command line + # switch + # Return the path with forward slashes because the command using it might + # not support backslashes. + arguments = [i if (i[:1] in "/-") else _FixPath(i, "/") for i in cmd[1:]] + arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in arguments] arguments = [MSVSSettings.FixVCMacroSlashes(i) for i in arguments] if quote_cmd: # Support a mode for using cmd directly. diff --git a/tools/gyp/pylib/gyp/msvs_emulation.py b/tools/gyp/pylib/gyp/msvs_emulation.py index 2d289dcb47f467..5b9c2712e091b4 100644 --- a/tools/gyp/pylib/gyp/msvs_emulation.py +++ b/tools/gyp/pylib/gyp/msvs_emulation.py @@ -74,8 +74,8 @@ def EncodeRspFileList(args, quote_cmd): program = call + " " + os.path.normpath(program) else: program = os.path.normpath(args[0]) - return (program + " " + - " ".join(QuoteForRspFile(arg, quote_cmd) for arg in args[1:])) + return (program + " " + + " ".join(QuoteForRspFile(arg, quote_cmd) for arg in args[1:])) def _GenericRetrieve(root, default, path): diff --git a/tools/gyp/setup.py b/tools/gyp/setup.py index 51c6b057378858..cf9d7d2e56c49f 100644 --- a/tools/gyp/setup.py +++ b/tools/gyp/setup.py @@ -15,7 +15,7 @@ setup( name="gyp-next", - version="0.9.5", + version="0.10.0", 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", From 37a7972f02b5ee11a6879c38225d6c261f9a134c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 24 Aug 2021 07:52:36 +0200 Subject: [PATCH 2/3] build: add support for Visual Studio 2022 --- vcbuild.bat | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/vcbuild.bat b/vcbuild.bat index 56f27111d91f0e..a91ee9b64c20f0 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -82,6 +82,7 @@ if /i "%1"=="x86" set target_arch=x86&goto arg-ok if /i "%1"=="x64" set target_arch=x64&goto arg-ok if /i "%1"=="arm64" set target_arch=arm64&goto arg-ok if /i "%1"=="vs2019" set target_env=vs2019&goto arg-ok +if /i "%1"=="vs2022" set target_env=vs2022&goto arg-ok if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok if /i "%1"=="projgen" set projgen=1&goto arg-ok if /i "%1"=="nobuild" set nobuild=1&goto arg-ok @@ -176,6 +177,7 @@ set "node_exe=%config%\node.exe" set "node_gyp_exe="%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp" set "npm_exe="%~dp0%node_exe%" %~dp0deps\npm\bin\npm-cli.js" if "%target_env%"=="vs2019" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2019" +if "%target_env%"=="vs2022" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2022" :: skip building if the only argument received was lint if "%*"=="lint" if exist "%node_exe%" goto lint-cpp @@ -239,6 +241,46 @@ if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64 @rem also if both are x86 if %target_arch%==x86 if %msvs_host_arch%==x86 set vcvarsall_arg=x86 +@rem Look for Visual Studio 2022 +:vs-set-2022 +if defined target_env if "%target_env%" NEQ "vs2022" goto vs-set-2019 +echo Looking for Visual Studio 2022 +@rem VCINSTALLDIR may be set if run from a VS Command Prompt and needs to be +@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to +@rem detect the version searched for +if not defined target_env set "VCINSTALLDIR=" +call tools\msvs\vswhere_usability_wrapper.cmd "[17.0,18.0)" "prerelease" +if "_%VCINSTALLDIR%_" == "__" goto vs-set-2019 +set "WIXSDKDIR=%WIX%\SDK\VS2017" +if defined msi ( + echo Looking for WiX installation for Visual Studio 2022... + if not exist "%WIXSDKDIR%" ( + echo Failed to find WiX install for Visual Studio 2022 + echo VS2022 support for WiX is only present starting at version 3.XX + goto vs-set-2019 + ) + if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" ( + echo Failed to find the WiX Toolset Visual Studio 2022 Extension + goto vs-set-2019 + ) +) +@rem check if VS2022 is already setup, and for the requested arch +if "_%VisualStudioVersion%_" == "_17.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2022 +@rem need to clear VSINSTALLDIR for vcvarsall to work as expected +set "VSINSTALLDIR=" +@rem prevent VsDevCmd.bat from changing the current working directory +set "VSCMD_START_DIR=%CD%" +set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg% +echo calling: %vcvars_call% +call %vcvars_call% +if errorlevel 1 goto vs-set-2019 +if defined DEBUG_HELPER @ECHO ON +:found_vs2022 +echo Found MSVS version %VisualStudioVersion% +set GYP_MSVS_VERSION=2022 +set PLATFORM_TOOLSET=v143 +goto msbuild-found + @rem Look for Visual Studio 2019 :vs-set-2019 if defined target_env if "%target_env%" NEQ "vs2019" goto msbuild-not-found @@ -691,7 +733,7 @@ set exit_code=1 goto exit :help -echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-benchmark/test-internet/test-pummel/test-simple/test-message/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [ltcg] [licensetf] [sign] [ia32/x86/x64/arm64] [vs2019] [download-all] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm] +echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-benchmark/test-internet/test-pummel/test-simple/test-message/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [ltcg] [licensetf] [sign] [ia32/x86/x64/arm64] [vs2019/vs2022] [download-all] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm] echo Examples: echo vcbuild.bat : builds release build echo vcbuild.bat debug : builds debug build From 364cea34d36228d1e27d9b84bf277c3343a55102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 24 Aug 2021 07:56:43 +0200 Subject: [PATCH 3/3] build: add windows-2022 to GitHub test matrix --- .github/workflows/build-windows.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 1b0b336f4b8273..d489de708d130b 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -18,7 +18,11 @@ env: jobs: build-windows: if: github.event.pull_request.draft == false - runs-on: windows-latest + strategy: + matrix: + windows: [windows-2019, windows-2022] + fail-fast: false + runs-on: ${{ matrix.windows }} steps: - uses: actions/checkout@v2 - name: Set up Python ${{ env.PYTHON_VERSION }}