#!/usr/bin/env bash set -eu set +x # This script links tools from their place in the bazel-bin dir to the provided # directory. This directory should be on your $PATH if you want to actually # make any use of this script. bin="$1" HACK_TOOLS_TARGET="${HACK_TOOLS_TARGET:-"//hack:tools_to_link"}" echo "linking tools to $1" if [[ "$2" == "$HACK_TOOLS_TARGET" ]]; then echo "building dev tools..." # if its the filegroup with the required set of dev tools, dont perform # the additional _binary query because it dont work # shellcheck disable=SC2207 targets=($(bazel cquery --output=files "$HACK_TOOLS_TARGET")) else # remove specific _linux variants (relying on host configuration) defined for # binaries and remove container binaries from link targets. we only want to link # whatever binaries would be built for the host platform. echo "querying Bazel expression for binaries to link" # shellcheck disable=SC2207 targets=($(bazel cquery --output=files "kind(.*_binary, ${2})" | grep -Ev "_linux|container.binary")) fi for b in "${targets[@]}"; do dst="${bin}/$(basename "$b")" rm -f "$dst" ln -sf "$PWD/$b" "$dst" echo "$b --> $dst" done