mirror of https://github.com/aminya/setup-cpp
Merge pull request #112 from aminya/bazel [skip ci]
This commit is contained in:
commit
322f0819ba
|
@ -17,7 +17,7 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
|
|||
| category | tools |
|
||||
| --------------------- | ------------------------------------------------------------ |
|
||||
| compiler and analyzer | llvm, gcc, msvc, vcvarsall, cppcheck, clangtidy, clangformat |
|
||||
| build system | cmake, ninja, meson, make, task |
|
||||
| build system | cmake, ninja, meson, make, task, bazel |
|
||||
| package manager | vcpkg, conan, choco, brew, nala |
|
||||
| cache | cppcache |
|
||||
| documentation | doxygen, graphviz |
|
||||
|
|
|
@ -12,6 +12,10 @@ words:
|
|||
- aarch
|
||||
- aminya
|
||||
- applellvm
|
||||
- bazel
|
||||
- bazelisk
|
||||
- copr
|
||||
- vbatts
|
||||
- buildtools
|
||||
- caxa
|
||||
- ccache
|
||||
|
|
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
|
@ -0,0 +1,12 @@
|
|||
import { setupBazel } from "../bazel"
|
||||
import { testBin } from "../../utils/tests/test-helpers"
|
||||
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||
|
||||
jest.setTimeout(300000)
|
||||
describe("setup-bazel", () => {
|
||||
it("should setup bazel", async () => {
|
||||
const installInfo = await setupBazel("", "", process.arch)
|
||||
|
||||
await testBin("bazel", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
||||
})
|
||||
})
|
|
@ -0,0 +1,47 @@
|
|||
import { addAptKeyViaDownload, setupAptPack } from "../utils/setup/setupAptPack"
|
||||
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||
import { isArch } from "../utils/env/isArch"
|
||||
import { hasDnf } from "../utils/env/hasDnf"
|
||||
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||
import { execSudo } from "../utils/exec/sudo"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function setupBazel(version: string, _setupDir: string, _arch: string) {
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
// install bazelisk because it contains both
|
||||
return setupChocoPack("bazelisk", version)
|
||||
}
|
||||
case "darwin": {
|
||||
// install bazelisk because it contains both
|
||||
return setupBrewPack("bazelisk", version)
|
||||
}
|
||||
case "linux": {
|
||||
if (isArch()) {
|
||||
throw new Error("installing bazel on Arch linux is not supported yet")
|
||||
} else if (hasDnf()) {
|
||||
// https://bazel.build/install/redhat
|
||||
setupDnfPack("dnf-plugins-core", undefined)
|
||||
execSudo("dnf", ["copr", "enable", "vbatts/bazel"])
|
||||
return setupDnfPack("bazel4", undefined)
|
||||
} else if (isUbuntu()) {
|
||||
// https://bazel.build/install/ubuntu
|
||||
const keyFileName = await addAptKeyViaDownload(
|
||||
"bazel-archive-keyring.gpg",
|
||||
"https://bazel.build/bazel-release.pub.gpg"
|
||||
)
|
||||
execSudo("bash", [
|
||||
"-c",
|
||||
`echo "deb [arch=amd64 signed-by=${keyFileName}] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list`,
|
||||
])
|
||||
return setupAptPack("bazel", version, [], true)
|
||||
}
|
||||
throw new Error(`Unsupported linux distribution`)
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported platform`)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ import { addEnv } from "./utils/env/addEnv"
|
|||
import { setupSevenZip } from "./sevenzip/sevenzip"
|
||||
import { setupGraphviz } from "./graphviz/graphviz"
|
||||
import { setupNala } from "./nala/nala"
|
||||
import { setupBazel } from "./bazel/bazel"
|
||||
|
||||
/** The setup functions */
|
||||
const setups = {
|
||||
|
@ -51,6 +52,7 @@ const setups = {
|
|||
ninja: setupNinja,
|
||||
python: setupPython,
|
||||
vcpkg: setupVcpkg,
|
||||
bazel: setupBazel,
|
||||
conan: setupConan,
|
||||
meson: setupMeson,
|
||||
gcovr: setupGcovr,
|
||||
|
@ -80,6 +82,7 @@ const tools: Array<keyof typeof setups> = [
|
|||
"brew",
|
||||
"python",
|
||||
"vcpkg",
|
||||
"bazel",
|
||||
"cmake",
|
||||
"ninja",
|
||||
"conan",
|
||||
|
@ -359,6 +362,7 @@ All the available tools:
|
|||
--cmake
|
||||
--ninja
|
||||
--vcpkg
|
||||
--bazel
|
||||
--meson
|
||||
--conan
|
||||
--make
|
||||
|
|
|
@ -2,7 +2,7 @@ import { dirname } from "path"
|
|||
import which from "which"
|
||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||
import { execSudo } from "../utils/exec/sudo"
|
||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||
import { addAptKeyViaDownload, setupAptPack } from "../utils/setup/setupAptPack"
|
||||
|
||||
let binDir: string | undefined
|
||||
|
||||
|
@ -22,14 +22,13 @@ export async function setupNala(version: string, _setupDir: string, _arch: strin
|
|||
}
|
||||
|
||||
// https://github.com/volitank/nala#-installation
|
||||
await setupAptPack("wget")
|
||||
const keyFileName = await addAptKeyViaDownload(
|
||||
"volian-archive-scar-unstable.gpg",
|
||||
"https://deb.volian.org/volian/scar.key"
|
||||
)
|
||||
execSudo("/bin/bash", [
|
||||
"-c",
|
||||
`wget -qO - https://deb.volian.org/volian/scar.key | tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null`,
|
||||
])
|
||||
execSudo("/bin/bash", [
|
||||
"-c",
|
||||
`echo "deb http://deb.volian.org/volian/ scar main" | tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list`,
|
||||
`echo "deb [signed-by=${keyFileName}] http://deb.volian.org/volian/ scar main" | tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list`,
|
||||
])
|
||||
|
||||
try {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import { InstallationInfo } from "./setupBin"
|
||||
import { execSudo } from "../exec/sudo"
|
||||
import { info } from "@actions/core"
|
||||
import { warning } from "../io/io"
|
||||
import { isGitHubCI } from "../env/isCI"
|
||||
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
||||
import { appendFileSync, existsSync } from "fs"
|
||||
|
@ -18,10 +17,10 @@ export async function setupAptPack(
|
|||
repositories: string[] = [],
|
||||
update = false
|
||||
): Promise<InstallationInfo> {
|
||||
info(`Installing ${name} ${version ?? ""} via apt`)
|
||||
|
||||
const apt: string = getApt()
|
||||
|
||||
info(`Installing ${name} ${version ?? ""} via ${apt}`)
|
||||
|
||||
process.env.DEBIAN_FRONTEND = "noninteractive"
|
||||
|
||||
if (!didUpdate || update) {
|
||||
|
@ -80,8 +79,8 @@ async function initApt(apt: string) {
|
|||
"ca-certificates",
|
||||
"gnupg",
|
||||
])
|
||||
addAptKey(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
|
||||
addAptKey(["1E9377A2BA9EF27F"], "setup-cpp-launchpad-toolchain.gpg")
|
||||
addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
|
||||
addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg")
|
||||
if (apt === "nala") {
|
||||
// enable utf8 otherwise it fails because of the usage of ASCII encoding
|
||||
await addEnv("LANG", "C.UTF-8")
|
||||
|
@ -89,24 +88,39 @@ async function initApt(apt: string) {
|
|||
}
|
||||
}
|
||||
|
||||
function addAptKey(keys: string[], name: string) {
|
||||
try {
|
||||
if (!existsSync(`/root/.gnupg/${name}`)) {
|
||||
for (const key of keys) {
|
||||
execSudo("gpg", [
|
||||
"--no-default-keyring",
|
||||
"--keyring",
|
||||
name,
|
||||
"--keyserver",
|
||||
"keyserver.ubuntu.com",
|
||||
"--recv-keys",
|
||||
key,
|
||||
])
|
||||
}
|
||||
function initGpg() {
|
||||
execSudo("gpg", ["-k"])
|
||||
}
|
||||
|
||||
export function addAptKeyViaServer(keys: string[], name: string, server = "keyserver.ubuntu.com") {
|
||||
const fileName = `/etc/apt/trusted.gpg.d/${name}`
|
||||
if (!existsSync(fileName)) {
|
||||
initGpg()
|
||||
for (const key of keys) {
|
||||
execSudo("gpg", [
|
||||
"--no-default-keyring",
|
||||
"--keyring",
|
||||
`gnupg-ring:${fileName}`,
|
||||
"--keyserver",
|
||||
server,
|
||||
"--recv-keys",
|
||||
key,
|
||||
])
|
||||
execSudo("chmod", ["644", fileName])
|
||||
}
|
||||
} catch (err) {
|
||||
warning(`Failed to add keys: ${err}`)
|
||||
}
|
||||
return fileName
|
||||
}
|
||||
|
||||
export async function addAptKeyViaDownload(name: string, url: string) {
|
||||
const fileName = `/etc/apt/trusted.gpg.d/${name}`
|
||||
if (!existsSync(fileName)) {
|
||||
initGpg()
|
||||
await setupAptPack("curl", undefined)
|
||||
execSudo("bash", ["-c", `curl -s ${url} | gpg --no-default-keyring --keyring gnupg-ring:${fileName} --import`])
|
||||
execSudo("chmod", ["644", fileName])
|
||||
}
|
||||
return fileName
|
||||
}
|
||||
|
||||
export function updateAptAlternatives(name: string, path: string) {
|
||||
|
|
Loading…
Reference in New Issue