[build] joint (step 2)

- dist:
  - compiler
  - tools(cinterop,klib)
  - stdlib
  - cache
This commit is contained in:
Vasily Levchenko
2020-11-16 16:40:45 +01:00
parent c85c3ac123
commit 840c1e612c
14 changed files with 112 additions and 61 deletions

View File

@@ -106,6 +106,10 @@ sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourc
kotlin.srcDir("../kotlin-native/build-tools/src/main/kotlin")
kotlin.srcDir("../kotlin-native/build-tools/src/tmp/kotlin")
kotlin.srcDir("../kotlin-native/tools/kotlin-native-gradle-plugin/src/main/kotlin")
kotlin.srcDir("../compiler/util-klib/src")
kotlin.srcDir(project.kotlinNativeVersionSrc())
kotlin.srcDir("../native/utils/src")
kotlin.exclude("**/benchmark/SwiftBenchmarkingPlugin.kt")
}
tasks.validatePlugins.configure {
@@ -148,8 +152,6 @@ dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-cio:$ktorVersion")
api("org.jetbrains.kotlin:kotlin-native-utils:$kotlinVersion")
implementation("org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion")
}
@@ -167,7 +169,10 @@ java {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs += listOf(
"-Xopt-in=kotlin.RequiresOptIn", "-Xskip-runtime-version-check", "-Xsuppress-version-warnings"
"-Xopt-in=kotlin.RequiresOptIn",
"-Xskip-runtime-version-check",
"-Xsuppress-version-warnings",
"-Xopt-in=kotlin.ExperimentalStdlibApi"
)
}

View File

@@ -31,8 +31,11 @@ dependencies {
api project(path: ":kotlin-native:endorsedLibraries:kotlinx.cli", configuration: "jvmRuntimeElements")
api project(":kotlin-stdlib")
api project(":kotlin-compiler")
api project(kotlinCompilerModule)
api project(":kotlinx-metadata-klib")
api project(":native:kotlin-native-utils")
implementation(project(":compiler:util"))
implementation(project(":compiler:ir.serialization.common"))
testImplementation "junit:junit:4.12"
testImplementation project(":kotlin-test:kotlin-test-junit")
@@ -44,3 +47,13 @@ compileKotlin {
allWarningsAsErrors=true
}
}
sourceSets{
main {
kotlin {
srcDir("../../shared/src/library/kotlin")
srcDir("../../shared/src/main/kotlin")
srcDir("../../../buildSrc/src/generated/kotlin")
}
}
}

View File

@@ -21,13 +21,6 @@ apply plugin: 'kotlin'
apply plugin: org.jetbrains.kotlin.NativeInteropPlugin
apply plugin: "maven-publish"
// (gets applied to this project and all its subprojects)
allprojects {
repositories {
maven { url project.bootstrapKotlinRepo }
}
}
sourceSets {
compiler {
proto.srcDir 'compiler/ir/backend.native/src/'
@@ -37,6 +30,9 @@ sourceSets {
}
kotlin {
srcDir 'compiler/ir/backend.native/src/'
srcDir '../shared/src/main/kotlin'
srcDir '../shared/src/library/kotlin'
srcDir '../../buildSrc/src/generated/kotlin'
}
resources.srcDir 'compiler/ir/backend.native/resources/'
}
@@ -114,7 +110,7 @@ kotlinNativeInterop {
}
files {
if (!project.parent.convention.plugins.platformInfo.isWindows()) {
if (!project.project(":kotlin-native").convention.plugins.platformInfo.isWindows()) {
compilerOpts '-fPIC'
linkerOpts '-fPIC'
}
@@ -147,13 +143,14 @@ configurations {
cli_bc {
extendsFrom cli_bcRuntime
}
cli_bcCompile.extendsFrom compilerCompile
}
dependencies {
trove4j_jar "org.jetbrains.intellij.deps:trove4j:1.0.20181211@jar"
kotlin_compiler_jar project(":kotlin-compiler")
kotlin_stdlib_jar project(":kotlin-stdlib")
kotlin_reflect_jar project(":kotlin-reflect")
kotlin_compiler_jar project(kotlinCompilerModule)
kotlin_stdlib_jar kotlinStdLibModule
kotlin_reflect_jar kotlinReflectModule
kotlin_script_runtime_jar project(":kotlin-script-runtime")
[kotlinCommonStdlibModule, kotlinTestCommonModule, kotlinTestAnnotationsCommonModule].each {
@@ -164,15 +161,44 @@ dependencies {
compilerCompile "com.google.protobuf:protobuf-java:${protobufVersion}"
compilerCompile project(":kotlin-compiler")
compilerCompile project(kotlinCompilerModule)
compilerCompile project(":native:kotlin-native-utils")
compilerCompile project(":core:descriptors")
compilerCompile project(":compiler:ir.tree")
compilerCompile project(":compiler:ir.tree.impl")
compilerCompile project(":compiler:ir.backend.common")
compilerCompile project(":compiler:util")
compilerCompile project(":native:frontend.native")
compilerCompile project(":compiler:cli-common")
compilerCompile project(":compiler:cli")
compilerCompile project(":kotlin-util-klib")
compilerCompile project(":kotlin-util-klib-metadata")
compilerCompile project(":compiler:ir.serialization.common")
use(LocalDependenciesKt) {
compilerCompile(intellijCoreDep()){
artifact {
name = "intellij-core"
type = "jar"
}
}
compilerCompile(intellijDep()){
artifact {
name = "util"
type = "jar"
//extention = "jar"
}
}
compileOnly(jpsStandalone())
}
compilerCompile kotlinNativeInterop['llvm'].configuration
compilerCompile kotlinNativeInterop['hash'].configuration
compilerCompile kotlinNativeInterop['files'].configuration
cli_bcCompile project(":kotlin-compiler")
cli_bcCompile sourceSets.compiler.output
bc_frontendCompile kotlinCompilerModule
bc_frontendCompile project(kotlinCompilerModule)
cli_bc sourceSets.cli_bc.output
}
@@ -184,12 +210,7 @@ classes.dependsOn 'compilerClasses', 'cli_bcClasses', 'bc_frontendClasses'
// These are just a couple of aliases
task stdlib(dependsOn: "${hostName}Stdlib")
def commonSrc = file('build/stdlib')
task unzipStdlibSources(type: CopyCommonSources) {
outputDir commonSrc
sourcePaths configurations.kotlinCommonSources
}
def commonSrc = project(":kotlin-stdlib-common").files("src/kotlin", "src/generated", "../unsigned/src", "../src").files
final List<File> stdLibSrc = [
project(':kotlin-native:Interop:Runtime').file('src/main/kotlin'),
@@ -220,6 +241,8 @@ targetList.each { target ->
include "*.jar"
}
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', '-XXLanguage:+AllowContractsForCustomFunctions',
@@ -227,14 +250,19 @@ targetList.each { target ->
'-Xopt-in=kotlin.contracts.ExperimentalContracts',
'-Xopt-in=kotlin.ExperimentalMultiplatform',
'-Xallow-result-return-type',
commonSrc.absolutePath,
"-Xcommon-sources=${commonSrc.absolutePath}",
*commonSrc.toList(),
*testAnnotationCommon.toList(),
*testCommon.toList(),
"-Xcommon-sources=${commonSrc.join(',')}",
"-Xcommon-sources=${testAnnotationCommon.join(',')}",
"-Xcommon-sources=${testCommon.join(',')}",
*stdLibSrc]
stdLibSrc.forEach { inputs.dir(it) }
inputs.dir(commonSrc)
commonSrc.forEach{
inputs.dir(it)
}
outputs.dir(project(':kotlin-native:runtime').file("build/${target}Stdlib"))
dependsOn 'unzipStdlibSources'
dependsOn ":kotlin-native:runtime:${target}Runtime"
dependsOn ":kotlin-native:distCompiler"
}
@@ -253,7 +281,7 @@ jar {
sourceSets.filesInteropStubs.output,
sourceSets.llvmInteropStubs.output
dependsOn ':runtime:hostRuntime', 'external_jars'
dependsOn ':kotlin-native:runtime:hostRuntime', 'external_jars'
}
def externalJars = ['compiler', 'stdlib', 'reflect', 'script_runtime']

View File

@@ -207,7 +207,7 @@ class NamedNativeInteropConfig implements Named {
).asPath
// Set the konan.home property because we run the cinterop tool not from a distribution jar
// so it will not be able to determine this path by itself.
systemProperties "konan.home": project.rootProject.projectDir
systemProperties "konan.home": project.project(":kotlin-native").projectDir
environment "LIBCLANG_DISABLE_CRASH_RECOVERY": "1"
outputs.dir generatedSrcDir

View File

@@ -466,7 +466,7 @@ open class KonanDynamicTest : KonanStandaloneTest() {
val execResult = plugin.execKonanClang(project.testTarget, Action<ExecSpec> {
workingDir = File(outputDirectory)
executable = clangTool
this@Action.executable = clangTool
args = listOf(processCSource(),
"-c",
"-o", "${this@KonanDynamicTest.executable}.o",

View File

@@ -32,7 +32,7 @@ object PlatformInfo {
@JvmStatic
fun getTarget(project: Project): KonanTarget {
val platformManager = project.rootProject.platformManager
val platformManager = project.project(":kotlin-native").platformManager
val targetName = project.project.testTarget.name
return platformManager.targetManager(targetName).target
}

View File

@@ -65,7 +65,7 @@ if (isMac()) {
}
ext {
distDir = file('dist')
distDir = rootProject.file('dist')
dependenciesDir = DependencyProcessor.defaultDependenciesRoot
experimentalEnabled = project.hasProperty("org.jetbrains.kotlin.native.experimentalTargets")
platformManager = new PlatformManager(DistributionKt.buildDistribution(projectDir.absolutePath),
@@ -82,7 +82,7 @@ ext {
KonanTarget.LINUX_MIPSEL32.INSTANCE
]
kotlinCompilerModule= project(":kotlin-compiler")
kotlinCompilerModule= [path: ":kotlin-compiler", configuration: "runtimeElements"]
kotlinStdLibModule= project(":kotlin-stdlib")
kotlinCommonStdlibModule= project(":kotlin-stdlib-common")
kotlinTestCommonModule= project(":kotlin-test:kotlin-test-common")
@@ -220,7 +220,7 @@ dependencies {
distPack project(':kotlin-native:Interop:Runtime')
distPack project(':kotlin-native:Interop:Indexer')
distPack project(':kotlin-native:Interop:StubGenerator')
//distPack project(':kotlin-native:backend.native')
distPack project(':kotlin-native:backend.native')
distPack project(':kotlin-native:utilities:cli-runner')
distPack project(':kotlin-native:utilities:basic-utils')
distPack project(':kotlin-native:klib')
@@ -341,7 +341,7 @@ task detectJarCollision(type: CollisionDetector) {
}
task shadowJar(type: ShadowJar) {
dependsOn ':detectJarCollision'
//dependsOn ':kotlin-native:detectJarCollision'
mergeServiceFiles()
destinationDirectory.set(file("$distDir/konan/lib"))
archiveBaseName.set("kotlin-native")
@@ -356,7 +356,7 @@ task shadowJar(type: ShadowJar) {
}
task distCompiler(type: Copy) {
dependsOn ':shadowJar'
dependsOn ':kotlin-native:shadowJar'
destinationDir distDir

View File

@@ -67,8 +67,8 @@ targetList.each { target ->
compilerDistributionPath.set(distDir)
dependsOn "${target}EndorsedLibraries"
dependsOn ":${target}CrossDistRuntime"
dependsOn ":${target}StdlibCache"
dependsOn ":kotlin-native:${target}CrossDistRuntime"
dependsOn ":kotlin-native:${target}StdlibCache"
cacheTask.dependsOn it
}

View File

@@ -16,5 +16,5 @@ configurations {
}
project.dependencies {
kotlinCompilerClasspath(project(":kotlin-compiler-embeddable"))
kotlinCompilerClasspath(project(path: ":kotlin-compiler-embeddable", configuration: "runtimeJar"))
}

View File

@@ -59,7 +59,7 @@ rootProject.project("kotlin-native").ext.platformManager.enabled.each { target -
it.originalKlib = file("$konanHome/klib/common/stdlib")
it.cacheRoot = file("$konanHome/klib/cache")
it.dependsOn ":${targetName}CrossDistRuntime"
it.dependsOn ":kotlin-native:${targetName}CrossDistRuntime"
}
}
@@ -86,7 +86,7 @@ rootProject.project("kotlin-native").ext.platformManager.enabled.each { target -
def libTask = konanArtifacts."$libName"."$targetName"
libTask.configure {
it.dependsOn df.config.depends.collect { defFileToLibName(targetName, it) }
it.dependsOn ":${targetName}CrossDist"
it.dependsOn ":kotlin-native:${targetName}CrossDist"
it.enableParallel = true
}
@@ -104,7 +104,7 @@ rootProject.project("kotlin-native").ext.platformManager.enabled.each { target -
it.originalKlib = tasks[libName].installDir.get()
it.cacheRoot = file("$konanHome/klib/cache")
it.dependsOn ":${targetName}StdlibCache"
it.dependsOn ":kotlin-native:${targetName}StdlibCache"
it.dependsOn tasks[libName]
it.dependsOn df.config.depends.collect {
def depName = defFileToLibName(targetName, it)

View File

@@ -28,7 +28,7 @@ val targetList: List<String> by project
bitcode {
create("runtime", file("src/main")) {
dependsOn(
":common:${target}Hash",
":kotlin-native:common:${target}Hash",
"${target}StdAlloc",
"${target}OptAlloc",
"${target}Mimalloc",

View File

@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.gradle.plugin.konan
import org.gradle.api.Named
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.Action
import org.gradle.process.JavaExecSpec
import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin.ProjectProperty.KONAN_HOME
import org.jetbrains.kotlin.konan.target.Family
import org.jetbrains.kotlin.konan.target.HostManager
@@ -91,21 +93,23 @@ internal abstract class KonanCliRunner(
"Please change it to the compiler root directory and rerun the build.")
}
project.javaexec {
main = this@KonanCliRunner.mainClass
classpath = classpath
jvmArgs(jvmArgs)
systemProperties(
System.getProperties().asSequence()
.map { (k, v) -> k.toString() to v.toString() }
.filter { (k, _) -> k !in blacklistProperties }
.escapeQuotesForWindows()
.toMap()
)
args(listOf(toolName) + transformArgs(args))
blacklistEnvironment.forEach { environment.remove(it) }
environment(environment)
}
project.javaexec(object :Action<JavaExecSpec> {
override fun execute(exec: JavaExecSpec) {
exec.main = mainClass
exec.classpath = classpath
exec.jvmArgs(jvmArgs)
exec.systemProperties(
System.getProperties().asSequence()
.map { (k, v) -> k.toString() to v.toString() }
.filter { (k, _) -> k !in this@KonanCliRunner.blacklistProperties }
.escapeQuotesForWindows()
.toMap()
)
exec.args(listOf(toolName) + transformArgs(args))
this@KonanCliRunner.blacklistEnvironment.forEach { environment.remove(it) }
exec.environment(environment)
}
})
}
}

View File

@@ -21,5 +21,6 @@ tasks.named<KotlinCompile>("compileKotlin") {
dependencies {
api(project(":kotlin-stdlib"))
implementation(project(":kotlin-compiler"))
implementation(project(project.project(":kotlin-native").extra["kotlinCompilerModule"] as Map<String, *>))
implementation(project(":compiler:util"))
}

View File

@@ -16,7 +16,7 @@ open class HostManager(
constructor(
distribution: Distribution,
experimental: Boolean = false,
experimental: Boolean = false
) : this(distribution.subTargetProvider, experimental || distribution.experimentalEnabled)
fun targetManager(userRequest: String? = null): TargetManager = TargetManagerImpl(userRequest, this)