refactor: add setupChocoMingw

This commit is contained in:
Amin Yahyaabadi 2022-05-20 15:19:19 -07:00
parent 1c4d0a479b
commit bdff7f7943
3 changed files with 18 additions and 12 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -19,16 +19,7 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
if (arch === "arm" || arch === "arm64") {
await setupChocoPack("gcc-arm-embedded", version)
}
await setupChocoPack("mingw", version)
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
binDir = "C:/tools/mingw64/bin"
await addPath(binDir)
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
binDir = "C:/tools/mingw32/bin"
await addPath(binDir)
} else if (existsSync(`${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin/g++.exe`)) {
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
}
binDir = await setupChocoMingw(version, arch)
break
}
case "darwin": {
@ -68,6 +59,21 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
return undefined
}
async function setupChocoMingw(version: string, arch: string) {
await setupChocoPack("mingw", version)
let binDir: string | undefined
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
binDir = "C:/tools/mingw64/bin"
await addPath(binDir)
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
binDir = "C:/tools/mingw32/bin"
await addPath(binDir)
} else if (existsSync(`${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin/g++.exe`)) {
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
}
return binDir
}
async function activateGcc(version: string, binDir: string) {
const promises: Promise<void>[] = []
// Setup gcc as the compiler