aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2023-07-12 21:28:12 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-07-12 21:28:12 +0000
commit2382775e57f4458ea4c5660c206f9bd582c8755e (patch)
tree584243dc6a0eb1867ba4f849c553cc6d2692774d
parentbf4e51def3a19480e9c29b26c9013bfebfcecb34 (diff)
parentefd3fceb6fe6c83b791b038f032addde8a722b87 (diff)
downloadkotlinx.coroutines-2382775e57f4458ea4c5660c206f9bd582c8755e.tar.gz
Reconcile Android.bp with AOSP am: efd3fceb6f
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/kotlinx.coroutines/+/24044163 Change-Id: I8203c6968a8ae9f61b8a28cabb82726b3bf8fc64 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--Android.bp67
1 files changed, 49 insertions, 18 deletions
diff --git a/Android.bp b/Android.bp
index 4ec0261d..a1bf13de 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,6 @@
package {
default_applicable_licenses: ["external_kotlinx.coroutines_license"],
+ default_visibility: ["//visibility:private"],
}
// Added automatically by a large-scale-change that took the approach of
@@ -35,11 +36,11 @@ license {
],
}
-java_library {
- name: "kotlinx_coroutines",
- host_supported: true,
- sdk_version: "current",
- min_sdk_version: "28",
+// Upstream compiles this lib against the JVM bootclasspath; compiling against the Android
+// bootclasspath will fail. Work around this by defining this as a java_library_host, and use
+// java_host_for_device to expose it to Android targets.
+java_library_host {
+ name: "kotlinx_coroutines-host",
srcs: ["kotlinx-coroutines-core/jvm/src/**/*.kt"],
common_srcs: [
"kotlinx-coroutines-core/common/src/**/*.kt",
@@ -53,7 +54,10 @@ java_library {
static_libs: [
"kotlinx_atomicfu",
],
- libs: ["kotlinx-coroutines-android-annotation-stubs"],
+ libs: [
+ "annotations", // for android.annotation.SuppressLint
+ "kotlinx-coroutines-android-annotation-stubs",
+ ],
kotlincflags: [
"-Xmulti-platform",
"-opt-in=kotlin.RequiresOptIn",
@@ -67,13 +71,37 @@ java_library {
],
apex_available: [
"//apex_available:platform",
- "//apex_available:anyapex"
+ "//apex_available:anyapex",
],
+}
+
+// Expose the host library to Android targets. This is generally an unsafe operation; in using
+// this, we are asserting that any host-only code will never be evaluated at runtime on Android.
+// If we're wrong, we will see runtime exceptions.
+java_host_for_device {
+ name: "kotlinx_coroutines-device",
+ libs: ["kotlinx_coroutines-host"],
+}
+
+// Combine host and Android libs back into a single target.
+java_library {
+ name: "kotlinx_coroutines",
+ host_supported: true,
+ sdk_version: "core_current",
+ min_sdk_version: "28",
target: {
host: {
- libs: ["annotations"], // for android.annotation.SuppressLint
+ static_libs: ["kotlinx_coroutines-host"],
+ },
+ android: {
+ static_libs: ["kotlinx_coroutines-device"],
},
},
+ apex_available: [
+ "//apex_available:platform",
+ "//apex_available:anyapex",
+ ],
+ visibility: ["//visibility:public"],
}
java_library {
@@ -94,8 +122,9 @@ java_library {
],
apex_available: [
"//apex_available:platform",
- "//apex_available:anyapex"
+ "//apex_available:anyapex",
],
+ visibility: ["//visibility:public"],
}
java_library {
@@ -110,13 +139,12 @@ java_library {
"-opt-in=kotlinx.coroutines.InternalCoroutinesApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
],
- libs: [
- "kotlinx_coroutines",
- ],
+ libs: ["kotlinx_coroutines"],
apex_available: [
"//apex_available:platform",
- "//apex_available:anyapex"
+ "//apex_available:anyapex",
],
+ visibility: ["//visibility:public"],
}
// Compile stub implementations of annotations used by kotlinx-coroutines but not present in the
@@ -134,25 +162,27 @@ java_library {
java_library {
name: "kotlinx-coroutines-core",
host_supported: true,
- sdk_version: "current",
+ sdk_version: "core_current",
min_sdk_version: "28",
static_libs: ["kotlinx_coroutines"],
apex_available: [
"//apex_available:platform",
- "//apex_available:anyapex"
+ "//apex_available:anyapex",
],
+ visibility: ["//visibility:public"],
}
java_library {
name: "kotlinx-coroutines-core-jvm",
host_supported: true,
- sdk_version: "current",
+ sdk_version: "core_current",
min_sdk_version: "28",
static_libs: ["kotlinx_coroutines"],
apex_available: [
"//apex_available:platform",
- "//apex_available:anyapex"
+ "//apex_available:anyapex",
],
+ visibility: ["//visibility:public"],
}
java_library {
@@ -165,8 +195,9 @@ java_library {
],
apex_available: [
"//apex_available:platform",
- "//apex_available:anyapex"
+ "//apex_available:anyapex",
],
+ visibility: ["//visibility:public"],
}
filegroup {