[K/N][gradle][interop] Arg to specify relative dir for libraryPath

This commit is contained in:
Igor Chevdar
2022-01-13 23:11:17 +05:00
parent 4418d76a0d
commit 41e1fbe971
2 changed files with 10 additions and 1 deletions
@@ -27,6 +27,7 @@ const val NODEFAULTLIBS = "no-default-libs"
const val NOENDORSEDLIBS = "no-endorsed-libs"
const val PURGE_USER_LIBS = "Xpurge-user-libs"
const val TEMP_DIR = "Xtemporary-files-dir"
const val PROJECT_DIR = "Xproject-dir"
const val NOPACK = "nopack"
const val COMPILE_SOURCES = "Xcompile-source"
const val SHORT_MODULE_NAME = "Xshort-module-name"
@@ -63,6 +64,8 @@ open class CommonInteropArguments(val argParser: ArgParser) {
description = "Don't pack the produced library into a klib file").default(false)
val tempDir by argParser.option(ArgType.String, TEMP_DIR,
description = "save temporary files to the given directory")
val projectDir by argParser.option(ArgType.String, PROJECT_DIR,
description = "base directory for relative libraryPath")
val kotlincOption by argParser.option(ArgType.String, "Xkotlinc-option",
description = "additional kotlinc compiler option").multiple()
val overrideKonanProperties by argParser.option(ArgType.String,
@@ -45,6 +45,7 @@ import java.io.File
import java.lang.IllegalArgumentException
import java.nio.file.*
import java.util.*
import kotlin.io.path.absolutePathString
data class InternalInteropOptions(val generated: String, val natives: String, val manifest: String? = null,
val cstubsName: String? = null)
@@ -235,7 +236,12 @@ private fun processCLib(flavor: KotlinPlatform, cinteropArguments: CInteropArgum
val excludedFunctions = def.config.excludedFunctions.toSet()
val excludedMacros = def.config.excludedMacros.toSet()
val staticLibraries = def.config.staticLibraries + cinteropArguments.staticLibrary.toTypedArray()
val libraryPaths = def.config.libraryPaths + cinteropArguments.libraryPath.toTypedArray()
val projectDir = cinteropArguments.projectDir
val libraryPaths = (def.config.libraryPaths + cinteropArguments.libraryPath).map {
if (projectDir == null || Paths.get(it).isAbsolute)
it
else Paths.get(projectDir, it).absolutePathString()
}
val fqParts = (cinteropArguments.pkg ?: def.config.packageName)?.split('.')
?: defFile!!.name.split('.').reversed().drop(1)