Skip to content

Commit

Permalink
fix: use the default version on Ubuntu, Fedora, Arch, macOS, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 3, 2024
1 parent 324effb commit 81c10d4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 30 deletions.
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ignorePaths:
- "**/node_modules/"
- .vscode/extensions.json
- patches/*.patch
- "**/github_brechtsanders_winlibs_mingw.json"
words:
- aarch
- aminya
Expand Down
52 changes: 32 additions & 20 deletions src/gcc/gcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,44 @@ export async function setupGcc(version: string, setupDir: string, arch: string,
{ name: "libstdc++-devel" },
])
} else if (isUbuntu()) {
installationInfo = await installAptPack([
{
name: "gcc",
version,
repository: "ppa:ubuntu-toolchain-r/test",
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
},
{
name: "g++",
version,
repository: "ppa:ubuntu-toolchain-r/test",
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
},
])
if (version === undefined) {
// the default version
installationInfo = await installAptPack([{ name: "gcc" }, { name: "g++" }])
} else {
// add the PPA for access to more versions
installationInfo = await installAptPack([
{
name: "gcc",
version,
repository: "ppa:ubuntu-toolchain-r/test",
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
},
{
name: "g++",
version,
repository: "ppa:ubuntu-toolchain-r/test",
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
},
])
}
}
} else {
info(`Install g++-multilib because gcc for ${arch} was requested`)
if (isArch()) {
await setupPacmanPack("gcc-multilib", version)
} else if (isUbuntu()) {
await installAptPack([{
name: "gcc-multilib",
version,
repository: "ppa:ubuntu-toolchain-r/test",
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
}])
if (version === undefined) {
// the default version
await installAptPack([{ name: "gcc-multilib" }])
} else {
// add the PPA for access to more versions
await installAptPack([{
name: "gcc-multilib",
version,
repository: "ppa:ubuntu-toolchain-r/test",
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
}])
}
}
}
break
Expand Down
16 changes: 6 additions & 10 deletions src/versions/default_versions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js"

// passing "" to a tool installed by a package manager (apt, brew, choco) will result in the default version of that package manager.
// the directly downloaded tools require a given version ("" doesn't work).
Expand Down Expand Up @@ -30,8 +31,10 @@ export const DefaultVersions: Record<string, string | undefined> = {
kcov: "42", // https://github.com/SimonKagstrom/kcov/releases
task: "3.38.0", // https://github.com/go-task/task/releases
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/
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
// 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/
gcc: process.platform === "win32"
? "13"
: undefined, // use the default version on Ubuntu, Fedora, Arch, macOS, etc.
// mingw: isArch() ? "12.2.0-1" : "8", // https://archlinux.org/packages/extra/x86_64/mingw-w64-gcc/
powershell: "7.4.5", // https://github.com/PowerShell/PowerShell/releases/tag/v7.4.5
}

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

0 comments on commit 81c10d4

Please sign in to comment.