diff options
author | 2018-01-23 08:53:11 -0800 | |
---|---|---|
committer | 2018-01-23 08:55:06 -0800 | |
commit | 96a9a2baa31da9d11e3cdaf152241991ae832f35 (patch) | |
tree | e7acad49d63ef2b83e2846a077344ba75cec458d | |
parent | d452163286e9e4936ed9e5a83ef2f009a3535df4 (diff) |
Pass the correct path of aapt_binary and merge its data runfiles into android_instrumentation_test's runfiles.
GITHUB: #903
RELNOTES: None.
PiperOrigin-RevId: 182940009
3 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java index 33dee6c938..96ea978498 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java @@ -85,7 +85,7 @@ public class AndroidInstrumentationTest implements RuleConfiguredTargetFactory { .addTargets(runfilesDeps, RunfilesProvider.DEFAULT_RUNFILES) .addTransitiveArtifacts(AndroidCommon.getSupportApks(ruleContext)) .addTransitiveArtifacts(getAdb(ruleContext).getFilesToRun()) - .addTransitiveArtifacts(getAapt(ruleContext).getFilesToRun()) + .merge(getAapt(ruleContext).getRunfilesSupport()) .addArtifacts(getDataDeps(ruleContext)) .build(); @@ -121,6 +121,7 @@ public class AndroidInstrumentationTest implements RuleConfiguredTargetFactory { .add(Substitution.of("%workspace%", ruleContext.getWorkspaceName())) .add(Substitution.of("%test_label%", ruleContext.getLabel().getCanonicalForm())) .add(executableSubstitution("%adb%", getAdb(ruleContext))) + .add(executableSubstitution("%aapt%", getAapt(ruleContext))) .add(executableSubstitution("%device_script%", getTargetDevice(ruleContext))) .add(executableSubstitution("%test_entry_point%", getTestEntryPoint(ruleContext))) .add(artifactSubstitution("%target_apk%", getTargetApk(ruleContext))) diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt b/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt index 07dd76ce6b..b2863c1f35 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt +++ b/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt @@ -44,7 +44,7 @@ test_entry_point="%test_entry_point%" log_levels="%log_levels%" WORKSPACE_DIR="${TEST_SRCDIR}/%workspace%" adb="${WORKSPACE_DIR}/%adb%" -aapt="${WORKSPACE_DIR}/../../external/androidsdk/aapt_binary" +aapt="${WORKSPACE_DIR}/%aapt%" device_script="${WORKSPACE_DIR}/%device_script%" data_deps="%data_deps%" diff --git a/tools/android/android_sdk_repository_template.bzl b/tools/android/android_sdk_repository_template.bzl index 637bbf2978..2d847fe133 100644 --- a/tools/android/android_sdk_repository_template.bzl +++ b/tools/android/android_sdk_repository_template.bzl @@ -168,6 +168,13 @@ def create_android_sdk_rules( # there's no runfiles support so Bazel just creates a junction to # {SDK}/build-tools. "SDK=$${0}.runfiles/%s" % name, + # If $${SDK} is not a directory, it means that this tool is running + # from a runfiles directory, in the case of + # android_instrumentation_test. Hence, use the androidsdk + # that's already present in the runfiles of the current context. + "if [[ ! -d $${SDK} ]] ; then", + " SDK=$$(pwd)/../%s" % name, + "fi", "exec $${SDK}/build-tools/%s/%s $$*" % (build_tools_directory, tool), "EOF\n"]), ) |