[K/N][gradle][interop] Arg to specify relative dir for libraryPath
This commit is contained in:
+3
@@ -27,6 +27,7 @@ const val NODEFAULTLIBS = "no-default-libs"
|
|||||||
const val NOENDORSEDLIBS = "no-endorsed-libs"
|
const val NOENDORSEDLIBS = "no-endorsed-libs"
|
||||||
const val PURGE_USER_LIBS = "Xpurge-user-libs"
|
const val PURGE_USER_LIBS = "Xpurge-user-libs"
|
||||||
const val TEMP_DIR = "Xtemporary-files-dir"
|
const val TEMP_DIR = "Xtemporary-files-dir"
|
||||||
|
const val PROJECT_DIR = "Xproject-dir"
|
||||||
const val NOPACK = "nopack"
|
const val NOPACK = "nopack"
|
||||||
const val COMPILE_SOURCES = "Xcompile-source"
|
const val COMPILE_SOURCES = "Xcompile-source"
|
||||||
const val SHORT_MODULE_NAME = "Xshort-module-name"
|
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)
|
description = "Don't pack the produced library into a klib file").default(false)
|
||||||
val tempDir by argParser.option(ArgType.String, TEMP_DIR,
|
val tempDir by argParser.option(ArgType.String, TEMP_DIR,
|
||||||
description = "save temporary files to the given directory")
|
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",
|
val kotlincOption by argParser.option(ArgType.String, "Xkotlinc-option",
|
||||||
description = "additional kotlinc compiler option").multiple()
|
description = "additional kotlinc compiler option").multiple()
|
||||||
val overrideKonanProperties by argParser.option(ArgType.String,
|
val overrideKonanProperties by argParser.option(ArgType.String,
|
||||||
|
|||||||
+7
-1
@@ -45,6 +45,7 @@ import java.io.File
|
|||||||
import java.lang.IllegalArgumentException
|
import java.lang.IllegalArgumentException
|
||||||
import java.nio.file.*
|
import java.nio.file.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.io.path.absolutePathString
|
||||||
|
|
||||||
data class InternalInteropOptions(val generated: String, val natives: String, val manifest: String? = null,
|
data class InternalInteropOptions(val generated: String, val natives: String, val manifest: String? = null,
|
||||||
val cstubsName: String? = null)
|
val cstubsName: String? = null)
|
||||||
@@ -235,7 +236,12 @@ private fun processCLib(flavor: KotlinPlatform, cinteropArguments: CInteropArgum
|
|||||||
val excludedFunctions = def.config.excludedFunctions.toSet()
|
val excludedFunctions = def.config.excludedFunctions.toSet()
|
||||||
val excludedMacros = def.config.excludedMacros.toSet()
|
val excludedMacros = def.config.excludedMacros.toSet()
|
||||||
val staticLibraries = def.config.staticLibraries + cinteropArguments.staticLibrary.toTypedArray()
|
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('.')
|
val fqParts = (cinteropArguments.pkg ?: def.config.packageName)?.split('.')
|
||||||
?: defFile!!.name.split('.').reversed().drop(1)
|
?: defFile!!.name.split('.').reversed().drop(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user