Skip to content

Commit 81c10d4

Browse files
committed
fix: use the default version on Ubuntu, Fedora, Arch, macOS, etc.
1 parent 324effb commit 81c10d4

File tree

3 files changed

+39
-30
lines changed

3 files changed

+39
-30
lines changed

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ignorePaths:
1111
- "**/node_modules/"
1212
- .vscode/extensions.json
1313
- patches/*.patch
14+
- "**/github_brechtsanders_winlibs_mingw.json"
1415
words:
1516
- aarch
1617
- aminya

src/gcc/gcc.ts

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,44 @@ export async function setupGcc(version: string, setupDir: string, arch: string,
110110
{ name: "libstdc++-devel" },
111111
])
112112
} else if (isUbuntu()) {
113-
installationInfo = await installAptPack([
114-
{
115-
name: "gcc",
116-
version,
117-
repository: "ppa:ubuntu-toolchain-r/test",
118-
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
119-
},
120-
{
121-
name: "g++",
122-
version,
123-
repository: "ppa:ubuntu-toolchain-r/test",
124-
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
125-
},
126-
])
113+
if (version === undefined) {
114+
// the default version
115+
installationInfo = await installAptPack([{ name: "gcc" }, { name: "g++" }])
116+
} else {
117+
// add the PPA for access to more versions
118+
installationInfo = await installAptPack([
119+
{
120+
name: "gcc",
121+
version,
122+
repository: "ppa:ubuntu-toolchain-r/test",
123+
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
124+
},
125+
{
126+
name: "g++",
127+
version,
128+
repository: "ppa:ubuntu-toolchain-r/test",
129+
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
130+
},
131+
])
132+
}
127133
}
128134
} else {
129135
info(`Install g++-multilib because gcc for ${arch} was requested`)
130136
if (isArch()) {
131137
await setupPacmanPack("gcc-multilib", version)
132138
} else if (isUbuntu()) {
133-
await installAptPack([{
134-
name: "gcc-multilib",
135-
version,
136-
repository: "ppa:ubuntu-toolchain-r/test",
137-
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
138-
}])
139+
if (version === undefined) {
140+
// the default version
141+
await installAptPack([{ name: "gcc-multilib" }])
142+
} else {
143+
// add the PPA for access to more versions
144+
await installAptPack([{
145+
name: "gcc-multilib",
146+
version,
147+
repository: "ppa:ubuntu-toolchain-r/test",
148+
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
149+
}])
150+
}
139151
}
140152
}
141153
break

src/versions/default_versions.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { isArch } from "../utils/env/isArch.js"
2+
import { isUbuntu } from "../utils/env/isUbuntu.js"
23

34
// passing "" to a tool installed by a package manager (apt, brew, choco) will result in the default version of that package manager.
45
// the directly downloaded tools require a given version ("" doesn't work).
@@ -30,8 +31,10 @@ export const DefaultVersions: Record<string, string | undefined> = {
3031
kcov: "42", // https://github.com/SimonKagstrom/kcov/releases
3132
task: "3.38.0", // https://github.com/go-task/task/releases
3233
doxygen: isArch() ? "1.11.0-4" : "1.11.0", // https://www.doxygen.nl/download.html // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen // https://formulae.brew.sh/formula/doxygen // https://archlinux.org/packages/extra/x86_64/doxygen/
33-
gcc: isArch() ? "13.2.1-3" : "13", // https://github.com/brechtsanders/winlibs_mingw/releases and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
34-
// mingw: isArch() ? "12.2.0-1" : "8", // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=mingw-w64 // https://archlinux.org/packages/extra/x86_64/mingw-w64-gcc/
34+
gcc: process.platform === "win32"
35+
? "13"
36+
: undefined, // use the default version on Ubuntu, Fedora, Arch, macOS, etc.
37+
// mingw: isArch() ? "12.2.0-1" : "8", // https://archlinux.org/packages/extra/x86_64/mingw-w64-gcc/
3538
powershell: "7.4.5", // https://github.com/PowerShell/PowerShell/releases/tag/v7.4.5
3639
}
3740

@@ -44,14 +47,7 @@ export const MinVersions: Record<string, string | undefined> = {
4447
// - the newer ubuntu versions use the first entry (e.g. v20),
4548
// - the older ones use ""
4649
export const DefaultLinuxVersion: Record<string, Record<number, string> | undefined> = {
47-
gcc: {
48-
24: "13",
49-
22: "13",
50-
20: "11",
51-
18: "11",
52-
16: "11",
53-
14: "11",
54-
},
50+
// https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=mingw-w64
5551
mingw: {
5652
24: "8.0.0-1",
5753
22: "8.0.0-1",

0 commit comments

Comments
 (0)