mirror of
https://github.com/ilammy/msvc-dev-cmd.git
synced 2026-09-06 21:57:19 +08:00
Enable other editions of msvc (#4)
I'll probably use self hosted runners in a project and the Community version of Visual Studio will be installed on those. This enables the script to check for Community and Professional editions in addition to the Entreprise one offered by GitHub. The modification generates a kinda search map ordered by version then by edition. It generates the batch script that runs vcvarsall.bat on the fly given that search map.
This commit is contained in:
@@ -5,8 +5,8 @@ const os = require('os')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const process = require('process')
|
const process = require('process')
|
||||||
|
|
||||||
const MSVS_2017 = '%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Auxiliary\\Build'
|
const EDITIONS = ['Enterprise', 'Professional', 'Community']
|
||||||
const MSVS_2019 = '%ProgramFiles(x86)%\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build'
|
const VERSIONS = ['2019', '2017']
|
||||||
|
|
||||||
const InterestingVariables = [
|
const InterestingVariables = [
|
||||||
'INCLUDE',
|
'INCLUDE',
|
||||||
@@ -26,6 +26,26 @@ async function main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this should generate an array like
|
||||||
|
// [
|
||||||
|
// ['P2017', 'path\to\2017\Professional...'],
|
||||||
|
// ['C2017', 'path\to\2017\Entreprise...'],
|
||||||
|
// etc...
|
||||||
|
// [
|
||||||
|
// Given the order of each list it should check
|
||||||
|
// for the more recent versions first and the
|
||||||
|
// highest grade edition first.
|
||||||
|
var search_map = []
|
||||||
|
|
||||||
|
VERSIONS.forEach(ver => {
|
||||||
|
EDITIONS.forEach(ed => {
|
||||||
|
let label = ed.charAt(0) + ver
|
||||||
|
let path = `%ProgramFiles(x86)%\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat`
|
||||||
|
|
||||||
|
search_map.push([label, path])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
const arch = core.getInput('arch')
|
const arch = core.getInput('arch')
|
||||||
const sdk = core.getInput('sdk')
|
const sdk = core.getInput('sdk')
|
||||||
const toolset = core.getInput('toolset')
|
const toolset = core.getInput('toolset')
|
||||||
@@ -53,22 +73,29 @@ async function main() {
|
|||||||
}
|
}
|
||||||
core.debug(`Arguments: ${args.join(' ')}`)
|
core.debug(`Arguments: ${args.join(' ')}`)
|
||||||
|
|
||||||
|
var script = '';
|
||||||
|
|
||||||
|
search_map.forEach(pair => {
|
||||||
|
script += `@IF EXIST "${pair[1]}" GOTO :${pair[0]}\n`
|
||||||
|
})
|
||||||
|
|
||||||
|
script += `@ECHO "Microsoft Visual Studio not found"\n
|
||||||
|
@EXIT 1\n`
|
||||||
|
|
||||||
|
search_map.forEach(pair => {
|
||||||
|
script += `:${pair[0]}\n
|
||||||
|
@CALL "${pair[1]}" ${args.join(' ')}\n
|
||||||
|
@GOTO ENV\n`
|
||||||
|
})
|
||||||
|
|
||||||
|
script += `:ENV\n
|
||||||
|
@IF ERRORLEVEL 1 EXIT\n
|
||||||
|
@SET`
|
||||||
|
|
||||||
|
core.debug(script)
|
||||||
|
|
||||||
core.debug(`Writing helper file: ${helper}`)
|
core.debug(`Writing helper file: ${helper}`)
|
||||||
await fs.writeFile(helper, `
|
await fs.writeFile(helper, script)
|
||||||
@IF EXIST "${MSVS_2017}\\vcvarsall.bat" GOTO :2017
|
|
||||||
@IF EXIST "${MSVS_2019}\\vcvarsall.bat" GOTO :2019
|
|
||||||
@ECHO "Microsoft Visual Studio not found"
|
|
||||||
@EXIT 1
|
|
||||||
:2017
|
|
||||||
@CALL "${MSVS_2017}\\vcvarsall.bat" ${args.join(' ')}
|
|
||||||
@GOTO ENV
|
|
||||||
:2019
|
|
||||||
@CALL "${MSVS_2019}\\vcvarsall.bat" ${args.join(' ')}
|
|
||||||
@GOTO ENV
|
|
||||||
:ENV
|
|
||||||
@IF ERRORLEVEL 1 EXIT
|
|
||||||
@SET
|
|
||||||
`)
|
|
||||||
|
|
||||||
var environment
|
var environment
|
||||||
try {
|
try {
|
||||||
@@ -98,4 +125,4 @@ async function main() {
|
|||||||
core.info(`Configured Developer Command Prompt`)
|
core.info(`Configured Developer Command Prompt`)
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(() => core.setFailed('Could not setup Developer Command Prompt'))
|
main().catch((e) => core.setFailed('Could not setup Developer Command Prompt: ' + e.message))
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "msvc-dev-cmd",
|
"name": "msvc-dev-cmd",
|
||||||
"version": "1.0.0",
|
"version": "1.1.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user