API 4 ABI: Dump WASM target names
We need to dump WASM target names exactly as we do it for Native target names. ^KT-66367
This commit is contained in:
committed by
Space Team
parent
d43db973d4
commit
4941094521
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.library.*
|
||||
* Anything that can be retrieved from manifest and that might be helpful to know about the inspected KLIB.
|
||||
*
|
||||
* @property platform [KLIB_PROPERTY_BUILTINS_PLATFORM]
|
||||
* @property nativeTargets [KLIB_PROPERTY_NATIVE_TARGETS]
|
||||
* @property platformTargets [KLIB_PROPERTY_NATIVE_TARGETS], [KLIB_PROPERTY_WASM_TARGETS]
|
||||
* @property compilerVersion [KLIB_PROPERTY_COMPILER_VERSION]
|
||||
* @property abiVersion [KLIB_PROPERTY_ABI_VERSION]
|
||||
* @property libraryVersion [KLIB_PROPERTY_LIBRARY_VERSION]
|
||||
@@ -20,9 +20,20 @@ import org.jetbrains.kotlin.library.*
|
||||
@ExperimentalLibraryAbiReader
|
||||
data class LibraryManifest(
|
||||
val platform: String?,
|
||||
val nativeTargets: List<String>,
|
||||
val platformTargets: List<LibraryTarget>,
|
||||
val compilerVersion: String?,
|
||||
val abiVersion: String?,
|
||||
val libraryVersion: String?,
|
||||
val irProviderName: String?
|
||||
)
|
||||
) {
|
||||
@Deprecated("Use platformTargets instead", ReplaceWith("platformTargets"))
|
||||
val nativeTargets: List<String> get() = platformTargets.filterIsInstance<LibraryTarget.Native>().map { it.name }
|
||||
}
|
||||
|
||||
/**
|
||||
* The concrete platform target that the library supports.
|
||||
*/
|
||||
sealed interface LibraryTarget {
|
||||
data class Native(val name: String) : LibraryTarget
|
||||
data class WASM(val name: String) : LibraryTarget
|
||||
}
|
||||
|
||||
+4
-1
@@ -80,7 +80,10 @@ internal class LibraryAbiReaderImpl(libraryFile: File, filters: List<AbiReadingF
|
||||
val versions = library.versions
|
||||
return LibraryManifest(
|
||||
platform = library.builtInsPlatform?.name,
|
||||
nativeTargets = library.nativeTargets.sorted(),
|
||||
platformTargets = buildList {
|
||||
library.nativeTargets.sorted().mapTo(this, LibraryTarget::Native)
|
||||
library.wasmTargets.sorted().mapTo(this, LibraryTarget::WASM)
|
||||
},
|
||||
compilerVersion = versions.compilerVersion,
|
||||
abiVersion = versions.abiVersion?.toString(),
|
||||
libraryVersion = versions.libraryVersion,
|
||||
|
||||
+11
@@ -37,9 +37,20 @@ internal class AbiRendererImpl(
|
||||
|
||||
if (settings.renderManifest) {
|
||||
with(libraryAbi.manifest) {
|
||||
val nativeTargets = mutableListOf<LibraryTarget.Native>()
|
||||
val wasmTargets = mutableListOf<LibraryTarget.WASM>()
|
||||
|
||||
for (platformTarget in platformTargets) {
|
||||
when (platformTarget) {
|
||||
is LibraryTarget.Native -> nativeTargets += platformTarget
|
||||
is LibraryTarget.WASM -> wasmTargets += platformTarget
|
||||
}
|
||||
}
|
||||
|
||||
listOfNotNull(
|
||||
platform?.let { "Platform" to it },
|
||||
nativeTargets.takeIf { it.isNotEmpty() }?.let { "Native targets" to it.joinToString(separator = ", ") },
|
||||
wasmTargets.takeIf { it.isNotEmpty() }?.let { "WASM targets" to it.joinToString(separator = ", ") },
|
||||
compilerVersion?.let { "Compiler version" to it },
|
||||
abiVersion?.let { "ABI version" to it },
|
||||
libraryVersion?.let { "Library version" to it },
|
||||
|
||||
+22
-8
@@ -39,7 +39,7 @@ class ManifestReadingTest {
|
||||
val testData = mapOf(
|
||||
"sample-library-1" to LibraryManifest(
|
||||
platform = BuiltInsPlatform.JS.name,
|
||||
nativeTargets = emptyList(),
|
||||
platformTargets = emptyList(),
|
||||
compilerVersion = "1.23.45",
|
||||
abiVersion = "2.34.56",
|
||||
libraryVersion = "3.45.67",
|
||||
@@ -47,7 +47,14 @@ class ManifestReadingTest {
|
||||
),
|
||||
"sample-library-2" to LibraryManifest(
|
||||
platform = BuiltInsPlatform.NATIVE.name,
|
||||
nativeTargets = listOf("ios_arm64", "ios_simulator_arm64", "macos_arm64", "macos_x64"),
|
||||
platformTargets = listOf(
|
||||
LibraryTarget.Native("ios_arm64"),
|
||||
LibraryTarget.Native("ios_simulator_arm64"),
|
||||
LibraryTarget.Native("macos_arm64"),
|
||||
LibraryTarget.Native("macos_x64"),
|
||||
LibraryTarget.WASM("wasm-js"),
|
||||
LibraryTarget.WASM("wasm-wasi"),
|
||||
),
|
||||
compilerVersion = null,
|
||||
abiVersion = null,
|
||||
libraryVersion = null,
|
||||
@@ -82,18 +89,25 @@ class ManifestReadingTest {
|
||||
moduleName = libraryName,
|
||||
versions = libraryVersioning,
|
||||
builtInsPlatform = builtInsPlatform,
|
||||
nativeTargets = libraryManifest.nativeTargets,
|
||||
nativeTargets = libraryManifest.platformTargets.filterIsInstance<LibraryTarget.Native>().map { it.name },
|
||||
nopack = true,
|
||||
shortName = libraryName,
|
||||
layout = libraryLayout
|
||||
)
|
||||
libraryManifest.irProviderName?.let { irProviderName ->
|
||||
library.addManifestAddend(
|
||||
Properties().apply {
|
||||
|
||||
library.addManifestAddend(
|
||||
Properties().apply {
|
||||
val wasmTargets = libraryManifest.platformTargets.filterIsInstance<LibraryTarget.WASM>()
|
||||
if (wasmTargets.isNotEmpty()) {
|
||||
this[KLIB_PROPERTY_WASM_TARGETS] = wasmTargets.joinToString(" ") { it.name }
|
||||
}
|
||||
|
||||
libraryManifest.irProviderName?.let { irProviderName ->
|
||||
this[KLIB_PROPERTY_IR_PROVIDER] = irProviderName
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
library.addIr(SerializedIrModule(files = emptyList())) // Empty library.
|
||||
library.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user