From fbaa700337bf0cf9083f083e6cd0d2f82faf1506 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 10 Aug 2016 22:15:27 +0000 Subject: 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 --- .../build/lib/ideinfo/AndroidStudioInfoAspect.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/java') 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 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 getDataListAttribute(RuleContext ruleContext, + String attributeName) { + return hasDataModeAttribute(ruleContext, attributeName, BuildType.LABEL_LIST) + ? ruleContext.getPrerequisiteArtifacts(attributeName, Mode.DATA).list() + : ImmutableList.of(); + } + + private static Collection getTargetListAttribute(RuleContext ruleContext, String attributeName) { return (ruleContext.attributes().has(attributeName, BuildType.LABEL_LIST) -- cgit v1.2.3