fix: support activation of old gcc

This commit is contained in:
Amin Yahyaabadi 2021-12-07 06:16:31 -06:00
parent fa01e81c02
commit 9d3670c0fb
3 changed files with 23 additions and 9 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

@ -34,20 +34,30 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
} }
case "linux": { case "linux": {
if (arch === "x64") { if (arch === "x64") {
await setupAptPack("gcc", version, [
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
"ppa:ubuntu-toolchain-r/test",
])
binDir = ( binDir = (
await setupAptPack("g++", version, [ await setupAptPack("g++", version, [
"ppa:ubuntu-toolchain-r/test",
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'", "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'", "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
"ppa:ubuntu-toolchain-r/test",
]) ])
).binDir ).binDir
} else { } else {
info(`Install g++-multilib because gcc for ${arch} was requested`) info(`Install g++-multilib because gcc for ${arch} was requested`)
await setupAptPack("gcc-multilib", version, [
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
"ppa:ubuntu-toolchain-r/test",
])
binDir = ( binDir = (
await setupAptPack("g++-multilib", version, [ await setupAptPack("g++-multilib", version, [
"ppa:ubuntu-toolchain-r/test",
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'", "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'", "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
"ppa:ubuntu-toolchain-r/test",
]) ])
).binDir ).binDir
} }
@ -58,9 +68,9 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
// case "none": { // case "none": {
// if (arch === "arm" || arch === "arm64") { // if (arch === "arm" || arch === "arm64") {
// return setupAptPack("gcc-arm-none-eabi", version, [ // return setupAptPack("gcc-arm-none-eabi", version, [
// "ppa:ubuntu-toolchain-r/test",
// "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'", // "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
// "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'", // "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
// "ppa:ubuntu-toolchain-r/test",
// ]) // ])
// } else { // } else {
// throw new Error(`Unsupported platform for ${arch}`) // throw new Error(`Unsupported platform for ${arch}`)
@ -78,8 +88,6 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
} }
async function activateGcc(version: string, binDir: string) { async function activateGcc(version: string, binDir: string) {
const majorVersion = semverMajor(semverCoerce(version) ?? version)
// TODO // TODO
// const ld = process.env.LD_LIBRARY_PATH ?? "" // const ld = process.env.LD_LIBRARY_PATH ?? ""
// const dyld = process.env.DYLD_LIBRARY_PATH ?? "" // const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
@ -93,8 +101,14 @@ async function activateGcc(version: string, binDir: string) {
exportVariable("CC", `${binDir}/gcc`) exportVariable("CC", `${binDir}/gcc`)
exportVariable("CXX", `${binDir}/g++`) exportVariable("CXX", `${binDir}/g++`)
} else { } else {
exportVariable("CC", `${binDir}/gcc-${majorVersion}`) const majorVersion = semverMajor(semverCoerce(version) ?? version)
exportVariable("CXX", `${binDir}/g++-${majorVersion}`) if (majorVersion >= 5) {
exportVariable("CC", `${binDir}/gcc-${majorVersion}`)
exportVariable("CXX", `${binDir}/g++-${majorVersion}`)
} else {
exportVariable("CC", `${binDir}/gcc-${version}`)
exportVariable("CXX", `${binDir}/g++-${version}`)
}
} }
await setupMacOSSDK() await setupMacOSSDK()