...
1#!/usr/bin/env bash
2
3set -o errexit
4set -o nounset
5set -o pipefail
6
7if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then # Running inside bazel
8 echo "Updating gomock..." >&2
9elif ! command -v bazel &>/dev/null; then
10 echo "Install bazel via 'just hack/bazelisk'" >&2
11 exit 1
12else
13 echo "This script should be ran via a Bazel target"
14 exit 1
15fi
16
17go=$(realpath "$1")
18gomock="$(realpath "$2")"
19dir=$3
20PATH=$(dirname "$gomock"):$(dirname "$go"):$PATH
21# https://github.com/koalaman/shellcheck/wiki/SC2155
22export PATH
23
24REPO_ROOT=${BUILD_WORKSPACE_DIRECTORY}
25cd "${REPO_ROOT}/${dir}"
26echo "Generating code from ${REPO_ROOT}/${dir}"
27
28"$go" generate ./...
View as plain text