...

Text file src/edge-infra.dev/hack/link-tools.sh

Documentation: edge-infra.dev/hack

     1#!/usr/bin/env bash
     2
     3set -eu
     4set +x
     5
     6# This script links tools from their place in the bazel-bin dir to the provided
     7# directory. This directory should be on your $PATH if you want to actually
     8# make any use of this script.
     9
    10bin="$1"
    11HACK_TOOLS_TARGET="${HACK_TOOLS_TARGET:-"//hack:tools_to_link"}"
    12
    13echo "linking tools to $1"
    14
    15if [[ "$2" == "$HACK_TOOLS_TARGET" ]]; then
    16    echo "building dev tools..."
    17    # if its the filegroup with the required set of dev tools, dont perform
    18    # the additional _binary query because it dont work
    19
    20    # shellcheck disable=SC2207
    21    targets=($(bazel cquery --output=files "$HACK_TOOLS_TARGET"))
    22else
    23    # remove specific _linux variants (relying on host configuration) defined for 
    24    # binaries and remove container binaries from link targets. we only want to link
    25    # whatever binaries would be built for the host platform.
    26
    27    echo "querying Bazel expression for binaries to link"
    28
    29    # shellcheck disable=SC2207
    30    targets=($(bazel cquery --output=files "kind(.*_binary, ${2})" | grep -Ev "_linux|container.binary"))
    31fi
    32
    33
    34for b in "${targets[@]}"; do
    35    dst="${bin}/$(basename "$b")"
    36    rm -f "$dst"
    37    ln -sf "$PWD/$b" "$dst"
    38    echo "$b --> $dst"
    39done 

View as plain text