mirror of https://github.com/aminya/setup-cpp
fix: fix getting the brew path on linux
This commit is contained in:
parent
ded42d5c2f
commit
66a38eb0fb
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
|
@ -46,12 +46,16 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (process.platform === "linux") {
|
binDir = getBrewPath()
|
||||||
binDir = "/home/linuxbrew/.linuxbrew/bin/"
|
|
||||||
await addPath(binDir)
|
await addPath(binDir)
|
||||||
} else {
|
|
||||||
binDir = "/usr/local/bin/"
|
|
||||||
}
|
|
||||||
|
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getBrewPath() {
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
return "/home/linuxbrew/.linuxbrew/bin/"
|
||||||
|
} else {
|
||||||
|
return "/usr/local/bin/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
const installationInfo = setupBrewPack("doxygen", undefined)
|
const installationInfo = await setupBrewPack("doxygen", undefined)
|
||||||
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
|
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
installationInfo = setupBrewPack("gcc", version)
|
installationInfo = await setupBrewPack("gcc", version)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
|
|
|
@ -15,7 +15,7 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
|
||||||
return setupChocoPack("make", version)
|
return setupChocoPack("make", version)
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
setupBrewPack("make", version)
|
await setupBrewPack("make", version)
|
||||||
await addPath("/usr/local/opt/make/libexec/gnubin")
|
await addPath("/usr/local/opt/make/libexec/gnubin")
|
||||||
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
|
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,36 @@
|
||||||
/* eslint-disable require-atomic-updates */
|
/* eslint-disable require-atomic-updates */
|
||||||
import { info } from "@actions/core"
|
import { info } from "@actions/core"
|
||||||
import execa from "execa"
|
import execa from "execa"
|
||||||
|
import { join } from "patha"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { setupBrew } from "../../brew/brew"
|
import { getBrewPath, setupBrew } from "../../brew/brew"
|
||||||
import { InstallationInfo } from "./setupBin"
|
import { InstallationInfo } from "./setupBin"
|
||||||
|
|
||||||
let hasBrew = false
|
let hasBrew = false
|
||||||
|
|
||||||
/** A function that installs a package using brew */
|
/** A function that installs a package using brew */
|
||||||
export function setupBrewPack(name: string, version?: string, extraArgs: string[] = []): InstallationInfo {
|
export async function setupBrewPack(
|
||||||
|
name: string,
|
||||||
|
version?: string,
|
||||||
|
extraArgs: string[] = []
|
||||||
|
): Promise<InstallationInfo> {
|
||||||
info(`Installing ${name} ${version ?? ""} via brew`)
|
info(`Installing ${name} ${version ?? ""} via brew`)
|
||||||
|
|
||||||
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
||||||
setupBrew("", "", process.arch)
|
await setupBrew("", "", process.arch)
|
||||||
hasBrew = true
|
hasBrew = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// brew is not thread-safe
|
const binDir = getBrewPath()
|
||||||
execa.sync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name, ...extraArgs], {
|
|
||||||
stdio: "inherit",
|
|
||||||
})
|
|
||||||
|
|
||||||
return { binDir: "/usr/local/bin/" }
|
// brew is not thread-safe
|
||||||
|
execa.sync(
|
||||||
|
join(binDir, "brew"),
|
||||||
|
["install", version !== undefined && version !== "" ? `${name}@${version}` : name, ...extraArgs],
|
||||||
|
{
|
||||||
|
stdio: "inherit",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue