Skip to content

Commit

Permalink
Remove special case for --run_under
Browse files Browse the repository at this point in the history
This commit removes the special case for `--run_under` which tried to
find a runfile directory beside the currently executing script. This
isn't needed because the runfiles bash script should set RUNFILES_DIR
to the right thing anyway
  • Loading branch information
mishazharov committed Jan 15, 2024
1 parent b8c9dea commit 9ec9c91
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions foreign_cc/private/runnable_binary_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
#!/usr/bin/env bash

# RUN_UNDER_RUNFILES is set in the "bazel test" environment, where all transitive runfiles are placed into one directory
# Otherwise, first cd to the runfiles dir for the wrapped executable before searching for shared libraries for the wrapped executable
if [[ -z $RUN_UNDER_RUNFILES ]]; then
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
RUNFILES_DIR_TMP=${SCRIPT_DIR}/SH_BINARY_FILENAME.runfiles

if [[ -d "$RUNFILES_DIR_TMP" ]]; then
RUNFILES_DIR="$RUNFILES_DIR_TMP"
fi

unset RUNFILES_DIR_TMP
fi

if [[ -n "$RUNFILES_DIR" ]] && [[ -d "$RUNFILES_DIR" ]]; then
cd ${RUNFILES_DIR}
else
cd "$(pwd)"
fi

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2. (@bazel_tools//tools/bash/runfiles)
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
Expand All @@ -30,6 +11,8 @@ source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---

cd "${RUNFILES_DIR}"

EXE=EXECUTABLE
EXE_PATH=$(rlocation "${EXE#external/}")

Expand Down Expand Up @@ -71,5 +54,4 @@ if [ ${#SHARED_LIBS_DIRS_ARRAY[@]} -ne 0 ]; then
fi

cd - &> /dev/null

exec ${EXE_PATH} "$@"

0 comments on commit 9ec9c91

Please sign in to comment.