mirror of https://github.com/aminya/setup-cpp
perf: install LLVM and GCC in parallel
This commit is contained in:
parent
96bc4cd6f9
commit
bd7b54ade4
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -20,7 +20,6 @@ import { existsSync } from "fs"
|
||||||
import ciDetect from "@npmcli/ci-detect"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { setupGcc } from "../gcc/gcc"
|
import { setupGcc } from "../gcc/gcc"
|
||||||
import { getVersion } from "../versions/versions"
|
import { getVersion } from "../versions/versions"
|
||||||
import { isArch } from "../utils/env/isArch"
|
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
|
|
||||||
//================================================
|
//================================================
|
||||||
|
@ -291,31 +290,45 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform, _a
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
const installationInfo = await _setupLLVM(version, setupDir, arch)
|
const installationInfo = await setupLLVMWithoutActivation(version, setupDir, arch)
|
||||||
await activateLLVM(installationInfo.installDir ?? setupDir, version)
|
await activateLLVM(installationInfo.installDir ?? setupDir, version)
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
let didInit = false
|
let installedDeps = false
|
||||||
async function _setupLLVM(version: string, setupDir: string, arch: string) {
|
|
||||||
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
|
async function setupLLVMWithoutActivation(version: string, setupDir: string, arch: string) {
|
||||||
if (!didInit) {
|
const installationInfoPromise = setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
|
||||||
if (process.platform === "linux") {
|
|
||||||
// install llvm build dependencies
|
let depsPromise: Promise<void>
|
||||||
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
|
if (!installedDeps) {
|
||||||
if (isArch()) {
|
depsPromise = setupLLVMDeps(arch)
|
||||||
// setupPacmanPack("ncurses")
|
|
||||||
// TODO: install libtinfo ?
|
|
||||||
} else if (isUbuntu()) {
|
|
||||||
await setupAptPack("libtinfo-dev")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line require-atomic-updates
|
// eslint-disable-next-line require-atomic-updates
|
||||||
didInit = true
|
installedDeps = true
|
||||||
|
} else {
|
||||||
|
depsPromise = Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// install LLVM and its dependencies in parallel
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
const [installationInfo, _] = await Promise.all([installationInfoPromise, depsPromise])
|
||||||
|
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setupLLVMDeps(arch: string) {
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
// install llvm build dependencies
|
||||||
|
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
|
||||||
|
|
||||||
|
if (isUbuntu()) {
|
||||||
|
await setupAptPack("libtinfo-dev")
|
||||||
|
}
|
||||||
|
// TODO: install libtinfo on other distros
|
||||||
|
// setupPacmanPack("ncurses")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function activateLLVM(directory: string, versionGiven: string) {
|
export async function activateLLVM(directory: string, versionGiven: string) {
|
||||||
const version = semverCoerceIfInvalid(versionGiven)
|
const version = semverCoerceIfInvalid(versionGiven)
|
||||||
|
|
||||||
|
@ -378,7 +391,7 @@ export function setupClangTools(version: string, setupDir: string, arch: string)
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
addLLVMLoggingMatcher()
|
addLLVMLoggingMatcher()
|
||||||
}
|
}
|
||||||
return _setupLLVM(version, setupDir, arch)
|
return setupLLVMWithoutActivation(version, setupDir, arch)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLLVMLoggingMatcher() {
|
function addLLVMLoggingMatcher() {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import { hasDnf } from "../utils/env/hasDnf"
|
||||||
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
import { getExecOutput } from "@actions/exec"
|
import { getExecOutput } from "@actions/exec"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import { isBinUptoDate } from "../utils/setup/version"
|
import { isBinUptoDate } from "../utils/setup/version"
|
||||||
import { getVersion } from "../versions/versions"
|
import { getVersion } from "../versions/versions"
|
||||||
import assert from "assert"
|
import assert from "assert"
|
||||||
|
|
Loading…
Reference in New Issue