mirror of https://github.com/aminya/setup-cpp
Merge pull request #25 from aminya/vs2022 [skip ci]
This commit is contained in:
commit
c56c0d924a
|
@ -15,6 +15,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
|
- windows-2022
|
||||||
- windows-2019
|
- windows-2019
|
||||||
- ubuntu-20.04
|
- ubuntu-20.04
|
||||||
- macos-10.15
|
- macos-10.15
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,4 @@
|
||||||
const DefaultVersions: Record<string, string> = {
|
const DefaultVersions: Record<string, string> = {
|
||||||
msvc: "2019",
|
|
||||||
vcvarsall: "2019",
|
|
||||||
llvm: "13.0.0",
|
llvm: "13.0.0",
|
||||||
clangtidy: "13.0.0",
|
clangtidy: "13.0.0",
|
||||||
clangformat: "13.0.0",
|
clangformat: "13.0.0",
|
||||||
|
|
14
src/main.ts
14
src/main.ts
|
@ -160,11 +160,7 @@ export async function main(args: string[]): Promise<number> {
|
||||||
case "llvm":
|
case "llvm":
|
||||||
case "clang":
|
case "clang":
|
||||||
case "clang++": {
|
case "clang++": {
|
||||||
const installationInfo = await setupLLVM(
|
const installationInfo = await setupLLVM(getVersion("llvm", version), join(setupCppDir, "llvm"), arch)
|
||||||
getVersion("llvm", version) as string,
|
|
||||||
join(setupCppDir, "llvm"),
|
|
||||||
arch
|
|
||||||
)
|
|
||||||
successMessages.push(getSuccessMessage("llvm", installationInfo))
|
successMessages.push(getSuccessMessage("llvm", installationInfo))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -172,7 +168,7 @@ export async function main(args: string[]): Promise<number> {
|
||||||
case "mingw":
|
case "mingw":
|
||||||
case "cygwin":
|
case "cygwin":
|
||||||
case "msys": {
|
case "msys": {
|
||||||
const installationInfo = await setupGcc(getVersion("gcc", version) as string, join(setupCppDir, "gcc"), arch)
|
const installationInfo = await setupGcc(getVersion("gcc", version), join(setupCppDir, "gcc"), arch)
|
||||||
successMessages.push(getSuccessMessage("gcc", installationInfo))
|
successMessages.push(getSuccessMessage("gcc", installationInfo))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -183,11 +179,7 @@ export async function main(args: string[]): Promise<number> {
|
||||||
case "visualstudio":
|
case "visualstudio":
|
||||||
case "visualcpp":
|
case "visualcpp":
|
||||||
case "visualc++": {
|
case "visualc++": {
|
||||||
const installationInfo = await setupMSVC(
|
const installationInfo = setupMSVC(getVersion("msvc", version), join(setupCppDir, "msvc"), arch)
|
||||||
getVersion("msvc", version) as string,
|
|
||||||
join(setupCppDir, "msvc"),
|
|
||||||
arch
|
|
||||||
)
|
|
||||||
successMessages.push(getSuccessMessage("msvc", installationInfo))
|
successMessages.push(getSuccessMessage("msvc", installationInfo))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,67 @@
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
|
||||||
import { setupMSVC } from "../msvc"
|
import { setupMSVC } from "../msvc"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
describe("setup-msvc", () => {
|
describe("setup-msvc", () => {
|
||||||
it("should setup msvc 2019", async () => {
|
it("should setup the pre-installed msvc", () => {
|
||||||
try {
|
try {
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await setupMSVC("2019", "", process.arch)
|
setupMSVC("", "", process.arch)
|
||||||
await testBin("cl", [])
|
console.log(which.sync("cl"))
|
||||||
console.log(which("cl"))
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// TODO
|
// TODO
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup msvc 2017", async () => {
|
it("should setup msvc 2022", () => {
|
||||||
try {
|
try {
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await setupMSVC("2017", "", process.arch)
|
setupMSVC("2022", "", process.arch)
|
||||||
await testBin("cl", [])
|
console.log(which.sync("cl"))
|
||||||
console.log(which("cl"))
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// TODO
|
// TODO
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup msvc 2015", async () => {
|
it("should setup msvc 2019", () => {
|
||||||
try {
|
try {
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await setupMSVC("2015", "", process.arch)
|
setupMSVC("2019", "", process.arch)
|
||||||
await testBin("cl", [])
|
console.log(which.sync("cl"))
|
||||||
console.log(which("cl"))
|
} catch (e) {
|
||||||
|
// TODO
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should setup msvc 2017", () => {
|
||||||
|
try {
|
||||||
|
if (process.platform !== "win32") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setupMSVC("2017", "", process.arch)
|
||||||
|
console.log(which.sync("cl"))
|
||||||
|
} catch (e) {
|
||||||
|
// TODO
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should setup msvc 2015", () => {
|
||||||
|
try {
|
||||||
|
if (process.platform !== "win32") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setupMSVC("2015", "", process.arch)
|
||||||
|
console.log(which.sync("cl"))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// TODO
|
// TODO
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import { error } from "@actions/core"
|
import { error, info } from "@actions/core"
|
||||||
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
|
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -7,24 +7,26 @@ import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
|
||||||
|
|
||||||
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
|
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
|
||||||
|
|
||||||
export async function setupMSVC(
|
export function setupMSVC(
|
||||||
versionGiven: MSVCVersion,
|
versionGiven: MSVCVersion,
|
||||||
_setupDir: string,
|
_setupDir: string,
|
||||||
arch: string,
|
arch: string,
|
||||||
sdk?: string,
|
sdk?: string,
|
||||||
uwp?: boolean,
|
uwp?: boolean,
|
||||||
spectre?: boolean
|
spectre?: boolean
|
||||||
): Promise<void> {
|
) {
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const version = vsversion_to_versionnumber(versionGiven) as string
|
const version = vsversion_to_versionnumber(versionGiven) as string
|
||||||
|
|
||||||
// check if the given version is already installed
|
// check if the given version is already installed
|
||||||
|
info(`Checking if MSVC ${version} is already installed`)
|
||||||
let installed = false
|
let installed = false
|
||||||
try {
|
try {
|
||||||
findVcvarsall(version)
|
const path = findVcvarsall(version) as string
|
||||||
installed = true
|
installed = true
|
||||||
|
info(`Found the pre-installed version of MSVC at ${path}`)
|
||||||
} catch {
|
} catch {
|
||||||
// not installed, try installing
|
// not installed, try installing
|
||||||
}
|
}
|
||||||
|
@ -32,31 +34,31 @@ export async function setupMSVC(
|
||||||
let toolset: string | undefined
|
let toolset: string | undefined
|
||||||
let VCTargetsPath: string | undefined
|
let VCTargetsPath: string | undefined
|
||||||
// https://github.com/aminya/setup-cpp/issues/1
|
// https://github.com/aminya/setup-cpp/issues/1
|
||||||
|
if (!installed) {
|
||||||
try {
|
try {
|
||||||
if (version === "14.0") {
|
if (version === "14.0") {
|
||||||
toolset = "14.0"
|
toolset = "14.0"
|
||||||
if (!installed) {
|
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 === "15.0") {
|
} else if (version === "15.0") {
|
||||||
toolset = "14.16"
|
toolset = "14.16"
|
||||||
if (!installed) {
|
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 === "16.0") {
|
} else if (version === "16.0") {
|
||||||
toolset = "14.29"
|
toolset = "14.29"
|
||||||
if (!installed) {
|
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 if (version === "17.0") {
|
||||||
|
toolset = undefined
|
||||||
|
setupChocoPack("visualstudio2022buildtools", "117.0.5.0", [])
|
||||||
|
VCTargetsPath = undefined
|
||||||
} else {
|
} else {
|
||||||
error(`The given MSVC versions ${versionGiven} is not supported yet.`)
|
error(`The given MSVC versions ${versionGiven} is not supported yet.`)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error(e as string | Error)
|
error(e as string | Error)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// run vcvarsall.bat environment variables
|
// run vcvarsall.bat environment variables
|
||||||
setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,13 @@ export function setupChocoPack(name: string, version?: string, args: string[] =
|
||||||
env.PATH = PATH
|
env.PATH = PATH
|
||||||
|
|
||||||
if (version !== undefined && version !== "") {
|
if (version !== undefined && version !== "") {
|
||||||
execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args], { env, extendEnv: false })
|
execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args], {
|
||||||
|
env,
|
||||||
|
extendEnv: false,
|
||||||
|
stdio: "inherit",
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
execa.sync("choco", ["install", "-y", name, ...args], { env, extendEnv: false })
|
execa.sync("choco", ["install", "-y", name, ...args], { env, extendEnv: false, stdio: "inherit" })
|
||||||
}
|
}
|
||||||
|
|
||||||
const binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
|
const binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
|
||||||
|
|
|
@ -26,7 +26,9 @@ export async function setupPipPack(name: string, version?: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
execa.sync(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name])
|
execa.sync(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name], {
|
||||||
|
stdio: "inherit",
|
||||||
|
})
|
||||||
|
|
||||||
if (binDir === undefined) {
|
if (binDir === undefined) {
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
|
|
Loading…
Reference in New Issue