Skip to content

Commit

Permalink
Add Bazel feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mering committed Jul 26, 2023
1 parent 3f9164f commit cc508e4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/bazel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Bazel feature

Install [Bazelisk](https://github.com/bazelbuild/bazelisk) and [Buildifier](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md).
34 changes: 34 additions & 0 deletions src/bazel/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "Bazel",
"id": "bazel",
"version": "1.0.0",
"description": "Bazel feature",
"options": {
"bazelisk_version": {
"type": "string",
"proposals": [
"1.17.0",
"latest"
],
"default": "latest",
"description": "Version of Bazelisk to manage Bazel versions"
},
"buildifier_version": {
"type": "string",
"proposals": [
"5.1.0",
"6.1.2",
"latest"
],
"default": "latest",
"description": "Version of Buildifier to lint BUILD files"
}
},
"customizations": {
"vscode": {
"extensions": [
"bazelbuild.vscode-bazel"
]
}
}
}
26 changes: 26 additions & 0 deletions src/bazel/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
set -eu

echo "Installing Bazel"

LOCAL_BIN="/usr/local/bin"

github_download() {
repo=$1
version=$2
artifact=$3
output=$4
if [ "${version}" = "latest" ]; then
URL="https://github.com/${repo}/releases/latest/download/${artifact}"
else
URL="https://github.com/${repo}/releases/download/${version}/${artifact}"
fi
curl -LSs "${URL}" -o "${output}"
}

github_download "bazelbuild/bazelisk" "${BAZELISK_VERSION}" "bazelisk-linux-amd64" "${LOCAL_BIN}/bazelisk"
chmod +x "${LOCAL_BIN}/bazelisk"
ln -s "${LOCAL_BIN}/bazelisk" "${LOCAL_BIN}/bazel"

github_download "bazelbuild/buildtools" "${BUILDIFIER_VERSION}" "buildifier-linux-amd64" "${LOCAL_BIN}/buildifier"
chmod +x "${LOCAL_BIN}/buildifier"

0 comments on commit cc508e4

Please sign in to comment.