Skip to content

Commit bdff7f7

Browse files
committed
refactor: add setupChocoMingw
1 parent 1c4d0a4 commit bdff7f7

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/gcc/gcc.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,7 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
1919
if (arch === "arm" || arch === "arm64") {
2020
await setupChocoPack("gcc-arm-embedded", version)
2121
}
22-
await setupChocoPack("mingw", version)
23-
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
24-
binDir = "C:/tools/mingw64/bin"
25-
await addPath(binDir)
26-
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
27-
binDir = "C:/tools/mingw32/bin"
28-
await addPath(binDir)
29-
} else if (existsSync(`${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin/g++.exe`)) {
30-
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
31-
}
22+
binDir = await setupChocoMingw(version, arch)
3223
break
3324
}
3425
case "darwin": {
@@ -68,6 +59,21 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
6859
return undefined
6960
}
7061

62+
async function setupChocoMingw(version: string, arch: string) {
63+
await setupChocoPack("mingw", version)
64+
let binDir: string | undefined
65+
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
66+
binDir = "C:/tools/mingw64/bin"
67+
await addPath(binDir)
68+
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
69+
binDir = "C:/tools/mingw32/bin"
70+
await addPath(binDir)
71+
} else if (existsSync(`${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin/g++.exe`)) {
72+
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
73+
}
74+
return binDir
75+
}
76+
7177
async function activateGcc(version: string, binDir: string) {
7278
const promises: Promise<void>[] = []
7379
// Setup gcc as the compiler

0 commit comments

Comments
 (0)