Skip to content

Commit

Permalink
feat: support vs2022
Browse files Browse the repository at this point in the history
  • Loading branch information
gengjiawen committed Oct 24, 2021
1 parent fb85fb2 commit 4676a0b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 24 deletions.
25 changes: 2 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
# TODO: Line 43, enable pytest --doctest-modules

name: Tests
name: Tests on Windows
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]
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
Expand All @@ -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
45 changes: 45 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 13 additions & 1 deletion lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -257,22 +258,31 @@ VisualStudioFinder.prototype = {
ret.versionYear = 2019
return ret
}
if (ret.versionMajor === 17) {
ret.versionYear = 2022
return ret
}
this.log.silly('- unsupported version:', ret.versionMajor)
return {}
},

// 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
},

Expand All @@ -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
Expand Down

0 comments on commit 4676a0b

Please sign in to comment.