...
1bin_dir := "$HOME/bin"
2build := "bazel build --config=quiet"
3
4# they say you can do else ifs but i could never get it working
5# https://github.com/casey/just#conditional-expressions
6bazeliskOS := if os_family() == "windows" {
7 "bazelisk-windows-amd64.exe"
8} else {
9 if os() == "macos" {
10 if arch() == "aarch64" {
11 "darwin-arm64"
12 } else {
13 "darwin-amd64"
14 }
15 } else {
16 if arch() == "arm" {
17 "linux-arm64"
18 } else {
19 "linux-amd64"
20 }
21 }
22}
23
24ibazelOS := if os_family() == "windows" {
25 "windows_amd64.exe"
26} else {
27 if os() == "macos" {
28 if arch() == "aarch64" {
29 "darwin_arm64"
30 } else {
31 "darwin_amd64"
32 }
33 } else {
34 "linux_amd64"
35 }
36}
37
38# creates {{bin_dir}} if it doesnt exist, so we can install tools to directories
39# owned by the user
40_mkdir:
41 @mkdir -p {{bin_dir}}
42
43# message reminding people to update their $PATH so that ~/bin is on it
44_setup-path-msg:
45 @echo "\n\nTOOL INSTALLATION COMPLETE.\n\n"
46 @echo "NEXT STEPS:"
47 @echo "- Add {{bin_dir}} to your \$PATH variable in your ~/.bashrc or ~/.zshrc to add the installed tools to your path."
48 @echo "- Don't forget to run 'source ~/{.bashrc or .zshrc}' for the changes to take effect"
49
50# sets up symlinks for tooling binaries managed by this repository to {{bin_dir}}. should only be ran once
51link-tools target: _mkdir
52 # run linking script from root of repository
53 @cd .. && hack/link-tools.sh {{bin_dir}} {{target}}
54 @just _setup-path-msg
55
56clean-links:
57 # deleting all linked tools:
58 find {{bin_dir}} -maxdepth 1 -type l
59 find {{bin_dir}} -maxdepth 1 -type l | xargs rm
60 # run `just link` to relink default development tools
61
62#
63# REPOSITORY BOOTSTRAP RECIPES
64#
65
66# installs bazel tooling to {{bin_dir}}, should be ran one time per dev machine
67bazel: _mkdir bazelisk bazel-watcher _setup-path-msg
68
69# Installs Bazelisk as Bazel, one-time per machine
70bazelisk version="1.17.0":
71 #!/usr/bin/env bash
72 set -ex
73 if command -v bazel &> /dev/null
74 then
75 echo "Bazel already installed, uninstall if you want to reinstall"
76 echo "then re-run this recipe: just hack/bazelisk"
77 exit
78 fi
79 echo "I am going to install bazelisk as bazel. You can treat it as bazel."
80 curl -Lo {{bin_dir}}/bazel https://github.com/bazelbuild/bazelisk/releases/download/v{{version}}/bazelisk-{{bazeliskOS}}
81 chmod +x {{bin_dir}}/bazel
82 echo "You can now use bazel directly from the command line"
83
84# Installs iBazel, the Bazel + file watcher utility
85bazel-watcher version="0.22.0":
86 #!/usr/bin/env bash
87 set -ex
88 if command -v ibazel &> /dev/null
89 then
90 echo "bazel-watcher already installed, uninstall if you want to reinstall"
91 echo "then re-run this recipe: just hack/bazel-watcher"
92 exit
93 fi
94 echo "Installing ibazel..."
95 curl -Lo {{bin_dir}}/ibazel https://github.com/bazelbuild/bazel-watcher/releases/download/v{{version}}/ibazel_{{ibazelOS}}
96 chmod +x {{bin_dir}}/ibazel
97 echo "Successfully installed, replace bazel calls with ibazel to automatically rerun on file change."
View as plain text