Skip to content

Commit

Permalink
Mount TreeArtifact directories as inputs to Spawns.
Browse files Browse the repository at this point in the history
Fixes bazelbuild#1928.

--
PiperOrigin-RevId: 141077737
MOS_MIGRATED_REVID=141077737
  • Loading branch information
aj-michael authored and damienmg committed Dec 6, 2016
1 parent c645a45 commit 3f008a0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ void mountInputs(
}
}

// ActionInputHelper#expandArtifacts above expands empty TreeArtifacts into an empty list.
// However, actions that accept TreeArtifacts as inputs generally expect that the empty
// directory is created. So here we explicitly mount the directories of the TreeArtifacts as
// inputs.
for (ActionInput input : spawn.getInputFiles()) {
if (input instanceof Artifact && ((Artifact) input).isTreeArtifact()) {
PathFragment mount = new PathFragment(input.getExecPathString());
mounts.put(mount, execRoot.getRelative(mount));
}
}

for (ActionInput input : inputs) {
if (input.getExecPathString().contains("internal/_middlemen/")) {
continue;
Expand Down
23 changes: 23 additions & 0 deletions src/test/shell/bazel/android/android_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,29 @@ function test_android_binary_clang() {
check_soname
}

# Regression test for https://github.com/bazelbuild/bazel/issues/1928.
function test_empty_tree_artifact_action_inputs_mount_empty_directories() {
create_new_workspace
setup_android_support
cat > AndroidManifest.xml <<EOF
<manifest package="com.test"/>
EOF
mkdir res
zip test.aar AndroidManifest.xml res/
cat > BUILD <<EOF
aar_import(
name = "test",
aar = "test.aar",
)
EOF
# Building aar_import invokes the AndroidResourceProcessingAction with a
# TreeArtifact of the AAR resources as the input. Since there are no
# resources, the Bazel sandbox should create an empty directory. If the
# directory is not created, the action thinks that its inputs do not exist and
# crashes.
bazel build :test
}

# ndk r10 and earlier
if [[ ! -r "${TEST_SRCDIR}/androidndk/ndk/RELEASE.TXT" ]]; then
# ndk r11 and later
Expand Down

0 comments on commit 3f008a0

Please sign in to comment.