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:
Alexander Gorshenev
2017-10-13 14:41:07 +03:00
committed by alexander-gorshenev
parent 9d8663a4fa
commit 6cab9a1038
3 changed files with 23 additions and 3 deletions
@@ -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() {
println("""
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.
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)
@@ -39,7 +39,9 @@ interface 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
.getProperty("exportForwardDeclarations").split(' ')
.map { it.trim() }.filter { it.isNotEmpty() }
@@ -69,7 +69,7 @@ fun invokeCinterop(args: Array<String>) {
val library = KonanLibrary(it.libraryFile)
val manifestProperties = library.manifestFile.loadProperties()
// TODO: handle missing properties?
manifestProperties["pkg"]?.let {
manifestProperties["package"]?.let {
val pkg = it as String
val headerIds = (manifestProperties["includedHeaders"] as String).split(' ')
val arg = "$pkg:${headerIds.joinToString(",")}"