diff options
author | 2016-08-10 22:15:27 +0000 | |
---|---|---|
committer | 2016-08-11 09:16:33 +0000 | |
commit | fbaa700337bf0cf9083f083e6cd0d2f82faf1506 (patch) | |
tree | 4f7179d3a8b9781393d94ba30f9c8392cacf004c /src/main | |
parent | cfd61cf9b12089804118a45eabbf329880ea4641 (diff) |
Expose test "data" attribute to IDE.
This is needed to deploy android_tests to the device for testing. For
symmetry we expose it for all tests rules.
--
MOS_MIGRATED_REVID=129918247
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java | 18 | ||||
-rw-r--r-- | src/main/protobuf/android_studio_ide_info.proto | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java b/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java index 8f29d09ae8..12c47a9dab 100644 --- a/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java @@ -386,6 +386,10 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config if (attr != null) { builder.setSize(attr); } + Collection<Artifact> data = getDataListAttribute(ruleContext, "data"); + for (Artifact artifact : data) { + builder.addData(makeArtifactLocation(artifact)); + } outputBuilder.setTestInfo(builder); } @@ -797,6 +801,20 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config return getStringListAttribute(ruleContext, "copts"); } + private static boolean hasDataModeAttribute(RuleContext ruleContext, + String attributeName, Type<?> type) { + return ruleContext.attributes().has(attributeName, type) + && ruleContext.getAttributeMode(attributeName) == Mode.DATA; + } + + private static Collection<Artifact> getDataListAttribute(RuleContext ruleContext, + String attributeName) { + return hasDataModeAttribute(ruleContext, attributeName, BuildType.LABEL_LIST) + ? ruleContext.getPrerequisiteArtifacts(attributeName, Mode.DATA).list() + : ImmutableList.<Artifact>of(); + } + + private static Collection<Artifact> getTargetListAttribute(RuleContext ruleContext, String attributeName) { return (ruleContext.attributes().has(attributeName, BuildType.LABEL_LIST) diff --git a/src/main/protobuf/android_studio_ide_info.proto b/src/main/protobuf/android_studio_ide_info.proto index 07c86a53e0..1a65ac8456 100644 --- a/src/main/protobuf/android_studio_ide_info.proto +++ b/src/main/protobuf/android_studio_ide_info.proto @@ -100,6 +100,7 @@ message ProtoLibraryLegacyJavaIdeInfo { message TestInfo { string size = 1; + repeated ArtifactLocation data = 2; } message JavaToolchainIdeInfo { |