diff options
author | Xin Li <delphij@google.com> | 2023-01-11 22:47:00 -0800 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2023-01-11 22:47:00 -0800 |
commit | 2da232539ec461417d686e182e7c5134137138a3 (patch) | |
tree | bc04dda0b7461d63470e79a641f9a54537b0309f | |
parent | 4ac0c760bbce9b91b85288ae80a33966ef852f40 (diff) | |
parent | 228096f806ad6f7d06450d2f6cc9940b54e07f0f (diff) | |
download | kotlinx.coroutines-2da232539ec461417d686e182e7c5134137138a3.tar.gz |
Merge tm-qpr-dev-plus-aosp-without-vendor@9467136temp_273316506_tm-qpr2
Bug: 264720040
Merged-In: I5b1f7fdac0270c86807b4838cefb1e69f5e0ddff
Change-Id: Ibe0a2af016b0c7e9e9935e190f3d8938e48b3871
-rw-r--r-- | Android.bp | 68 |
1 files changed, 50 insertions, 18 deletions
@@ -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,15 +139,15 @@ 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 // Android tree. java_library { @@ -134,25 +163,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 +196,9 @@ java_library { ], apex_available: [ "//apex_available:platform", - "//apex_available:anyapex" + "//apex_available:anyapex", ], + visibility: ["//visibility:public"], } filegroup { |