diff options
author | 2018-01-04 22:01:33 -0800 | |
---|---|---|
committer | 2018-01-04 22:03:44 -0800 | |
commit | e4b9ca042432e3ab5c105aba1f63c462ba0a3093 (patch) | |
tree | 51eff723059493020d88cd063ba43953806ed430 /src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java | |
parent | 9e63684a58025d98bfe2f180d56ba7ece69545ae (diff) |
Merge the runfiles of @androidsdk//:aapt_binary into android_instrumentation_test's runfiles, and pass the execpath of aapt_binary to the entry point using the --aapt flag.
This allows android_instrumentation_test to use the dynamically linked AAPT from the user-provided SDK.
The reason for not using %aapt% template expansion in the stub template is because @androidsdk//:aapt_binary is a shell script with hardcoded paths to the actual dependencies in its runfiles directory, but since this binary is called within an android_instrumentation_test's runfiles directory, the nested aapt runfiles directory doesn't exist because runfiles are not nested, but merged.
We can make this work by referring to the actual external/androidsdk/aapt_binary using a `../../` directory traversal, and we can also assume that the aapt_binary is there because android_instrumentation_test merged aapt's runfiles from the SDK.
RELNOTES: None.
PiperOrigin-RevId: 180888739
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java | 6 |
1 files changed, 6 insertions, 0 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 cc3d44e9fc..33dee6c938 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,6 +85,7 @@ public class AndroidInstrumentationTest implements RuleConfiguredTargetFactory { .addTargets(runfilesDeps, RunfilesProvider.DEFAULT_RUNFILES) .addTransitiveArtifacts(AndroidCommon.getSupportApks(ruleContext)) .addTransitiveArtifacts(getAdb(ruleContext).getFilesToRun()) + .addTransitiveArtifacts(getAapt(ruleContext).getFilesToRun()) .addArtifacts(getDataDeps(ruleContext)) .build(); @@ -251,6 +252,11 @@ public class AndroidInstrumentationTest implements RuleConfiguredTargetFactory { return AndroidSdkProvider.fromRuleContext(ruleContext).getAdb(); } + /** AAPT binary from the Android SDK. */ + private static FilesToRunProvider getAapt(RuleContext ruleContext) { + return AndroidSdkProvider.fromRuleContext(ruleContext).getAapt(); + } + /** Map of {@code test_args} for the test runner to make available to test test code. */ private static ImmutableMap<String, String> getTestArgs(RuleContext ruleContext) { return ImmutableMap.copyOf(ruleContext.attributes().get("test_args", Type.STRING_DICT)); |