mirror of
https://github.com/ilammy/msvc-dev-cmd.git
synced 2026-09-07 06:07:19 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d8610e2b41 | |||
| 9f8ae839b0 | |||
| bb050e7771 | |||
| f456b805b3 | |||
| 74a501b087 | |||
| af5661e514 | |||
| 7defe92547 | |||
| e78ece9a2a | |||
| 62f16bb530 | |||
| 985d494a0f | |||
| c5426bf30a | |||
| 100402d805 |
@@ -18,6 +18,8 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Download Internet
|
- name: Download Internet
|
||||||
run: npm install
|
run: npm install
|
||||||
|
- name: Run eslint
|
||||||
|
run: npm run lint
|
||||||
- name: Enable Developer Command Prompt (amd64)
|
- name: Enable Developer Command Prompt (amd64)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -56,12 +58,13 @@ jobs:
|
|||||||
dumpbin /headers hello.exe
|
dumpbin /headers hello.exe
|
||||||
audit:
|
audit:
|
||||||
name: npm audit
|
name: npm audit
|
||||||
runs-on: windows-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source code
|
- name: Check out source code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm audit --audit-level=moderate
|
- run: npm audit --audit-level=moderate --production
|
||||||
|
- run: npm audit --audit-level=critical
|
||||||
alias-arch:
|
alias-arch:
|
||||||
name: arch aliases
|
name: arch aliases
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ jobs:
|
|||||||
hello.exe
|
hello.exe
|
||||||
audit:
|
audit:
|
||||||
name: npm audit
|
name: npm audit
|
||||||
runs-on: windows-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source code
|
- name: Check out source code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- run: npm audit --audit-level=moderate
|
- run: npm audit --audit-level=moderate --production
|
||||||
|
- run: npm audit --audit-level=critical
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ jobs:
|
|||||||
|
|
||||||
- `arch` – target architecture
|
- `arch` – target architecture
|
||||||
- native compilation:
|
- native compilation:
|
||||||
- `x64` (default) or its synonyms: `amd64`, `win64`
|
- `x64` (default) or its synonyms: `amd64`, `win64`, `x86_64`, `x86-64`
|
||||||
- `x86` or its synonyms: `win32`
|
- `x86` or its synonyms: `win32`
|
||||||
- cross-compilation: `x86_amd64`, `x86_arm`, `x86_arm64`, `amd64_x86`, `amd64_arm`, `amd64_arm64`
|
- cross-compilation: `x86_amd64`, `x86_arm`, `x86_arm64`, `amd64_x86`, `amd64_arm`, `amd64_arm64`
|
||||||
- `sdk` – Windows SDK to use
|
- `sdk` – Windows SDK to use
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ const path = require('path')
|
|||||||
const process = require('process')
|
const process = require('process')
|
||||||
|
|
||||||
const PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)']
|
const PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)']
|
||||||
|
const PROGRAM_FILES = [process.env['ProgramFiles(x86)'], process.env['ProgramFiles']]
|
||||||
|
|
||||||
|
|
||||||
const EDITIONS = ['Enterprise', 'Professional', 'Community']
|
const EDITIONS = ['Enterprise', 'Professional', 'Community']
|
||||||
const VERSIONS = ['2019', '2017']
|
const VERSIONS = ['2022', '2019', '2017']
|
||||||
|
|
||||||
const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer`
|
const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer`
|
||||||
|
|
||||||
@@ -32,9 +34,10 @@ function findVcvarsall() {
|
|||||||
|
|
||||||
// If that does not work, try the standard installation locations,
|
// If that does not work, try the standard installation locations,
|
||||||
// starting with the latest and moving to the oldest.
|
// starting with the latest and moving to the oldest.
|
||||||
|
for (const prog_files of PROGRAM_FILES) {
|
||||||
for (const ver of VERSIONS) {
|
for (const ver of VERSIONS) {
|
||||||
for (const ed of EDITIONS) {
|
for (const ed of EDITIONS) {
|
||||||
path = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat`
|
path = `${prog_files}\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat`
|
||||||
core.info(`Trying standard location: ${path}`)
|
core.info(`Trying standard location: ${path}`)
|
||||||
if (fs.existsSync(path)) {
|
if (fs.existsSync(path)) {
|
||||||
core.info(`Found standard location: ${path}`)
|
core.info(`Found standard location: ${path}`)
|
||||||
@@ -42,6 +45,7 @@ function findVcvarsall() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
core.info("Not found in standard locations")
|
core.info("Not found in standard locations")
|
||||||
|
|
||||||
// Special case for Visual Studio 2015 (and maybe earlier), try it out too.
|
// Special case for Visual Studio 2015 (and maybe earlier), try it out too.
|
||||||
@@ -70,7 +74,8 @@ function filterPathValue(path) {
|
|||||||
return paths.filter(unique).join(';')
|
return paths.filter(unique).join(';')
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
/** See https://github.com/ilammy/msvc-dev-cmd#inputs */
|
||||||
|
function setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre) {
|
||||||
if (process.platform != 'win32') {
|
if (process.platform != 'win32') {
|
||||||
core.info('This is not a Windows virtual environment, bye!')
|
core.info('This is not a Windows virtual environment, bye!')
|
||||||
return
|
return
|
||||||
@@ -79,17 +84,13 @@ function main() {
|
|||||||
// Add standard location of "vswhere" to PATH, in case it's not there.
|
// Add standard location of "vswhere" to PATH, in case it's not there.
|
||||||
process.env.PATH += path.delimiter + VSWHERE_PATH
|
process.env.PATH += path.delimiter + VSWHERE_PATH
|
||||||
|
|
||||||
var arch = core.getInput('arch')
|
|
||||||
const sdk = core.getInput('sdk')
|
|
||||||
const toolset = core.getInput('toolset')
|
|
||||||
const uwp = core.getInput('uwp')
|
|
||||||
const spectre = core.getInput('spectre')
|
|
||||||
|
|
||||||
// There are all sorts of way the architectures are called. In addition to
|
// There are all sorts of way the architectures are called. In addition to
|
||||||
// values supported by Microsoft Visual C++, recognize some common aliases.
|
// values supported by Microsoft Visual C++, recognize some common aliases.
|
||||||
let arch_aliases = {
|
let arch_aliases = {
|
||||||
"win32": "x86",
|
"win32": "x86",
|
||||||
"win64": "x64",
|
"win64": "x64",
|
||||||
|
"x86_64": "x64",
|
||||||
|
"x86-64": "x64",
|
||||||
}
|
}
|
||||||
// Ignore case when matching as that's what humans expect.
|
// Ignore case when matching as that's what humans expect.
|
||||||
if (arch.toLowerCase() in arch_aliases) {
|
if (arch.toLowerCase() in arch_aliases) {
|
||||||
@@ -116,25 +117,27 @@ function main() {
|
|||||||
const vcvars = `"${findVcvarsall()}" ${args.join(' ')}`
|
const vcvars = `"${findVcvarsall()}" ${args.join(' ')}`
|
||||||
core.debug(`vcvars command-line: ${vcvars}`)
|
core.debug(`vcvars command-line: ${vcvars}`)
|
||||||
|
|
||||||
const old_environment = child_process.execSync(`set`, {shell: "cmd"}).toString().split('\r\n')
|
const cmd_output_string = child_process.execSync(`set && cls && ${vcvars} && cls && set`, {shell: "cmd"}).toString()
|
||||||
const new_environment = child_process.execSync(`${vcvars} && set`, {shell: "cmd"}).toString().split('\r\n')
|
const cmd_output_parts = cmd_output_string.split('\f')
|
||||||
|
|
||||||
|
const old_environment = cmd_output_parts[0].split('\r\n')
|
||||||
|
const vcvars_output = cmd_output_parts[1].split('\r\n')
|
||||||
|
const new_environment = cmd_output_parts[2].split('\r\n')
|
||||||
|
|
||||||
// If vsvars.bat is given an incorrect command line, it will print out
|
// If vsvars.bat is given an incorrect command line, it will print out
|
||||||
// an error and *still* exit successfully. Parse out errors from output
|
// an error and *still* exit successfully. Parse out errors from output
|
||||||
// which don't look like environment variables, and fail if appropriate.
|
// which don't look like environment variables, and fail if appropriate.
|
||||||
var failed = false
|
const error_messages = vcvars_output.filter((line) => {
|
||||||
for (let line of new_environment) {
|
|
||||||
if (line.match(/^\[ERROR.*\]/)) {
|
if (line.match(/^\[ERROR.*\]/)) {
|
||||||
failed = true
|
|
||||||
// Don't print this particular line which will be confusing in output.
|
// Don't print this particular line which will be confusing in output.
|
||||||
if (line.match(/Error in script usage. The correct usage is:$/)) {
|
if (!line.match(/Error in script usage. The correct usage is:$/)) {
|
||||||
continue
|
return true
|
||||||
}
|
|
||||||
core.error(line)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failed) {
|
return false
|
||||||
throw new Error('invalid parameters')
|
})
|
||||||
|
if (error_messages.length > 0) {
|
||||||
|
throw new Error('invalid parameters' + '\r\n' + error_messages.join('\r\n'))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert old environment lines into a dictionary for easier lookup.
|
// Convert old environment lines into a dictionary for easier lookup.
|
||||||
@@ -173,6 +176,17 @@ function main() {
|
|||||||
|
|
||||||
core.info(`Configured Developer Command Prompt`)
|
core.info(`Configured Developer Command Prompt`)
|
||||||
}
|
}
|
||||||
|
exports.setupMSVCDevCmd = setupMSVCDevCmd
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
var arch = core.getInput('arch')
|
||||||
|
const sdk = core.getInput('sdk')
|
||||||
|
const toolset = core.getInput('toolset')
|
||||||
|
const uwp = core.getInput('uwp')
|
||||||
|
const spectre = core.getInput('spectre')
|
||||||
|
|
||||||
|
setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
main()
|
main()
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "msvc-dev-cmd",
|
||||||
|
"version": "1.10.0",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/@actions/core": {
|
||||||
|
"version": "1.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
||||||
|
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
-45
@@ -1,40 +1,16 @@
|
|||||||
{
|
{
|
||||||
"_args": [
|
|
||||||
[
|
|
||||||
"@actions/core@1.2.6",
|
|
||||||
"/Users/ilammy/Documents/dev/ilammy/msvc-dev-cmd"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "@actions/core@1.2.6",
|
|
||||||
"_id": "@actions/core@1.2.6",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==",
|
|
||||||
"_location": "/@actions/core",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/core@1.2.6",
|
|
||||||
"name": "@actions/core",
|
"name": "@actions/core",
|
||||||
"escapedName": "@actions%2fcore",
|
"version": "1.2.6",
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "1.2.6",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.2.6"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
|
||||||
"_spec": "1.2.6",
|
|
||||||
"_where": "/Users/ilammy/Documents/dev/ilammy/msvc-dev-cmd",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"description": "Actions core lib",
|
"description": "Actions core lib",
|
||||||
"devDependencies": {
|
"keywords": [
|
||||||
"@types/node": "^12.0.2"
|
"github",
|
||||||
},
|
"actions",
|
||||||
|
"core"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/core",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/core.js",
|
||||||
|
"types": "lib/core.d.ts",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "lib",
|
||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
@@ -43,15 +19,6 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"!.DS_Store"
|
"!.DS_Store"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/main/packages/core",
|
|
||||||
"keywords": [
|
|
||||||
"github",
|
|
||||||
"actions",
|
|
||||||
"core"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/core.js",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -65,6 +32,10 @@
|
|||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"types": "lib/core.d.ts",
|
"bugs": {
|
||||||
"version": "1.2.6"
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^12.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+951
-1112
File diff suppressed because it is too large
Load Diff
+3
-4
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "msvc-dev-cmd",
|
"name": "msvc-dev-cmd",
|
||||||
"version": "1.8.0",
|
"version": "1.10.0",
|
||||||
"description": "GitHub Action to setup Developer Command Prompt for Microsoft Visual C++",
|
"description": "GitHub Action to setup Developer Command Prompt for Microsoft Visual C++",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint index.js",
|
"lint": "eslint index.js"
|
||||||
"test": "eslint index.js"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -31,6 +30,6 @@
|
|||||||
"@actions/core": "^1.2"
|
"@actions/core": "^1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^6.8.0"
|
"eslint": "^7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user