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 |
|
| category | tools |
|
||||||
| --------------------- | ------------------------------------------------------------ |
|
| --------------------- | ------------------------------------------------------------ |
|
||||||
| compiler and analyzer | llvm, gcc, msvc, vcvarsall, cppcheck, clangtidy, clangformat |
|
| 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 |
|
| package manager | vcpkg, conan, choco, brew, nala |
|
||||||
| cache | cppcache |
|
| cache | cppcache |
|
||||||
| documentation | doxygen, graphviz |
|
| documentation | doxygen, graphviz |
|
||||||
|
|
|
@ -12,6 +12,10 @@ words:
|
||||||
- aarch
|
- aarch
|
||||||
- aminya
|
- aminya
|
||||||
- applellvm
|
- applellvm
|
||||||
|
- bazel
|
||||||
|
- bazelisk
|
||||||
|
- copr
|
||||||
|
- vbatts
|
||||||
- buildtools
|
- buildtools
|
||||||
- caxa
|
- caxa
|
||||||
- ccache
|
- 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 { setupSevenZip } from "./sevenzip/sevenzip"
|
||||||
import { setupGraphviz } from "./graphviz/graphviz"
|
import { setupGraphviz } from "./graphviz/graphviz"
|
||||||
import { setupNala } from "./nala/nala"
|
import { setupNala } from "./nala/nala"
|
||||||
|
import { setupBazel } from "./bazel/bazel"
|
||||||
|
|
||||||
/** The setup functions */
|
/** The setup functions */
|
||||||
const setups = {
|
const setups = {
|
||||||
|
@ -51,6 +52,7 @@ const setups = {
|
||||||
ninja: setupNinja,
|
ninja: setupNinja,
|
||||||
python: setupPython,
|
python: setupPython,
|
||||||
vcpkg: setupVcpkg,
|
vcpkg: setupVcpkg,
|
||||||
|
bazel: setupBazel,
|
||||||
conan: setupConan,
|
conan: setupConan,
|
||||||
meson: setupMeson,
|
meson: setupMeson,
|
||||||
gcovr: setupGcovr,
|
gcovr: setupGcovr,
|
||||||
|
@ -80,6 +82,7 @@ const tools: Array<keyof typeof setups> = [
|
||||||
"brew",
|
"brew",
|
||||||
"python",
|
"python",
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
|
"bazel",
|
||||||
"cmake",
|
"cmake",
|
||||||
"ninja",
|
"ninja",
|
||||||
"conan",
|
"conan",
|
||||||
|
@ -359,6 +362,7 @@ All the available tools:
|
||||||
--cmake
|
--cmake
|
||||||
--ninja
|
--ninja
|
||||||
--vcpkg
|
--vcpkg
|
||||||
|
--bazel
|
||||||
--meson
|
--meson
|
||||||
--conan
|
--conan
|
||||||
--make
|
--make
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { dirname } from "path"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
import { execSudo } from "../utils/exec/sudo"
|
import { execSudo } from "../utils/exec/sudo"
|
||||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
import { addAptKeyViaDownload, setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
|
|
||||||
let binDir: string | undefined
|
let binDir: string | undefined
|
||||||
|
|
||||||
|
@ -22,14 +22,13 @@ export async function setupNala(version: string, _setupDir: string, _arch: strin
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/volitank/nala#-installation
|
// 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", [
|
execSudo("/bin/bash", [
|
||||||
"-c",
|
"-c",
|
||||||
`wget -qO - https://deb.volian.org/volian/scar.key | tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null`,
|
`echo "deb [signed-by=${keyFileName}] http://deb.volian.org/volian/ scar main" | tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list`,
|
||||||
])
|
|
||||||
execSudo("/bin/bash", [
|
|
||||||
"-c",
|
|
||||||
`echo "deb http://deb.volian.org/volian/ scar main" | tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list`,
|
|
||||||
])
|
])
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import { InstallationInfo } from "./setupBin"
|
import { InstallationInfo } from "./setupBin"
|
||||||
import { execSudo } from "../exec/sudo"
|
import { execSudo } from "../exec/sudo"
|
||||||
import { info } from "@actions/core"
|
import { info } from "@actions/core"
|
||||||
import { warning } from "../io/io"
|
|
||||||
import { isGitHubCI } from "../env/isCI"
|
import { isGitHubCI } from "../env/isCI"
|
||||||
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
||||||
import { appendFileSync, existsSync } from "fs"
|
import { appendFileSync, existsSync } from "fs"
|
||||||
|
@ -18,10 +17,10 @@ export async function setupAptPack(
|
||||||
repositories: string[] = [],
|
repositories: string[] = [],
|
||||||
update = false
|
update = false
|
||||||
): Promise<InstallationInfo> {
|
): Promise<InstallationInfo> {
|
||||||
info(`Installing ${name} ${version ?? ""} via apt`)
|
|
||||||
|
|
||||||
const apt: string = getApt()
|
const apt: string = getApt()
|
||||||
|
|
||||||
|
info(`Installing ${name} ${version ?? ""} via ${apt}`)
|
||||||
|
|
||||||
process.env.DEBIAN_FRONTEND = "noninteractive"
|
process.env.DEBIAN_FRONTEND = "noninteractive"
|
||||||
|
|
||||||
if (!didUpdate || update) {
|
if (!didUpdate || update) {
|
||||||
|
@ -80,8 +79,8 @@ async function initApt(apt: string) {
|
||||||
"ca-certificates",
|
"ca-certificates",
|
||||||
"gnupg",
|
"gnupg",
|
||||||
])
|
])
|
||||||
addAptKey(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
|
addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
|
||||||
addAptKey(["1E9377A2BA9EF27F"], "setup-cpp-launchpad-toolchain.gpg")
|
addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg")
|
||||||
if (apt === "nala") {
|
if (apt === "nala") {
|
||||||
// enable utf8 otherwise it fails because of the usage of ASCII encoding
|
// enable utf8 otherwise it fails because of the usage of ASCII encoding
|
||||||
await addEnv("LANG", "C.UTF-8")
|
await addEnv("LANG", "C.UTF-8")
|
||||||
|
@ -89,24 +88,39 @@ async function initApt(apt: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAptKey(keys: string[], name: string) {
|
function initGpg() {
|
||||||
try {
|
execSudo("gpg", ["-k"])
|
||||||
if (!existsSync(`/root/.gnupg/${name}`)) {
|
}
|
||||||
|
|
||||||
|
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) {
|
for (const key of keys) {
|
||||||
execSudo("gpg", [
|
execSudo("gpg", [
|
||||||
"--no-default-keyring",
|
"--no-default-keyring",
|
||||||
"--keyring",
|
"--keyring",
|
||||||
name,
|
`gnupg-ring:${fileName}`,
|
||||||
"--keyserver",
|
"--keyserver",
|
||||||
"keyserver.ubuntu.com",
|
server,
|
||||||
"--recv-keys",
|
"--recv-keys",
|
||||||
key,
|
key,
|
||||||
])
|
])
|
||||||
|
execSudo("chmod", ["644", fileName])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
return fileName
|
||||||
warning(`Failed to add keys: ${err}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
export function updateAptAlternatives(name: string, path: string) {
|
||||||
|
|
Loading…
Reference in New Issue