Skip to content

Commit 4efeac9

Browse files
lberkicopybara-github
authored andcommitted
Make the Merkle tree computation work in the wake of 7149f57 .
Fixes a bunch of downstream breakages: bazelbuild/continuous-integration#1093 bazelbuild/continuous-integration#1094 bazel-contrib/rules_nodejs#2464 bazel-contrib/rules_python#419 Turns out, the assertion that "Merkle tree computation uses `ActionInput.getExecPath()`" was only mostly correct: there was a place where the key of the input map was used instead. I'm somewhat surprised that this did not show up in our test battery, although, admittedly, "unsound directory as an input file in an external repository" doesn't sound like the most common use case. RELNOTES: None. PiperOrigin-RevId: 358366246
1 parent eeb1576 commit 4efeac9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/main/java/com/google/devtools/build/lib/remote/merkletree/DirectoryTreeBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private static int buildFromActionInputs(
154154

155155
case DIRECTORY:
156156
SortedMap<PathFragment, ActionInput> directoryInputs =
157-
explodeDirectory(path, execRoot);
157+
explodeDirectory(input.getExecPath(), execRoot);
158158
return buildFromActionInputs(
159159
directoryInputs, metadataProvider, execRoot, digestUtil, tree);
160160

src/test/shell/bazel/disk_cache_test.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,29 @@ EOF
6666
assert_equals "0" $(cat "${execution_file}")
6767
}
6868

69+
function test_input_directories_in_external_repo_with_sibling_repository_layout() {
70+
create_new_workspace
71+
l=$TEST_TMPDIR/l
72+
mkdir -p "$l/dir"
73+
touch "$l/WORKSPACE"
74+
touch "$l/dir/f"
75+
cat > "$l/BUILD" <<'EOF'
76+
exports_files(["dir"])
77+
EOF
78+
79+
cat >> WORKSPACE <<EOF
80+
local_repository(name="l", path="$l")
81+
EOF
82+
83+
cat > BUILD <<'EOF'
84+
genrule(name="g", srcs=["@l//:dir"], outs=["go"], cmd="find $< > $@")
85+
EOF
86+
87+
bazel build \
88+
--experimental_sibling_repository_layout \
89+
--disk_cache="$TEST_TMPDIR/cache" \
90+
//:g || fail "build failed"
91+
92+
}
93+
6994
run_suite "local action cache test"

0 commit comments

Comments
 (0)