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.
|
* 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 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 compilerVersion [KLIB_PROPERTY_COMPILER_VERSION]
|
||||||
* @property abiVersion [KLIB_PROPERTY_ABI_VERSION]
|
* @property abiVersion [KLIB_PROPERTY_ABI_VERSION]
|
||||||
* @property libraryVersion [KLIB_PROPERTY_LIBRARY_VERSION]
|
* @property libraryVersion [KLIB_PROPERTY_LIBRARY_VERSION]
|
||||||
@@ -20,9 +20,20 @@ import org.jetbrains.kotlin.library.*
|
|||||||
@ExperimentalLibraryAbiReader
|
@ExperimentalLibraryAbiReader
|
||||||
data class LibraryManifest(
|
data class LibraryManifest(
|
||||||
val platform: String?,
|
val platform: String?,
|
||||||
val nativeTargets: List<String>,
|
val platformTargets: List<LibraryTarget>,
|
||||||
val compilerVersion: String?,
|
val compilerVersion: String?,
|
||||||
val abiVersion: String?,
|
val abiVersion: String?,
|
||||||
val libraryVersion: String?,
|
val libraryVersion: String?,
|
||||||
val irProviderName: 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
|
val versions = library.versions
|
||||||
return LibraryManifest(
|
return LibraryManifest(
|
||||||
platform = library.builtInsPlatform?.name,
|
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,
|
compilerVersion = versions.compilerVersion,
|
||||||
abiVersion = versions.abiVersion?.toString(),
|
abiVersion = versions.abiVersion?.toString(),
|
||||||
libraryVersion = versions.libraryVersion,
|
libraryVersion = versions.libraryVersion,
|
||||||
|
|||||||
+11
@@ -37,9 +37,20 @@ internal class AbiRendererImpl(
|
|||||||
|
|
||||||
if (settings.renderManifest) {
|
if (settings.renderManifest) {
|
||||||
with(libraryAbi.manifest) {
|
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(
|
listOfNotNull(
|
||||||
platform?.let { "Platform" to it },
|
platform?.let { "Platform" to it },
|
||||||
nativeTargets.takeIf { it.isNotEmpty() }?.let { "Native targets" to it.joinToString(separator = ", ") },
|
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 },
|
compilerVersion?.let { "Compiler version" to it },
|
||||||
abiVersion?.let { "ABI version" to it },
|
abiVersion?.let { "ABI version" to it },
|
||||||
libraryVersion?.let { "Library version" to it },
|
libraryVersion?.let { "Library version" to it },
|
||||||
|
|||||||
+22
-8
@@ -39,7 +39,7 @@ class ManifestReadingTest {
|
|||||||
val testData = mapOf(
|
val testData = mapOf(
|
||||||
"sample-library-1" to LibraryManifest(
|
"sample-library-1" to LibraryManifest(
|
||||||
platform = BuiltInsPlatform.JS.name,
|
platform = BuiltInsPlatform.JS.name,
|
||||||
nativeTargets = emptyList(),
|
platformTargets = emptyList(),
|
||||||
compilerVersion = "1.23.45",
|
compilerVersion = "1.23.45",
|
||||||
abiVersion = "2.34.56",
|
abiVersion = "2.34.56",
|
||||||
libraryVersion = "3.45.67",
|
libraryVersion = "3.45.67",
|
||||||
@@ -47,7 +47,14 @@ class ManifestReadingTest {
|
|||||||
),
|
),
|
||||||
"sample-library-2" to LibraryManifest(
|
"sample-library-2" to LibraryManifest(
|
||||||
platform = BuiltInsPlatform.NATIVE.name,
|
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,
|
compilerVersion = null,
|
||||||
abiVersion = null,
|
abiVersion = null,
|
||||||
libraryVersion = null,
|
libraryVersion = null,
|
||||||
@@ -82,18 +89,25 @@ class ManifestReadingTest {
|
|||||||
moduleName = libraryName,
|
moduleName = libraryName,
|
||||||
versions = libraryVersioning,
|
versions = libraryVersioning,
|
||||||
builtInsPlatform = builtInsPlatform,
|
builtInsPlatform = builtInsPlatform,
|
||||||
nativeTargets = libraryManifest.nativeTargets,
|
nativeTargets = libraryManifest.platformTargets.filterIsInstance<LibraryTarget.Native>().map { it.name },
|
||||||
nopack = true,
|
nopack = true,
|
||||||
shortName = libraryName,
|
shortName = libraryName,
|
||||||
layout = libraryLayout
|
layout = libraryLayout
|
||||||
)
|
)
|
||||||
libraryManifest.irProviderName?.let { irProviderName ->
|
|
||||||
library.addManifestAddend(
|
library.addManifestAddend(
|
||||||
Properties().apply {
|
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
|
this[KLIB_PROPERTY_IR_PROVIDER] = irProviderName
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
library.addIr(SerializedIrModule(files = emptyList())) // Empty library.
|
library.addIr(SerializedIrModule(files = emptyList())) // Empty library.
|
||||||
library.commit()
|
library.commit()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user