Skip to content

Commit 8616be0

Browse files
oharboeclaude
andcommitted
bazel: resolve runfiles root without hardcoding the workspace name
Gemini: the lint test scripts derived RUNFILES_DIR with ${PWD%/_main}, which strips nothing when the main workspace is not named "_main" (e.g. when OpenROAD is consumed as a dependency), leaving RUNFILES_DIR pointing one level too deep. Strip the last path component with ${PWD%/*} instead — the workspace subdirectory we start in — so the .runfiles root is found regardless of the workspace name. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 83e3846 commit 8616be0

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

bazel/bzl_lint_test.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ GIT="$(realpath "$2")"
1111

1212
# With rules_python's script bootstrap (bootstrap_impl=script), a py_binary
1313
# invoked via its realpath cannot locate its runfiles once we cd away.
14-
# Export the runfiles root we start in (<target>.runfiles/_main) so nested
15-
# tools resolve it from the environment instead.
16-
export RUNFILES_DIR="${RUNFILES_DIR:-${PWD%/_main}}"
14+
# Export the runfiles root (the .runfiles directory) so nested tools
15+
# resolve it from the environment instead. We start in the workspace
16+
# subdirectory of it (<target>.runfiles/<workspace>); strip the last path
17+
# component rather than a hardcoded workspace name so this also holds when
18+
# the workspace is not "_main" (e.g. consumed as a dependency).
19+
export RUNFILES_DIR="${RUNFILES_DIR:-${PWD%/*}}"
1720

1821
# MODULE.bazel must be in the sh_test `data` deps so it appears as a
1922
# runfiles symlink pointing at the real workspace. `readlink` (no -f,

bazel/tcl_lint_test.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ GIT="$(realpath "$2")"
1111

1212
# With rules_python's script bootstrap (bootstrap_impl=script), a py_binary
1313
# invoked via its realpath cannot locate its runfiles once we cd away.
14-
# Export the runfiles root we start in (<target>.runfiles/_main) so nested
15-
# tools resolve it from the environment instead.
16-
export RUNFILES_DIR="${RUNFILES_DIR:-${PWD%/_main}}"
14+
# Export the runfiles root (the .runfiles directory) so nested tools
15+
# resolve it from the environment instead. We start in the workspace
16+
# subdirectory of it (<target>.runfiles/<workspace>); strip the last path
17+
# component rather than a hardcoded workspace name so this also holds when
18+
# the workspace is not "_main" (e.g. consumed as a dependency).
19+
export RUNFILES_DIR="${RUNFILES_DIR:-${PWD%/*}}"
1720

1821
WORKSPACE="$(dirname "$(readlink -f tclint.toml)")"
1922
cd "$WORKSPACE"

0 commit comments

Comments
 (0)