[K/N][build] Move stdlib build to runtime project

Build stdlib with konan plugin in runtime project
This commit is contained in:
Pavel Punegov
2021-10-14 18:19:29 +03:00
committed by Space
parent c30292a472
commit e9b1f7cca1
8 changed files with 114 additions and 96 deletions
-78
View File
@@ -138,84 +138,6 @@ dependencies {
classes.dependsOn 'compilerClasses', 'cli_bcClasses'
// These are just a couple of aliases
task stdlib(dependsOn: "${hostName}Stdlib")
def commonSrc = project(":kotlin-stdlib-common").files("src/kotlin", "src/generated", "../unsigned/src", "../src").files
def commonBuiltinsSrc = project(":core:builtins").files(
["Progressions.kt", "ProgressionIterators.kt", "Range.kt", "Ranges.kt", "internal/progressionUtil.kt"]
.collect { "src/kotlin/$it" }).files
def interopRuntimeCommonSrc = project(':kotlin-native:Interop:Runtime').file('src/main/kotlin')
final List<File> stdLibSrc = [
interopRuntimeCommonSrc,
project(':kotlin-native:Interop:Runtime').file('src/native/kotlin'),
project(':kotlin-native:Interop:JsRuntime').file('src/main/kotlin'),
project(':kotlin-native:runtime').file('src/main/kotlin'),
project(":kotlin-stdlib-common").file('../native-wasm/src/')
]
// These files are built before the 'dist' is complete,
// so we provide a custom value for --runtime
targetList.each { target ->
def konanJvmArgs = [*HostManager.regularJvmArgs]
def defaultArgs = ['-nopack', '-nostdlib', '-no-default-libs', '-no-endorsed-libs',
//Uncomment this '-Werror' when common stdlib will be ready
]
if (target != "wasm32") defaultArgs += '-g'
def konanArgs = [*defaultArgs,
'-target', target,
"-Xruntime=${project(':kotlin-native:runtime').file('build/bitcode/main/' + target + '/runtime.bc')}",
*project.globalBuildArgs]
task("${target}Stdlib", type: JavaExec) {
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
// This task depends on distCompiler, so the compiler jar is already in the dist directory.
classpath = fileTree("${UtilsKt.getKotlinNativeDist(project)}/konan/lib") {
include "*.jar"
}
systemProperties "konan.home": UtilsKt.getKotlinNativeDist(project)
jvmArgs = konanJvmArgs
def testAnnotationCommon = project(":kotlin-test:kotlin-test-annotations-common").files("src/main/kotlin").files
def testCommon = project(":kotlin-test:kotlin-test-common").files("src/main/kotlin").files
args = [*konanArgs,
'-output', project(':kotlin-native:runtime').file("build/${target}Stdlib"),
'-produce', 'library', '-module-name', 'stdlib',
'-Xmulti-platform', '-opt-in=kotlin.RequiresOptIn',
'-opt-in=kotlin.contracts.ExperimentalContracts',
'-opt-in=kotlin.ExperimentalMultiplatform',
'-opt-in=kotlin.native.internal.InternalForKotlinNative',
'-opt-in=kotlin.native.SymbolNameIsDeprecated',
*commonSrc.toList(),
*commonBuiltinsSrc.toList(),
*testAnnotationCommon.toList(),
*testCommon.toList(),
"-Xcommon-sources=${commonSrc.join(',')}",
"-Xcommon-sources=${testAnnotationCommon.join(',')}",
"-Xcommon-sources=${testCommon.join(',')}",
"-Xcommon-sources=$interopRuntimeCommonSrc",
*stdLibSrc]
stdLibSrc.forEach { inputs.dir(it) }
commonSrc.forEach{
inputs.dir(it)
}
outputs.dir(project(':kotlin-native:runtime').file("build/${target}Stdlib"))
dependsOn ":kotlin-native:runtime:${target}Runtime"
dependsOn ":kotlin-native:distCompiler"
}
}
task run {
doLast {
logger.quiet("Run the outer project 'demo' target to compile the test source.")
}
}
jar {
from sourceSets.cli_bc.output,
sourceSets.compiler.output,