Skip to content

Commit

Permalink
Collect kotlin stdlib while building deps and track in sync
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 567033706
  • Loading branch information
Googler authored and copybara-github committed Sep 21, 2023
1 parent 60b46f3 commit a31129f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 7 deletions.
3 changes: 2 additions & 1 deletion aspect/build_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ FOLLOW_ATTRIBUTES_BY_RULE_KIND = [
("_aspect_proto_toolchain_for_javalite", []),
("_aspect_java_proto_toolchain", []),
("runtime", ["proto_lang_toolchain", "java_rpc_toolchain"]),
("_toolchain", ["_java_grpc_library", "_java_lite_grpc_library"]),
("_toolchain", ["_java_grpc_library", "_java_lite_grpc_library", "kt_jvm_library_helper", "android_library"]),
("kotlin_libs", ["kt_jvm_toolchain"]),
]

FOLLOW_ATTRIBUTES = [attr for (attr, _) in FOLLOW_ATTRIBUTES_BY_RULE_KIND]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public abstract class QuerySummary {
* <p>Whenever changing the logic in this class such that the Query.Summary proto contents will be
* different for the same input, this version should be incremented.
*/
@VisibleForTesting public static final int PROTO_VERSION = 5;
@VisibleForTesting public static final int PROTO_VERSION = 6;

public static final QuerySummary EMPTY =
create(Query.Summary.newBuilder().setVersion(PROTO_VERSION).build());
Expand All @@ -96,7 +96,12 @@ public abstract class QuerySummary {
// need to always need to traverse the attribute.
private static final ImmutableMap<String, ImmutableSet<String>> RULE_SCOPED_ATTRIBUTES =
ImmutableMap.of(
"$toolchain", ImmutableSet.of("_java_grpc_library", "_java_lite_grpc_library"));
"$toolchain",
ImmutableSet.of(
"_java_grpc_library",
"_java_lite_grpc_library",
"kt_jvm_library_helper",
"android_library"));

// Runtime dependency attributes
private static final ImmutableSet<String> RUNTIME_DEP_ATTRIBUTES =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ public void testAndroidLibrary() throws Exception {
assertThat(graph.getTargetOwners(TESTDATA_ROOT.resolve("android/TestAndroidClass.java")))
.containsExactly(Label.of("//" + TESTDATA_ROOT + "/android:android"));
assertThat(graph.getFileDependencies(TESTDATA_ROOT.resolve("android/TestAndroidClass.java")))
.isEmpty();
assertThat(graph.projectDeps()).isEmpty();
.containsExactly(
Label.of(
"//third_party/bazel_rules/rules_kotlin/toolchains/kotlin_jvm:kt_jvm_toolchain_linux_sts_jdk"));
assertThat(graph.projectDeps())
.containsExactly(
Label.of(
"//third_party/bazel_rules/rules_kotlin/toolchains/kotlin_jvm:kt_jvm_toolchain_linux_sts_jdk"));
}

@Test
Expand All @@ -175,9 +180,16 @@ public void testProjectAndroidLibrariesWithAidlSource_areProjectDeps() throws Ex
.containsExactly(TESTDATA_ROOT.resolve("aidl/TestAndroidAidlClass.java"));
assertThat(graph.getAndroidSourceFiles())
.containsExactly(TESTDATA_ROOT.resolve("aidl/TestAndroidAidlClass.java"));
assertThat(graph.projectDeps()).containsExactly(Label.of("//" + TESTDATA_ROOT + "/aidl:aidl"));
assertThat(graph.projectDeps())
.containsExactly(
Label.of(
"//third_party/bazel_rules/rules_kotlin/toolchains/kotlin_jvm:kt_jvm_toolchain_linux_sts_jdk"),
Label.of("//" + TESTDATA_ROOT + "/aidl:aidl"));
assertThat(graph.getFileDependencies(TESTDATA_ROOT.resolve("aidl/TestAndroidAidlClass.java")))
.containsExactly(Label.of("//" + TESTDATA_ROOT + "/aidl:aidl"));
.containsExactly(
Label.of(
"//third_party/bazel_rules/rules_kotlin/toolchains/kotlin_jvm:kt_jvm_toolchain_linux_sts_jdk"),
Label.of("//" + TESTDATA_ROOT + "/aidl:aidl"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("@build_bazel_rules_android//android:rules.bzl", "android_library")

android_library(
name = "kotlinandroidlib",
srcs = ["TestKotlinAndroidLib.kt"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.idea.blaze.qsync.testdata.kotlinandroidlib

val aList: List<String> = listOf("A", "B", "C")
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("//tools/build_defs/kotlin:rules.bzl", "kt_jvm_library")

kt_jvm_library(
name = "kotlinlib",
srcs = ["TestKotlinLib.kt"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.idea.blaze.qsync.testdata.kotlinlib

val aList: List<Int> = listOf(1, 2, 3)

0 comments on commit a31129f

Please sign in to comment.