1#!/usr/bin/env bash 2 3# --- begin runfiles.bash initialization v3 --- 4# Copy-pasted from the Bazel Bash runfiles library v3. 5set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash 6source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ 7 source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ 8 source "$0.runfiles/$f" 2>/dev/null || \ 9 source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ 10 source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ 11 { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e 12# --- end runfiles.bash initialization v3 --- 13 14 15set -euo pipefail 16 17# MARK - Functions 18 19fail() { 20 echo >&2 "$@" 21 exit 1 22} 23 24# MARK - Args 25 26if [[ "$#" -lt 1 ]]; then 27 fail "Usage: $0 /path/to/bin <args>" 28fi 29RUSTC="$(rlocation "$1")" 30 31# MARK - Test 32DIR=$(mktemp -d "rustc-test-XXXXXXX") 33 34set -x 35echo "fn main() {}" >"$DIR/main.rs" 36cd "$DIR" 37# simulate bazel run with setting BUILD_WORKING_DIRECTORY 38export BUILD_WORKING_DIRECTORY="$PWD" 39"$RUSTC" "main.rs" || 40 fail "Couldn't compile main.rs" 41