Use the same 'package' field in manifest as in .def-file.
Eliminate pkg. Use explicit 'interop = true' clause to distingush interop libraries.
This commit is contained in:
committed by
alexander-gorshenev
parent
9d8663a4fa
commit
6cab9a1038
+19
-1
@@ -142,6 +142,18 @@ private fun Properties.storeProperties(file: File) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Properties.putAndRunOnReplace(key: Any, newValue: Any, beforeReplace: (Any, Any, Any) -> Unit) {
|
||||||
|
val oldValue = this[key]
|
||||||
|
if (oldValue != null && oldValue!! != newValue) {
|
||||||
|
beforeReplace(key, oldValue!!, newValue)
|
||||||
|
}
|
||||||
|
this[key] = newValue
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun warn(msg: String) {
|
||||||
|
println("warning: $msg")
|
||||||
|
}
|
||||||
|
|
||||||
private fun usage() {
|
private fun usage() {
|
||||||
println("""
|
println("""
|
||||||
Run interop tool with -def <def_file_for_lib>.def
|
Run interop tool with -def <def_file_for_lib>.def
|
||||||
@@ -318,7 +330,13 @@ private fun processLib(args: Map<String, List<String>>,
|
|||||||
|
|
||||||
// TODO: if a library has partially included headers, then it shouldn't be used as a dependency.
|
// TODO: if a library has partially included headers, then it shouldn't be used as a dependency.
|
||||||
def.manifestAddendProperties["includedHeaders"] = nativeIndex.includedHeaders.joinToString(" ") { it.value }
|
def.manifestAddendProperties["includedHeaders"] = nativeIndex.includedHeaders.joinToString(" ") { it.value }
|
||||||
def.manifestAddendProperties["pkg"] = outKtPkg
|
|
||||||
|
def.manifestAddendProperties.putAndRunOnReplace("package", outKtPkg) {
|
||||||
|
key, oldValue, newValue ->
|
||||||
|
warn("The package value `$oldValue` specified in .def file is overriden with explicit $newValue")
|
||||||
|
}
|
||||||
|
|
||||||
|
def.manifestAddendProperties["interop"] = "true"
|
||||||
|
|
||||||
gen.addManifestProperties(def.manifestAddendProperties)
|
gen.addManifestProperties(def.manifestAddendProperties)
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -39,7 +39,9 @@ interface InteropLibrary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun createInteropLibrary(reader: KonanLibraryReader): InteropLibrary? {
|
fun createInteropLibrary(reader: KonanLibraryReader): InteropLibrary? {
|
||||||
val pkg = reader.manifestProperties.getProperty("pkg") ?: return null
|
if (reader.manifestProperties.getProperty("interop") != "true") return null
|
||||||
|
val pkg = reader.manifestProperties.getProperty("package")
|
||||||
|
?: error("Inconsistent manifest: interop library ${reader.libraryName} should have `package` specified")
|
||||||
val exportForwardDeclarations = reader.manifestProperties
|
val exportForwardDeclarations = reader.manifestProperties
|
||||||
.getProperty("exportForwardDeclarations").split(' ')
|
.getProperty("exportForwardDeclarations").split(' ')
|
||||||
.map { it.trim() }.filter { it.isNotEmpty() }
|
.map { it.trim() }.filter { it.isNotEmpty() }
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ fun invokeCinterop(args: Array<String>) {
|
|||||||
val library = KonanLibrary(it.libraryFile)
|
val library = KonanLibrary(it.libraryFile)
|
||||||
val manifestProperties = library.manifestFile.loadProperties()
|
val manifestProperties = library.manifestFile.loadProperties()
|
||||||
// TODO: handle missing properties?
|
// TODO: handle missing properties?
|
||||||
manifestProperties["pkg"]?.let {
|
manifestProperties["package"]?.let {
|
||||||
val pkg = it as String
|
val pkg = it as String
|
||||||
val headerIds = (manifestProperties["includedHeaders"] as String).split(' ')
|
val headerIds = (manifestProperties["includedHeaders"] as String).split(' ')
|
||||||
val arg = "$pkg:${headerIds.joinToString(",")}"
|
val arg = "$pkg:${headerIds.joinToString(",")}"
|
||||||
|
|||||||
Reference in New Issue
Block a user