[K/N][build] Add noPack option to Konan plugin
Make plugin aware of -nopack compiler option to correctly set outputs without .klib suffix.
This commit is contained in:
@@ -404,14 +404,20 @@ val stdLibSrcDirs = interopSrcDirs + listOf(
|
||||
project(":kotlin-stdlib-common").file("../native-wasm/src/")
|
||||
)
|
||||
|
||||
val args = listOf("-nopack", "-nostdlib", "-no-default-libs", "-no-endorsed-libs", /* -Werror (TODO: check) */)
|
||||
val args = listOf<String>(/* -Werror (TODO: check) */)
|
||||
|
||||
lateinit var stdlibBuildTask: TaskProvider<Task>
|
||||
|
||||
konanArtifacts {
|
||||
library("stdlib") {
|
||||
baseDir(project.buildDir.resolve("stdlib"))
|
||||
|
||||
enableMultiplatform(true)
|
||||
noStdLib(true)
|
||||
noPack(true)
|
||||
noDefaultLibs(true)
|
||||
noEndorsedLibs(true)
|
||||
|
||||
extraOpts(args + project.globalBuildArgs)
|
||||
extraOpts(
|
||||
"-module-name", "stdlib",
|
||||
@@ -421,6 +427,7 @@ konanArtifacts {
|
||||
"-opt-in=kotlin.native.internal.InternalForKotlinNative",
|
||||
"-opt-in=kotlin.native.SymbolNameIsDeprecated"
|
||||
)
|
||||
|
||||
srcFiles(commonBuiltinsSrc)
|
||||
commonStdlibSrcDirs.forEach { commonSrcDir(it) }
|
||||
testAnnotationCommonSrcDir.forEach { commonSrcDir(it) }
|
||||
|
||||
+1
@@ -66,6 +66,7 @@ abstract class KonanCompileConfig<T: KonanCompileTask>(name: String,
|
||||
override fun enableDebug(flag: Boolean) = tasks().forEach { it.configure { enableDebug(flag) } }
|
||||
override fun noStdLib(flag: Boolean) = tasks().forEach { it.configure { noStdLib(flag) } }
|
||||
override fun noMain(flag: Boolean) = tasks().forEach { it.configure { noMain(flag) } }
|
||||
override fun noPack(flag: Boolean) = tasks().forEach { it.configure { noPack(flag) } }
|
||||
override fun enableOptimizations(flag: Boolean) = tasks().forEach { it.configure { enableOptimizations(flag) } }
|
||||
override fun enableAssertions(flag: Boolean) = tasks().forEach { it.configure { enableAssertions(flag) } }
|
||||
|
||||
|
||||
+1
@@ -74,6 +74,7 @@ interface KonanCompileSpec: KonanBuildingSpec {
|
||||
fun enableDebug(flag: Boolean)
|
||||
fun noStdLib(flag: Boolean)
|
||||
fun noMain(flag: Boolean)
|
||||
fun noPack(flag: Boolean)
|
||||
fun enableOptimizations(flag: Boolean)
|
||||
fun enableAssertions(flag: Boolean)
|
||||
|
||||
|
||||
+13
-1
@@ -82,6 +82,7 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
|
||||
@Input var noStdLib = false
|
||||
@Input var noMain = false
|
||||
@Input var noPack: Boolean = false
|
||||
@Input var enableOptimizations = project.environmentVariables.enableOptimizations
|
||||
@Input var enableAssertions = false
|
||||
|
||||
@@ -187,7 +188,7 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
}
|
||||
|
||||
/** Args passed to the compiler at both stages of the two-stage compilation and during the singe-stage compilation. */
|
||||
protected fun buildCommonArgs() = mutableListOf<String>().apply {
|
||||
protected open fun buildCommonArgs() = mutableListOf<String>().apply {
|
||||
addArgs("-repo", libraries.repos.map { it.canonicalPath })
|
||||
|
||||
if (platformConfiguration.files.isNotEmpty()) {
|
||||
@@ -312,6 +313,10 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
noMain = flag
|
||||
}
|
||||
|
||||
override fun noPack(flag: Boolean) {
|
||||
noPack = flag
|
||||
}
|
||||
|
||||
override fun enableOptimizations(flag: Boolean) {
|
||||
enableOptimizations = flag
|
||||
}
|
||||
@@ -386,6 +391,13 @@ open class KonanCompileFrameworkTask: KonanCompileNativeBinary() {
|
||||
}
|
||||
|
||||
open class KonanCompileLibraryTask: KonanCompileTask() {
|
||||
override val artifactSuffix: String
|
||||
@Internal get() = if (!noPack) produce.suffix(konanTarget) else ""
|
||||
|
||||
override fun buildCommonArgs() = super.buildCommonArgs().apply {
|
||||
addKey("-nopack", noPack)
|
||||
}
|
||||
|
||||
override val produce: CompilerOutputKind get() = CompilerOutputKind.LIBRARY
|
||||
override val enableTwoStageCompilation: Boolean = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user