[K/N][build] Add common sources setting to Konan plugin
Used for stdlib build
This commit is contained in:
@@ -387,8 +387,7 @@ val commonBuiltinsSrc = listOf(
|
||||
}
|
||||
|
||||
val interopRuntimeCommonSrcDir = project(":kotlin-native:Interop:Runtime").file("src/main/kotlin")
|
||||
val interopSrcDir = listOf(
|
||||
interopRuntimeCommonSrcDir,
|
||||
val interopSrcDirs = listOf(
|
||||
project(":kotlin-native:Interop:Runtime").file("src/native/kotlin"),
|
||||
project(":kotlin-native:Interop:JsRuntime").file("src/main/kotlin")
|
||||
)
|
||||
@@ -396,7 +395,7 @@ val interopSrcDir = listOf(
|
||||
val testAnnotationCommonSrcDir = project(":kotlin-test:kotlin-test-annotations-common").files("src/main/kotlin").files
|
||||
val testCommonSrcDir = project(":kotlin-test:kotlin-test-common").files("src/main/kotlin").files
|
||||
|
||||
val stdLibSrcDirs = interopSrcDir + listOf(
|
||||
val stdLibSrcDirs = interopSrcDirs + listOf(
|
||||
project.file("src/main/kotlin"),
|
||||
project(":kotlin-stdlib-common").file("../native-wasm/src/")
|
||||
)
|
||||
@@ -419,27 +418,16 @@ konanArtifacts {
|
||||
"-opt-in=kotlin.native.SymbolNameIsDeprecated"
|
||||
)
|
||||
srcFiles(commonBuiltinsSrc)
|
||||
commonStdlibSrcDirs.forEach { extraOpts(it) }
|
||||
testAnnotationCommonSrcDir.forEach { extraOpts(it) }
|
||||
testCommonSrcDir.forEach { extraOpts(it) }
|
||||
extraOpts(interopRuntimeCommonSrcDir)
|
||||
extraOpts(
|
||||
"-Xcommon-sources=${commonStdlibSrcDirs.joinToString(",")}",
|
||||
"-Xcommon-sources=${testAnnotationCommonSrcDir.joinToString(",")}",
|
||||
"-Xcommon-sources=${testCommonSrcDir.joinToString(",")}",
|
||||
"-Xcommon-sources=$interopRuntimeCommonSrcDir",
|
||||
)
|
||||
commonStdlibSrcDirs.forEach { commonSrcDir(it) }
|
||||
testAnnotationCommonSrcDir.forEach { commonSrcDir(it) }
|
||||
testCommonSrcDir.forEach { commonSrcDir(it) }
|
||||
commonSrcDir(interopRuntimeCommonSrcDir)
|
||||
stdLibSrcDirs.forEach { srcDir(it) }
|
||||
}
|
||||
|
||||
stdlibBuildTask = project.findKonanBuildTask("stdlib", project.platformManager.hostPlatform.target).apply {
|
||||
configure {
|
||||
dependsOn(":kotlin-native:distCompiler")
|
||||
|
||||
// Configure inputs and outputs
|
||||
stdLibSrcDirs.forEach { inputs.dir(it) }
|
||||
commonStdlibSrcDirs.forEach { inputs.dir(it) }
|
||||
outputs.dir(project.buildDir.resolve("stdlib"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -462,10 +450,9 @@ targetList.forEach { targetName ->
|
||||
doLast {
|
||||
// Change target in manifest file
|
||||
with(KFile(destinationDir.resolve("default/manifest").absolutePath)) {
|
||||
loadProperties().also {
|
||||
it[KLIB_PROPERTY_NATIVE_TARGETS] = targetName
|
||||
saveProperties(it)
|
||||
}
|
||||
val props = loadProperties()
|
||||
props[KLIB_PROPERTY_NATIVE_TARGETS] = targetName
|
||||
saveProperties(props)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -56,6 +56,10 @@ abstract class KonanCompileConfig<T: KonanCompileTask>(name: String,
|
||||
override fun commonSourceSets(vararg sourceSetNames: String) = tasks().forEach { it.configure { commonSourceSets(*sourceSetNames) } }
|
||||
override fun enableMultiplatform(flag: Boolean) = tasks().forEach { it.configure { enableMultiplatform(flag) } }
|
||||
|
||||
override fun commonSrcDir(dir: Any) = tasks().forEach { it.configure { commonSrcDir(dir) } }
|
||||
override fun commonSrcFiles(vararg files: Any) = tasks().forEach { it.configure { commonSrcFiles(*files) } }
|
||||
override fun commonSrcFiles(files: Collection<Any>) = tasks().forEach { it.configure { commonSrcFiles(files) } }
|
||||
|
||||
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { linkerOpts(values) } }
|
||||
override fun linkerOpts(vararg values: String) = tasks().forEach { it.configure { linkerOpts(*values) } }
|
||||
|
||||
|
||||
+5
@@ -61,6 +61,11 @@ interface KonanCompileSpec: KonanBuildingSpec {
|
||||
fun commonSourceSet(sourceSetName: String)
|
||||
fun commonSourceSets(vararg sourceSetNames: String)
|
||||
|
||||
fun commonSrcDir(dir: Any)
|
||||
|
||||
fun commonSrcFiles(vararg files: Any)
|
||||
fun commonSrcFiles(files: Collection<Any>)
|
||||
|
||||
// DSL. Other parameters.
|
||||
|
||||
fun linkerOpts(vararg values: String)
|
||||
|
||||
+8
-1
@@ -282,10 +282,17 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
enableMultiplatform(true)
|
||||
}
|
||||
|
||||
internal fun commonSrcDir(dir: Any) {
|
||||
override fun commonSrcDir(dir: Any) {
|
||||
commonSrcFiles_.add(directoryToKt(dir))
|
||||
}
|
||||
|
||||
override fun commonSrcFiles(vararg files: Any) {
|
||||
commonSrcFiles_.add(project.files(files))
|
||||
}
|
||||
|
||||
override fun commonSrcFiles(files: Collection<Any>) = commonSrcFiles(*files.toTypedArray())
|
||||
|
||||
|
||||
// DSL. Other parameters.
|
||||
|
||||
override fun linkerOpts(values: List<String>) = linkerOpts(*values.toTypedArray())
|
||||
|
||||
Reference in New Issue
Block a user