mirror of https://github.com/aminya/setup-cpp
feat: support installing Bazel
This commit is contained in:
parent
c8cec57d18
commit
5183c0d6d4
|
@ -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 |
|
||||
|
|
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,46 @@
|
|||
import { 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": {
|
||||
return setupChocoPack("bazel", version)
|
||||
}
|
||||
case "darwin": {
|
||||
return setupBrewPack("bazel", 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
|
||||
execSudo("bash", [
|
||||
"-c",
|
||||
"wget -qO - https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg > /dev/null",
|
||||
])
|
||||
execSudo("bash", ["-c", "mv bazel-archive-keyring.gpg /usr/share/keyrings"])
|
||||
execSudo("bash", [
|
||||
"-c",
|
||||
'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo 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
|
||||
|
|
Loading…
Reference in New Issue