mirror of https://github.com/aminya/setup-cpp
feat: support setting up a specific msvc version
This commit is contained in:
parent
487a88259f
commit
3b5817d13d
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -36,7 +36,7 @@
|
||||||
"execa": "^5.1.1",
|
"execa": "^5.1.1",
|
||||||
"hasha": "^5.2.2",
|
"hasha": "^5.2.2",
|
||||||
"mri": "^1.2.0",
|
"mri": "^1.2.0",
|
||||||
"msvc-dev-cmd": " https://github.com/ilammy/msvc-dev-cmd",
|
"msvc-dev-cmd": " https://github.com/aminya/msvc-dev-cmd",
|
||||||
"semver": "^7.3.5",
|
"semver": "^7.3.5",
|
||||||
"setup-python": "https://github.com/actions/setup-python",
|
"setup-python": "https://github.com/actions/setup-python",
|
||||||
"untildify": "^4.0.0",
|
"untildify": "^4.0.0",
|
||||||
|
|
|
@ -22,7 +22,7 @@ specifiers:
|
||||||
hasha: ^5.2.2
|
hasha: ^5.2.2
|
||||||
jest: ^27.4.2
|
jest: ^27.4.2
|
||||||
mri: ^1.2.0
|
mri: ^1.2.0
|
||||||
msvc-dev-cmd: ' https://github.com/ilammy/msvc-dev-cmd'
|
msvc-dev-cmd: ' https://github.com/aminya/msvc-dev-cmd'
|
||||||
npm-run-all2: ^5.0.2
|
npm-run-all2: ^5.0.2
|
||||||
parcel: ^2.0.1
|
parcel: ^2.0.1
|
||||||
prettier-config-atomic: ^3.0.1
|
prettier-config-atomic: ^3.0.1
|
||||||
|
@ -43,7 +43,7 @@ dependencies:
|
||||||
execa: 5.1.1
|
execa: 5.1.1
|
||||||
hasha: 5.2.2
|
hasha: 5.2.2
|
||||||
mri: 1.2.0
|
mri: 1.2.0
|
||||||
msvc-dev-cmd: github.com/ilammy/msvc-dev-cmd/9f8ae839b01883414208f29e3e24524387f48e1f
|
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/dba5a20a9276e1a268337d014d486be27b98d66a
|
||||||
semver: 7.3.5
|
semver: 7.3.5
|
||||||
setup-python: github.com/actions/setup-python/f38219332975fe8f9c04cca981d674bf22aea1d3
|
setup-python: github.com/actions/setup-python/f38219332975fe8f9c04cca981d674bf22aea1d3
|
||||||
untildify: 4.0.0
|
untildify: 4.0.0
|
||||||
|
@ -8619,6 +8619,14 @@ packages:
|
||||||
semver: 7.3.5
|
semver: 7.3.5
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
github.com/aminya/msvc-dev-cmd/dba5a20a9276e1a268337d014d486be27b98d66a:
|
||||||
|
resolution: {tarball: https://codeload.github.com/aminya/msvc-dev-cmd/tar.gz/dba5a20a9276e1a268337d014d486be27b98d66a}
|
||||||
|
name: msvc-dev-cmd
|
||||||
|
version: 1.1.1
|
||||||
|
dependencies:
|
||||||
|
'@actions/core': 1.6.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
github.com/aminya/sort-package-json/076051b58be7b198732d1ce2b9a415ccd0c63a97:
|
github.com/aminya/sort-package-json/076051b58be7b198732d1ce2b9a415ccd0c63a97:
|
||||||
resolution: {tarball: https://codeload.github.com/aminya/sort-package-json/tar.gz/076051b58be7b198732d1ce2b9a415ccd0c63a97}
|
resolution: {tarball: https://codeload.github.com/aminya/sort-package-json/tar.gz/076051b58be7b198732d1ce2b9a415ccd0c63a97}
|
||||||
name: sort-package-json
|
name: sort-package-json
|
||||||
|
@ -8632,11 +8640,3 @@ packages:
|
||||||
is-plain-obj: 2.1.0
|
is-plain-obj: 2.1.0
|
||||||
sort-object-keys: 1.1.3
|
sort-object-keys: 1.1.3
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
github.com/ilammy/msvc-dev-cmd/9f8ae839b01883414208f29e3e24524387f48e1f:
|
|
||||||
resolution: {tarball: https://codeload.github.com/ilammy/msvc-dev-cmd/tar.gz/9f8ae839b01883414208f29e3e24524387f48e1f}
|
|
||||||
name: msvc-dev-cmd
|
|
||||||
version: 1.1.1
|
|
||||||
dependencies:
|
|
||||||
'@actions/core': 1.6.0
|
|
||||||
dev: false
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const DefaultVersions: Record<string, string> = {
|
const DefaultVersions: Record<string, string> = {
|
||||||
msvc: "2019",
|
msvc: "2019",
|
||||||
|
vcvarsall: "2019",
|
||||||
llvm: "13.0.0",
|
llvm: "13.0.0",
|
||||||
ninja: "1.10.2",
|
ninja: "1.10.2",
|
||||||
cmake: "3.22.0",
|
cmake: "3.22.0",
|
||||||
|
|
|
@ -114,17 +114,16 @@ export async function main(args: string[]): Promise<number> {
|
||||||
|
|
||||||
// skip if undefined
|
// skip if undefined
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
// get the setup function
|
|
||||||
const setupFunction = setups[tool]
|
|
||||||
|
|
||||||
// running the setup function for this tool
|
// running the setup function for this tool
|
||||||
try {
|
try {
|
||||||
let installationInfo: InstallationInfo | undefined | void
|
let installationInfo: InstallationInfo | undefined | void
|
||||||
if (tool === "vcvarsall") {
|
if (tool === "vcvarsall") {
|
||||||
// TODO expose the options
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
;(setupFunction as typeof setupVCVarsall)(undefined, arch, undefined, undefined, false, false)
|
setupVCVarsall(getVersion(tool, value), undefined, arch, undefined, undefined, false, false)
|
||||||
} else {
|
} else {
|
||||||
|
// get the setup function
|
||||||
|
const setupFunction = setups[tool]
|
||||||
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
installationInfo = await setupFunction(getVersion(tool, value), join(setupCppDir, tool), arch)
|
installationInfo = await setupFunction(getVersion(tool, value), join(setupCppDir, tool), arch)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import { error } from "@actions/core"
|
import { error } from "@actions/core"
|
||||||
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
|
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
import { vsversion_to_versionnumber } from "msvc-dev-cmd/lib.js"
|
||||||
|
|
||||||
type MSVCVersion = "2015" | "2017" | "2019" | string
|
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
|
||||||
|
|
||||||
export async function setupMSVC(
|
export async function setupMSVC(
|
||||||
version: MSVCVersion,
|
versionGiven: MSVCVersion,
|
||||||
_setupDir: string,
|
_setupDir: string,
|
||||||
arch: string,
|
arch: string,
|
||||||
sdk?: string,
|
sdk?: string,
|
||||||
|
@ -15,23 +18,27 @@ export async function setupMSVC(
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const version = vsversion_to_versionnumber(versionGiven) as string
|
||||||
|
|
||||||
let toolset: string | undefined
|
let toolset: string | undefined
|
||||||
let VCTargetsPath: string | undefined
|
let VCTargetsPath: string | undefined
|
||||||
// TODO enable this code path once its bugs are fixed
|
// TODO enable this code path once its bugs are fixed
|
||||||
// https://github.com/aminya/setup-cpp/issues/1
|
// https://github.com/aminya/setup-cpp/issues/1
|
||||||
try {
|
try {
|
||||||
if (version === "2015") {
|
if (version === "14.0") {
|
||||||
toolset = "14.0"
|
toolset = "14.0"
|
||||||
await setupChocoPack("visualcpp-build-tools", "14.0.25420.1", ["--ignore-dependencies"])
|
await setupChocoPack("visualcpp-build-tools", "14.0.25420.1", ["--ignore-dependencies"])
|
||||||
VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140"
|
VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140"
|
||||||
} else if (version === "2017") {
|
} else if (version === "15.0") {
|
||||||
toolset = "14.16"
|
toolset = "14.16"
|
||||||
await setupChocoPack("visualstudio2017buildtools", "15.9.41.0", [])
|
await setupChocoPack("visualstudio2017buildtools", "15.9.41.0", [])
|
||||||
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path
|
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path
|
||||||
} else if (version === "2019") {
|
} else if (version === "16.0") {
|
||||||
toolset = "14.29"
|
toolset = "14.29"
|
||||||
await setupChocoPack("visualstudio2019buildtools", "16.11.7.0", [])
|
await setupChocoPack("visualstudio2019buildtools", "16.11.7.0", [])
|
||||||
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133"
|
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133"
|
||||||
|
} else {
|
||||||
|
error(`The given MSVC versions ${versionGiven} is not supported yet.`)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (
|
if (
|
||||||
|
@ -43,5 +50,5 @@ export async function setupMSVC(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// run vcvarsall.bat environment variables
|
// run vcvarsall.bat environment variables
|
||||||
setupVCVarsall(VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import { exportVariable, info } from "@actions/core"
|
import { exportVariable, info } from "@actions/core"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
import { setupMSVCDevCmd } from "msvc-dev-cmd/lib.js"
|
||||||
|
|
||||||
function getArch(arch: string): string {
|
function getArch(arch: string): string {
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
|
@ -18,6 +21,7 @@ function getArch(arch: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setupVCVarsall(
|
export function setupVCVarsall(
|
||||||
|
vsversion: string,
|
||||||
VCTargetsPath: string | undefined,
|
VCTargetsPath: string | undefined,
|
||||||
arch: string,
|
arch: string,
|
||||||
toolset: string | undefined,
|
toolset: string | undefined,
|
||||||
|
@ -30,8 +34,5 @@ export function setupVCVarsall(
|
||||||
exportVariable("VCTargetsPath", VCTargetsPath)
|
exportVariable("VCTargetsPath", VCTargetsPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// lazy load the action so it is not executed
|
setupMSVCDevCmd(getArch(arch), sdk, toolset, uwp, spectre, vsversion)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const { setupMSVCDevCmd } = require("msvc-dev-cmd/index")
|
|
||||||
setupMSVCDevCmd(getArch(arch), sdk, toolset, uwp, spectre)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue