aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/ideinfo
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2016-02-24 22:52:03 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-02-25 14:14:10 +0000
commit5a0c721d56640d1a447ebdab82383b8e30cd7800 (patch)
tree5526eeb955e646bc6b662c0122ab554d5963529c /src/test/java/com/google/devtools/build/lib/ideinfo
parentf6a387cf5816602b9f6ad3283f15e33e44a71d9d (diff)
Expose information about transitive exports.
Also implement handling of exports in Skylark aspects and enable remaining tests (except PackageManifest and deprecated non-hermetic stuff). -- MOS_MIGRATED_REVID=115496333
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/ideinfo')
-rw-r--r--src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java16
-rw-r--r--src/test/java/com/google/devtools/build/lib/ideinfo/intellij_info.bzl79
2 files changed, 44 insertions, 51 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java b/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java
index 7c5db1f69d..fda62bd5a1 100644
--- a/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java
+++ b/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java
@@ -229,10 +229,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase
@Test
public void testJavaLibraryWithExports() throws Exception {
- if (!isNativeTest()) {
- return;
- }
-
scratch.file(
"com/google/example/BUILD",
"java_library(",
@@ -281,10 +277,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase
@Test
public void testJavaLibraryWithTransitiveExports() throws Exception {
- if (!isNativeTest()) {
- return;
- }
-
scratch.file(
"com/google/example/BUILD",
"java_library(",
@@ -369,10 +361,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase
@Test
public void testJavaImportWithExports() throws Exception {
- if (!isNativeTest()) {
- return;
- }
-
scratch.file(
"com/google/example/BUILD",
"java_library(",
@@ -844,10 +832,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase
@Test
public void testAndroidLibraryWithoutSourcesExportsDependencies() throws Exception {
- if (!isNativeTest()) {
- return;
- }
-
scratch.file(
"java/com/google/example/BUILD",
"android_library(",
diff --git a/src/test/java/com/google/devtools/build/lib/ideinfo/intellij_info.bzl b/src/test/java/com/google/devtools/build/lib/ideinfo/intellij_info.bzl
index 248d0e1d88..1e2e82e621 100644
--- a/src/test/java/com/google/devtools/build/lib/ideinfo/intellij_info.bzl
+++ b/src/test/java/com/google/devtools/build/lib/ideinfo/intellij_info.bzl
@@ -85,7 +85,6 @@ def build_file_artifact_location(build_file_path):
is_source = True,
)
-
def library_artifact(java_output):
if java_output == None or java_output.class_jar == None:
return None
@@ -109,6 +108,8 @@ def jars_from_output(output):
if jar != None and not jar.is_source]
def java_rule_ide_info(target, ctx):
+ if not hasattr(target, "java"):
+ return (None, set())
if hasattr(ctx.rule.attr, "srcs"):
sources = [artifact_location(file)
for src in ctx.rule.attr.srcs
@@ -154,19 +155,27 @@ def android_rule_ide_info(target, ctx):
),
ide_resolve_files)
-def collect_transitive_labels(rule_attrs, attr_list):
- return [str(dep.label)
- for attr_name in attr_list
- if hasattr(rule_attrs, attr_name)
- for dep in getattr(rule_attrs, attr_name)]
+def collect_labels(rule_attrs, attr_list):
+ return set([str(dep.label)
+ for attr_name in attr_list
+ if hasattr(rule_attrs, attr_name)
+ for dep in getattr(rule_attrs, attr_name)])
+
+def collect_export_deps(rule_attrs):
+ result = set()
+ for attr_name in DEPS:
+ if hasattr(rule_attrs, attr_name):
+ for dep in getattr(rule_attrs, attr_name):
+ result = result | dep.export_deps
+ return result
def _aspect_impl(target, ctx):
kind = get_kind(target, ctx)
rule_attrs = ctx.rule.attr
- compiletime_deps = collect_transitive_labels(rule_attrs, DEPS)
- runtime_deps = collect_transitive_labels(rule_attrs, RUNTIME_DEPS)
+ compiletime_deps = collect_labels(rule_attrs, DEPS) | collect_export_deps(rule_attrs)
+ runtime_deps = collect_labels(rule_attrs, RUNTIME_DEPS)
ide_info_text = set()
ide_resolve_files = set()
@@ -177,32 +186,31 @@ def _aspect_impl(target, ctx):
ide_info_text = ide_info_text | dep.intellij_info_files.ide_info_text
ide_resolve_files = ide_resolve_files | dep.intellij_info_files.ide_resolve_files
- if kind != _unrecognized_rule:
- if is_java_rule(target, ctx):
- java_rule_ide_info, java_ide_resolve_files = java_rule_ide_info(target, ctx)
- ide_resolve_files = ide_resolve_files | java_ide_resolve_files
-
- android_rule_ide_info, android_ide_resolve_files = android_rule_ide_info(target, ctx)
- ide_resolve_files = ide_resolve_files | android_ide_resolve_files
-
- info = struct_omit_none(
- label = str(target.label),
- kind = kind,
- dependencies = compiletime_deps,
- runtime_deps = runtime_deps,
- build_file_artifact_location = build_file_artifact_location(ctx.build_file_path),
- java_rule_ide_info = java_rule_ide_info,
- android_rule_ide_info = android_rule_ide_info,
- tags = ctx.rule.attr.tags,
- )
- else:
- info = struct(
- label = str(target.label),
- kind = kind,
- dependencies = compiletime_deps,
- runtime_deps = runtime_deps,
- build_file_artifact_location = build_file_artifact_location(ctx.build_file_path),
- )
+ (java_rule_ide_info, java_ide_resolve_files) = java_rule_ide_info(target, ctx)
+ ide_resolve_files = ide_resolve_files | java_ide_resolve_files
+
+ (android_rule_ide_info, android_ide_resolve_files) = android_rule_ide_info(target, ctx)
+ ide_resolve_files = ide_resolve_files | android_ide_resolve_files
+
+ export_deps = set()
+ if hasattr(target, "java"):
+ export_deps = set([str(l) for l in target.java.transitive_exports])
+ # Empty android libraries export all their dependencies.
+ if ctx.rule.kind == "android_library" and \
+ (not hasattr(rule_attrs, "src") or not ctx.rule.attr.src):
+ export_deps = export_deps | compiletime_deps
+
+ info = struct_omit_none(
+ label = str(target.label),
+ kind = kind,
+ dependencies = list(compiletime_deps),
+ runtime_deps = list(runtime_deps),
+ build_file_artifact_location = build_file_artifact_location(ctx.build_file_path),
+ java_rule_ide_info = java_rule_ide_info,
+ android_rule_ide_info = android_rule_ide_info,
+ tags = ctx.rule.attr.tags,
+ )
+
output = ctx.new_file(target.label.name + ".aswb-build.txt")
ctx.file_action(output, info.to_proto())
ide_info_text += set([output])
@@ -215,7 +223,8 @@ def _aspect_impl(target, ctx):
intellij_info_files = struct(
ide_info_text = ide_info_text,
ide_resolve_files = ide_resolve_files,
- )
+ ),
+ export_deps = export_deps,
)
intellij_info_aspect = aspect(implementation = _aspect_impl,