[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 interopRuntimeCommonSrcDir = project(":kotlin-native:Interop:Runtime").file("src/main/kotlin")
|
||||||
val interopSrcDir = listOf(
|
val interopSrcDirs = listOf(
|
||||||
interopRuntimeCommonSrcDir,
|
|
||||||
project(":kotlin-native:Interop:Runtime").file("src/native/kotlin"),
|
project(":kotlin-native:Interop:Runtime").file("src/native/kotlin"),
|
||||||
project(":kotlin-native:Interop:JsRuntime").file("src/main/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 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 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.file("src/main/kotlin"),
|
||||||
project(":kotlin-stdlib-common").file("../native-wasm/src/")
|
project(":kotlin-stdlib-common").file("../native-wasm/src/")
|
||||||
)
|
)
|
||||||
@@ -419,27 +418,16 @@ konanArtifacts {
|
|||||||
"-opt-in=kotlin.native.SymbolNameIsDeprecated"
|
"-opt-in=kotlin.native.SymbolNameIsDeprecated"
|
||||||
)
|
)
|
||||||
srcFiles(commonBuiltinsSrc)
|
srcFiles(commonBuiltinsSrc)
|
||||||
commonStdlibSrcDirs.forEach { extraOpts(it) }
|
commonStdlibSrcDirs.forEach { commonSrcDir(it) }
|
||||||
testAnnotationCommonSrcDir.forEach { extraOpts(it) }
|
testAnnotationCommonSrcDir.forEach { commonSrcDir(it) }
|
||||||
testCommonSrcDir.forEach { extraOpts(it) }
|
testCommonSrcDir.forEach { commonSrcDir(it) }
|
||||||
extraOpts(interopRuntimeCommonSrcDir)
|
commonSrcDir(interopRuntimeCommonSrcDir)
|
||||||
extraOpts(
|
|
||||||
"-Xcommon-sources=${commonStdlibSrcDirs.joinToString(",")}",
|
|
||||||
"-Xcommon-sources=${testAnnotationCommonSrcDir.joinToString(",")}",
|
|
||||||
"-Xcommon-sources=${testCommonSrcDir.joinToString(",")}",
|
|
||||||
"-Xcommon-sources=$interopRuntimeCommonSrcDir",
|
|
||||||
)
|
|
||||||
stdLibSrcDirs.forEach { srcDir(it) }
|
stdLibSrcDirs.forEach { srcDir(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
stdlibBuildTask = project.findKonanBuildTask("stdlib", project.platformManager.hostPlatform.target).apply {
|
stdlibBuildTask = project.findKonanBuildTask("stdlib", project.platformManager.hostPlatform.target).apply {
|
||||||
configure {
|
configure {
|
||||||
dependsOn(":kotlin-native:distCompiler")
|
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 {
|
doLast {
|
||||||
// Change target in manifest file
|
// Change target in manifest file
|
||||||
with(KFile(destinationDir.resolve("default/manifest").absolutePath)) {
|
with(KFile(destinationDir.resolve("default/manifest").absolutePath)) {
|
||||||
loadProperties().also {
|
val props = loadProperties()
|
||||||
it[KLIB_PROPERTY_NATIVE_TARGETS] = targetName
|
props[KLIB_PROPERTY_NATIVE_TARGETS] = targetName
|
||||||
saveProperties(it)
|
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 commonSourceSets(vararg sourceSetNames: String) = tasks().forEach { it.configure { commonSourceSets(*sourceSetNames) } }
|
||||||
override fun enableMultiplatform(flag: Boolean) = tasks().forEach { it.configure { enableMultiplatform(flag) } }
|
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(values: List<String>) = tasks().forEach { it.configure { linkerOpts(values) } }
|
||||||
override fun linkerOpts(vararg values: 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 commonSourceSet(sourceSetName: String)
|
||||||
fun commonSourceSets(vararg sourceSetNames: String)
|
fun commonSourceSets(vararg sourceSetNames: String)
|
||||||
|
|
||||||
|
fun commonSrcDir(dir: Any)
|
||||||
|
|
||||||
|
fun commonSrcFiles(vararg files: Any)
|
||||||
|
fun commonSrcFiles(files: Collection<Any>)
|
||||||
|
|
||||||
// DSL. Other parameters.
|
// DSL. Other parameters.
|
||||||
|
|
||||||
fun linkerOpts(vararg values: String)
|
fun linkerOpts(vararg values: String)
|
||||||
|
|||||||
+8
-1
@@ -282,10 +282,17 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
|||||||
enableMultiplatform(true)
|
enableMultiplatform(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun commonSrcDir(dir: Any) {
|
override fun commonSrcDir(dir: Any) {
|
||||||
commonSrcFiles_.add(directoryToKt(dir))
|
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.
|
// DSL. Other parameters.
|
||||||
|
|
||||||
override fun linkerOpts(values: List<String>) = linkerOpts(*values.toTypedArray())
|
override fun linkerOpts(values: List<String>) = linkerOpts(*values.toTypedArray())
|
||||||
|
|||||||
Reference in New Issue
Block a user