Skip to content

Commit c8f6527

Browse files
committed
fix: add env variables in parallel for llvm and gcc
1 parent 777ee3f commit c8f6527

File tree

5 files changed

+59
-48
lines changed

5 files changed

+59
-48
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: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,48 +68,52 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
6868
}
6969

7070
async function activateGcc(version: string, binDir: string) {
71+
const promises: Promise<void>[] = []
72+
// Setup gcc as the compiler
73+
7174
// TODO
7275
// const ld = process.env.LD_LIBRARY_PATH ?? ""
7376
// const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
74-
// // Setup gcc as the compiler
75-
// await addEnv("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`)
76-
// await addEnv("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`)
77-
// await addEnv("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`)
78-
// await addEnv("LDFLAGS", `-L${installDir}/lib`)
79-
// await addEnv("CPPFLAGS", `-I${installDir}/include`)
77+
// promises.push(
78+
// addEnv("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`),
79+
// addEnv("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`),
80+
// addEnv("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`),
81+
// addEnv("LDFLAGS", `-L${installDir}/lib`),
82+
// addEnv("CPPFLAGS", `-I${installDir}/include`)
83+
// )
84+
8085
if (process.platform === "win32") {
81-
await addEnv("CC", `${binDir}/gcc`)
82-
await addEnv("CXX", `${binDir}/g++`)
86+
promises.push(addEnv("CC", `${binDir}/gcc`), addEnv("CXX", `${binDir}/g++`))
8387
} else {
8488
const majorVersion = semverMajor(semverCoerce(version) ?? version)
8589
if (majorVersion >= 5) {
86-
await addEnv("CC", `${binDir}/gcc-${majorVersion}`)
87-
await addEnv("CXX", `${binDir}/g++-${majorVersion}`)
90+
promises.push(addEnv("CC", `${binDir}/gcc-${majorVersion}`), addEnv("CXX", `${binDir}/g++-${majorVersion}`))
8891

8992
if (process.platform === "linux") {
90-
await updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
91-
await updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
92-
await updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`)
93-
await updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
93+
updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
94+
updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
95+
updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`)
96+
updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
9497
}
9598
} else {
96-
await addEnv("CC", `${binDir}/gcc-${version}`)
97-
await addEnv("CXX", `${binDir}/g++-${version}`)
99+
promises.push(addEnv("CC", `${binDir}/gcc-${version}`), addEnv("CXX", `${binDir}/g++-${version}`))
98100

99101
if (process.platform === "linux") {
100-
await updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
101-
await updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
102-
await updateAptAlternatives("gcc", `${binDir}/gcc-${version}`)
103-
await updateAptAlternatives("g++", `${binDir}/g++-${version}`)
102+
updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
103+
updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
104+
updateAptAlternatives("gcc", `${binDir}/gcc-${version}`)
105+
updateAptAlternatives("g++", `${binDir}/g++-${version}`)
104106
}
105107
}
106108
}
107109

108-
await setupMacOSSDK()
110+
promises.push(setupMacOSSDK())
109111

110112
if (isGitHubCI()) {
111113
addGccLoggingMatcher()
112114
}
115+
116+
await Promise.all(promises)
113117
}
114118

115119
function addGccLoggingMatcher() {

src/llvm/llvm.ts

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -301,45 +301,53 @@ export async function activateLLVM(directory: string, versionGiven: string) {
301301
const ld = process.env.LD_LIBRARY_PATH ?? ""
302302
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
303303

304-
await addEnv("LLVM_PATH", directory) // the output of this action
304+
const promises = [
305+
// the output of this action
306+
addEnv("LLVM_PATH", directory),
305307

306-
// Setup LLVM as the compiler
307-
await addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`)
308-
await addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`)
308+
// Setup LLVM as the compiler
309+
addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`),
310+
addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`),
311+
312+
// compiler flags
313+
addEnv("LDFLAGS", `-L'${directory}/lib'`),
314+
addEnv("CPPFLAGS", `-I'${directory}/include'`),
315+
316+
// compiler paths
317+
addEnv("CC", `${directory}/bin/clang`),
318+
addEnv("CXX", `${directory}/bin/clang++`),
319+
320+
addEnv("LIBRARY_PATH", `${directory}/lib`),
321+
322+
// os sdks
323+
setupMacOSSDK(),
324+
]
309325

310326
// windows builds fail with llvm's CPATH
311327
if (process.platform !== "win32") {
312328
const llvmMajor = semverMajor(version)
313329
if (existsSync(`${directory}/lib/clang/${version}/include`)) {
314-
await addEnv("CPATH", `${directory}/lib/clang/${version}/include`)
330+
promises.push(addEnv("CPATH", `${directory}/lib/clang/${version}/include`))
315331
} else if (existsSync(`${directory}/lib/clang/${llvmMajor}/include`)) {
316-
await addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`)
332+
promises.push(addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`))
317333
}
318334
}
319335

320-
await addEnv("LDFLAGS", `-L'${directory}/lib'`)
321-
await addEnv("CPPFLAGS", `-I'${directory}/include'`)
322-
323-
await addEnv("CC", `${directory}/bin/clang`)
324-
await addEnv("CXX", `${directory}/bin/clang++`)
325-
326-
await addEnv("LIBRARY_PATH", `${directory}/lib`)
327-
328-
await setupMacOSSDK()
329-
330336
if (process.platform === "linux") {
331-
await updateAptAlternatives("cc", `${directory}/bin/clang`)
332-
await updateAptAlternatives("cxx", `${directory}/bin/clang++`)
333-
await updateAptAlternatives("clang", `${directory}/bin/clang`)
334-
await updateAptAlternatives("clang++", `${directory}/bin/clang++`)
335-
await updateAptAlternatives("lld", `${directory}/bin/lld`)
336-
await updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
337-
await updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
337+
updateAptAlternatives("cc", `${directory}/bin/clang`)
338+
updateAptAlternatives("cxx", `${directory}/bin/clang++`)
339+
updateAptAlternatives("clang", `${directory}/bin/clang`)
340+
updateAptAlternatives("clang++", `${directory}/bin/clang++`)
341+
updateAptAlternatives("lld", `${directory}/bin/lld`)
342+
updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
343+
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
338344
}
339345

340346
if (isGitHubCI()) {
341347
addLLVMLoggingMatcher()
342348
}
349+
350+
await Promise.all(promises)
343351
}
344352

345353
/** Setup llvm tools (clang tidy, clang format, etc) without activating llvm and using it as the compiler */

src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ export async function main(args: string[]): Promise<number> {
244244
case "appleclang":
245245
case "applellvm": {
246246
notice("Assuming apple-clang is already installed")
247-
await addEnv("CC", "clang")
248-
await addEnv("CXX", "clang++")
247+
await Promise.all([addEnv("CC", "clang"), addEnv("CXX", "clang++")])
249248
successMessages.push(getSuccessMessage("apple-clang", undefined))
250249
break
251250
}

0 commit comments

Comments
 (0)