From 4676a0b1d37a938c4cde589a63beb3c57bf0ef71 Mon Sep 17 00:00:00 2001 From: Jiawen Geng Date: Sun, 24 Oct 2021 09:43:10 +0000 Subject: [PATCH] feat: support vs2022 --- .github/workflows/tests.yml | 25 ++----------------- .github/workflows/windows.yml | 45 +++++++++++++++++++++++++++++++++++ lib/find-visualstudio.js | 14 ++++++++++- 3 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f7c9b979e3..9c6be2ecee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,4 @@ -# TODO: Line 43, enable pytest --doctest-modules - -name: Tests +name: Tests on Windows on: [push, pull_request] jobs: Tests: @@ -8,23 +6,11 @@ jobs: fail-fast: false max-parallel: 15 matrix: - node: [12.x, 14.x, 16.x] - python: ["3.6", "3.8", "3.10"] - os: [macos-latest, ubuntu-latest, windows-latest] + os: [windows-2022] runs-on: ${{ matrix.os }} steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - - name: Use Python ${{ matrix.python }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - env: - PYTHON_VERSION: ${{ matrix.python }} - name: Install Dependencies run: | npm install --no-progress @@ -34,12 +20,5 @@ jobs: run: | echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV - - name: Lint Python - if: matrix.os == 'ubuntu-latest' - run: flake8 . --ignore=E203,W503 --max-complexity=101 --max-line-length=88 --show-source --statistics - - name: Run Python tests - run: python -m pytest - # - name: Run doctests with pytest - # run: python -m pytest --doctest-modules - name: Run Node tests run: npm test diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000000..f7c9b979e3 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,45 @@ +# TODO: Line 43, enable pytest --doctest-modules + +name: Tests +on: [push, pull_request] +jobs: + Tests: + strategy: + fail-fast: false + max-parallel: 15 + matrix: + node: [12.x, 14.x, 16.x] + python: ["3.6", "3.8", "3.10"] + os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - name: Use Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + env: + PYTHON_VERSION: ${{ matrix.python }} + - name: Install Dependencies + run: | + npm install --no-progress + pip install flake8 pytest + - name: Set Windows environment + if: matrix.os == 'windows-latest' + run: | + echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV + echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV + - name: Lint Python + if: matrix.os == 'ubuntu-latest' + run: flake8 . --ignore=E203,W503 --max-complexity=101 --max-line-length=88 --show-source --statistics + - name: Run Python tests + run: python -m pytest + # - name: Run doctests with pytest + # run: python -m pytest --doctest-modules + - name: Run Node tests + run: npm test diff --git a/lib/find-visualstudio.js b/lib/find-visualstudio.js index f2cce327e7..64af7be346 100644 --- a/lib/find-visualstudio.js +++ b/lib/find-visualstudio.js @@ -2,6 +2,7 @@ const log = require('npmlog') const execFile = require('child_process').execFile +const fs = require('fs') const path = require('path').win32 const logWithPrefix = require('./util').logWithPrefix const regSearchKeys = require('./util').regSearchKeys @@ -257,6 +258,10 @@ VisualStudioFinder.prototype = { ret.versionYear = 2019 return ret } + if (ret.versionMajor === 17) { + ret.versionYear = 2022 + return ret + } this.log.silly('- unsupported version:', ret.versionMajor) return {} }, @@ -264,15 +269,20 @@ VisualStudioFinder.prototype = { // Helper - process MSBuild information getMSBuild: function getMSBuild (info, versionYear) { const pkg = 'Microsoft.VisualStudio.VC.MSBuild.Base' + const msbuildPath = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe') if (info.packages.indexOf(pkg) !== -1) { this.log.silly('- found VC.MSBuild.Base') if (versionYear === 2017) { return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe') } if (versionYear === 2019) { - return path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe') + return msbuildPath } } + // visual studio 2022 don't has msbuild pkg + if (fs.existsSync(msbuildPath)) { + return msbuildPath + } return null }, @@ -293,6 +303,8 @@ VisualStudioFinder.prototype = { return 'v141' } else if (versionYear === 2019) { return 'v142' + } else if (versionYear === 2022) { + return 'v143' } this.log.silly('- invalid versionYear:', versionYear) return null