mirror of https://github.com/aminya/setup-cpp
fix: add env variables in parallel for llvm and gcc
This commit is contained in:
parent
777ee3fd6d
commit
c8f6527003
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -68,48 +68,52 @@ 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 promises: Promise<void>[] = []
|
||||||
|
// Setup gcc as the compiler
|
||||||
|
|
||||||
// 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 ?? ""
|
||||||
// // Setup gcc as the compiler
|
// promises.push(
|
||||||
// await addEnv("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`)
|
// addEnv("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`),
|
||||||
// await addEnv("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`)
|
// addEnv("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`),
|
||||||
// await addEnv("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`)
|
// addEnv("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`),
|
||||||
// await addEnv("LDFLAGS", `-L${installDir}/lib`)
|
// addEnv("LDFLAGS", `-L${installDir}/lib`),
|
||||||
// await addEnv("CPPFLAGS", `-I${installDir}/include`)
|
// addEnv("CPPFLAGS", `-I${installDir}/include`)
|
||||||
|
// )
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
await addEnv("CC", `${binDir}/gcc`)
|
promises.push(addEnv("CC", `${binDir}/gcc`), addEnv("CXX", `${binDir}/g++`))
|
||||||
await addEnv("CXX", `${binDir}/g++`)
|
|
||||||
} else {
|
} else {
|
||||||
const majorVersion = semverMajor(semverCoerce(version) ?? version)
|
const majorVersion = semverMajor(semverCoerce(version) ?? version)
|
||||||
if (majorVersion >= 5) {
|
if (majorVersion >= 5) {
|
||||||
await addEnv("CC", `${binDir}/gcc-${majorVersion}`)
|
promises.push(addEnv("CC", `${binDir}/gcc-${majorVersion}`), addEnv("CXX", `${binDir}/g++-${majorVersion}`))
|
||||||
await addEnv("CXX", `${binDir}/g++-${majorVersion}`)
|
|
||||||
|
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
await updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
|
updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
|
||||||
await updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
|
updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
|
||||||
await updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`)
|
updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`)
|
||||||
await updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
|
updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await addEnv("CC", `${binDir}/gcc-${version}`)
|
promises.push(addEnv("CC", `${binDir}/gcc-${version}`), addEnv("CXX", `${binDir}/g++-${version}`))
|
||||||
await addEnv("CXX", `${binDir}/g++-${version}`)
|
|
||||||
|
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
await updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
|
updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
|
||||||
await updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
|
updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
|
||||||
await updateAptAlternatives("gcc", `${binDir}/gcc-${version}`)
|
updateAptAlternatives("gcc", `${binDir}/gcc-${version}`)
|
||||||
await updateAptAlternatives("g++", `${binDir}/g++-${version}`)
|
updateAptAlternatives("g++", `${binDir}/g++-${version}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await setupMacOSSDK()
|
promises.push(setupMacOSSDK())
|
||||||
|
|
||||||
if (isGitHubCI()) {
|
if (isGitHubCI()) {
|
||||||
addGccLoggingMatcher()
|
addGccLoggingMatcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addGccLoggingMatcher() {
|
function addGccLoggingMatcher() {
|
||||||
|
|
|
@ -301,45 +301,53 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
||||||
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 ?? ""
|
||||||
|
|
||||||
await addEnv("LLVM_PATH", directory) // the output of this action
|
const promises = [
|
||||||
|
// the output of this action
|
||||||
|
addEnv("LLVM_PATH", directory),
|
||||||
|
|
||||||
// Setup LLVM as the compiler
|
// Setup LLVM as the compiler
|
||||||
await addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`)
|
addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`),
|
||||||
await addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`)
|
addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`),
|
||||||
|
|
||||||
|
// compiler flags
|
||||||
|
addEnv("LDFLAGS", `-L'${directory}/lib'`),
|
||||||
|
addEnv("CPPFLAGS", `-I'${directory}/include'`),
|
||||||
|
|
||||||
|
// compiler paths
|
||||||
|
addEnv("CC", `${directory}/bin/clang`),
|
||||||
|
addEnv("CXX", `${directory}/bin/clang++`),
|
||||||
|
|
||||||
|
addEnv("LIBRARY_PATH", `${directory}/lib`),
|
||||||
|
|
||||||
|
// os sdks
|
||||||
|
setupMacOSSDK(),
|
||||||
|
]
|
||||||
|
|
||||||
// windows builds fail with llvm's CPATH
|
// windows builds fail with llvm's CPATH
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
const llvmMajor = semverMajor(version)
|
const llvmMajor = semverMajor(version)
|
||||||
if (existsSync(`${directory}/lib/clang/${version}/include`)) {
|
if (existsSync(`${directory}/lib/clang/${version}/include`)) {
|
||||||
await addEnv("CPATH", `${directory}/lib/clang/${version}/include`)
|
promises.push(addEnv("CPATH", `${directory}/lib/clang/${version}/include`))
|
||||||
} else if (existsSync(`${directory}/lib/clang/${llvmMajor}/include`)) {
|
} else if (existsSync(`${directory}/lib/clang/${llvmMajor}/include`)) {
|
||||||
await addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`)
|
promises.push(addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await addEnv("LDFLAGS", `-L'${directory}/lib'`)
|
|
||||||
await addEnv("CPPFLAGS", `-I'${directory}/include'`)
|
|
||||||
|
|
||||||
await addEnv("CC", `${directory}/bin/clang`)
|
|
||||||
await addEnv("CXX", `${directory}/bin/clang++`)
|
|
||||||
|
|
||||||
await addEnv("LIBRARY_PATH", `${directory}/lib`)
|
|
||||||
|
|
||||||
await setupMacOSSDK()
|
|
||||||
|
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
await updateAptAlternatives("cc", `${directory}/bin/clang`)
|
updateAptAlternatives("cc", `${directory}/bin/clang`)
|
||||||
await updateAptAlternatives("cxx", `${directory}/bin/clang++`)
|
updateAptAlternatives("cxx", `${directory}/bin/clang++`)
|
||||||
await updateAptAlternatives("clang", `${directory}/bin/clang`)
|
updateAptAlternatives("clang", `${directory}/bin/clang`)
|
||||||
await updateAptAlternatives("clang++", `${directory}/bin/clang++`)
|
updateAptAlternatives("clang++", `${directory}/bin/clang++`)
|
||||||
await updateAptAlternatives("lld", `${directory}/bin/lld`)
|
updateAptAlternatives("lld", `${directory}/bin/lld`)
|
||||||
await updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
|
updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
|
||||||
await updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
|
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isGitHubCI()) {
|
if (isGitHubCI()) {
|
||||||
addLLVMLoggingMatcher()
|
addLLVMLoggingMatcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Setup llvm tools (clang tidy, clang format, etc) without activating llvm and using it as the compiler */
|
/** Setup llvm tools (clang tidy, clang format, etc) without activating llvm and using it as the compiler */
|
||||||
|
|
|
@ -244,8 +244,7 @@ export async function main(args: string[]): Promise<number> {
|
||||||
case "appleclang":
|
case "appleclang":
|
||||||
case "applellvm": {
|
case "applellvm": {
|
||||||
notice("Assuming apple-clang is already installed")
|
notice("Assuming apple-clang is already installed")
|
||||||
await addEnv("CC", "clang")
|
await Promise.all([addEnv("CC", "clang"), addEnv("CXX", "clang++")])
|
||||||
await addEnv("CXX", "clang++")
|
|
||||||
successMessages.push(getSuccessMessage("apple-clang", undefined))
|
successMessages.push(getSuccessMessage("apple-clang", undefined))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue