Move everything under kotlin-native folder
I was forced to manually do update the following files, because otherwise they would be ignored according .gitignore settings. Probably they should be deleted from repo. Interop/.idea/compiler.xml Interop/.idea/gradle.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml Interop/.idea/modules.xml Interop/.idea/modules/Indexer/Indexer.iml Interop/.idea/modules/Runtime/Runtime.iml Interop/.idea/modules/StubGenerator/StubGenerator.iml backend.native/backend.native.iml backend.native/bc.frontend/bc.frontend.iml backend.native/cli.bc/cli.bc.iml backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt backend.native/tests/link/lib/foo.kt backend.native/tests/link/lib/foo2.kt backend.native/tests/teamcity-test.property
This commit is contained in:
@@ -0,0 +1,322 @@
|
||||
import org.jetbrains.kotlin.CopyCommonSources
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
buildscript {
|
||||
apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle"
|
||||
apply plugin: 'project-report'
|
||||
|
||||
dependencies {
|
||||
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8"
|
||||
}
|
||||
}
|
||||
|
||||
String protobufVersion = '2.6.1'
|
||||
apply plugin: "com.google.protobuf"
|
||||
apply plugin: 'java'
|
||||
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 buildKotlinCompilerRepo }
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
compiler {
|
||||
proto.srcDir 'compiler/ir/backend.native/src/'
|
||||
java {
|
||||
srcDir 'compiler/ir/backend.native/src/'
|
||||
srcDir 'build/renamed/source/proto/compiler/java'
|
||||
}
|
||||
kotlin {
|
||||
srcDir 'compiler/ir/backend.native/src/'
|
||||
}
|
||||
resources.srcDir 'compiler/ir/backend.native/resources/'
|
||||
}
|
||||
cli_bc {
|
||||
java.srcDir 'cli.bc/src'
|
||||
kotlin.srcDir 'cli.bc/src'
|
||||
}
|
||||
bc_frontend {
|
||||
java.srcDir 'bc.frontend/src'
|
||||
kotlin.srcDir 'bc.frontend/src'
|
||||
}
|
||||
}
|
||||
|
||||
compileCompilerKotlin {
|
||||
dependsOn('renamePackage')
|
||||
// The protobuf plugin specifies this dependency for java by itself,
|
||||
// but not for Kotlin.
|
||||
dependsOn('generateCompilerProto')
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
kotlinOptions.allWarningsAsErrors=true
|
||||
kotlinOptions.freeCompilerArgs += ['-Xopt-in=kotlin.RequiresOptIn', '-Xopt-in=org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI']
|
||||
}
|
||||
|
||||
compileCompilerJava {
|
||||
dependsOn('renamePackage')
|
||||
}
|
||||
|
||||
task copyGenerated(type: Copy) {
|
||||
dependsOn('generateCompilerProto')
|
||||
from 'build/generated/source/proto/compiler/java'
|
||||
into 'build/renamed/source/proto/compiler/java'
|
||||
filter { line -> line.replaceAll("com.google.protobuf", "org.jetbrains.kotlin.protobuf") }
|
||||
outputs.dir('build/renamed')
|
||||
}
|
||||
|
||||
task deleteGenerated(type: Delete) {
|
||||
dependsOn('copyGenerated')
|
||||
delete 'build/generated/source/proto/compiler/java'
|
||||
}
|
||||
|
||||
task renamePackage {
|
||||
dependsOn('copyGenerated', 'deleteGenerated')
|
||||
}
|
||||
|
||||
kotlinNativeInterop {
|
||||
llvm {
|
||||
dependsOn ":llvmDebugInfoC:debugInfoStaticLibrary"
|
||||
dependsOn ":llvmCoverageMappingC:coverageMappingStaticLibrary"
|
||||
defFile 'llvm.def'
|
||||
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
||||
compilerOpts "-fPIC"
|
||||
compilerOpts "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include", "-I${project(':llvmCoverageMappingC').projectDir}/src/main/include"
|
||||
linkerOpts "-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static", "-L${project(':llvmCoverageMappingC').buildDir}/libs/coverageMapping/static"
|
||||
}
|
||||
|
||||
hash { // TODO: copy-pasted from ':common:compileHash'
|
||||
if (!project.parent.convention.plugins.platformInfo.isWindows()) {
|
||||
compilerOpts '-fPIC'
|
||||
linkerOpts '-fPIC'
|
||||
}
|
||||
linker 'clang++'
|
||||
linkOutputs ":common:${hostName}Hash"
|
||||
|
||||
headers fileTree('../common/src/hash/headers') {
|
||||
include '**/*.h'
|
||||
include '**/*.hpp'
|
||||
}
|
||||
|
||||
pkg 'org.jetbrains.kotlin.backend.konan.hash'
|
||||
}
|
||||
|
||||
files {
|
||||
if (!project.parent.convention.plugins.platformInfo.isWindows()) {
|
||||
compilerOpts '-fPIC'
|
||||
linkerOpts '-fPIC'
|
||||
}
|
||||
linker 'clang++'
|
||||
linkOutputs ":common:${hostName}Files"
|
||||
|
||||
headers fileTree('../common/src/files/headers') {
|
||||
include '**/*.h'
|
||||
include '**/*.hpp'
|
||||
}
|
||||
|
||||
pkg 'org.jetbrains.kotlin.backend.konan.files'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
configurations {
|
||||
kotlin_compiler_jar
|
||||
kotlin_stdlib_jar
|
||||
kotlin_reflect_jar
|
||||
kotlin_script_runtime_jar
|
||||
trove4j_jar
|
||||
kotlinCommonSources
|
||||
|
||||
cli_bcRuntime {
|
||||
extendsFrom compilerRuntime
|
||||
extendsFrom kotlin_script_runtime_jar
|
||||
}
|
||||
|
||||
cli_bc {
|
||||
extendsFrom cli_bcRuntime
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
trove4j_jar "org.jetbrains.intellij.deps:trove4j:1.0.20181211@jar"
|
||||
kotlin_compiler_jar "$kotlinCompilerModule@jar"
|
||||
kotlin_stdlib_jar "$kotlinStdLibModule@jar"
|
||||
kotlin_reflect_jar "$kotlinReflectModule@jar"
|
||||
kotlin_script_runtime_jar "$kotlinScriptRuntimeModule@jar"
|
||||
|
||||
[kotlinCommonStdlibModule, kotlinTestCommonModule, kotlinTestAnnotationsCommonModule].each {
|
||||
kotlinCommonSources(it) { transitive = false }
|
||||
}
|
||||
|
||||
compilerCompile project(":utilities:basic-utils")
|
||||
|
||||
compilerCompile "com.google.protobuf:protobuf-java:${protobufVersion}"
|
||||
|
||||
compilerCompile kotlinCompilerModule
|
||||
compilerCompile kotlinNativeInterop['llvm'].configuration
|
||||
compilerCompile kotlinNativeInterop['hash'].configuration
|
||||
compilerCompile kotlinNativeInterop['files'].configuration
|
||||
compilerCompile "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
||||
|
||||
cli_bcCompile kotlinCompilerModule
|
||||
cli_bcCompile "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
||||
cli_bcCompile sourceSets.compiler.output
|
||||
|
||||
bc_frontendCompile kotlinCompilerModule
|
||||
|
||||
cli_bc sourceSets.cli_bc.output
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
final List<File> stdLibSrc = [
|
||||
project(':Interop:Runtime').file('src/main/kotlin'),
|
||||
project(':Interop:Runtime').file('src/native/kotlin'),
|
||||
project(':Interop:JsRuntime').file('src/main/kotlin'),
|
||||
project(':runtime').file('src/main/kotlin')
|
||||
]
|
||||
|
||||
// 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(':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("${rootProject.projectDir}/dist/konan/lib") {
|
||||
include "*.jar"
|
||||
}
|
||||
jvmArgs = konanJvmArgs
|
||||
args = [*konanArgs,
|
||||
'-output', project(':runtime').file("build/${target}Stdlib"),
|
||||
'-produce', 'library', '-module-name', 'stdlib', '-XXLanguage:+AllowContractsForCustomFunctions',
|
||||
'-Xmulti-platform', '-Xopt-in=kotlin.RequiresOptIn', '-Xinline-classes',
|
||||
'-Xopt-in=kotlin.contracts.ExperimentalContracts',
|
||||
'-Xopt-in=kotlin.ExperimentalMultiplatform',
|
||||
'-Xallow-result-return-type',
|
||||
commonSrc.absolutePath,
|
||||
"-Xcommon-sources=${commonSrc.absolutePath}",
|
||||
*stdLibSrc]
|
||||
stdLibSrc.forEach { inputs.dir(it) }
|
||||
inputs.dir(commonSrc)
|
||||
outputs.dir(project(':runtime').file("build/${target}Stdlib"))
|
||||
|
||||
dependsOn 'unzipStdlibSources'
|
||||
dependsOn ":runtime:${target}Runtime"
|
||||
dependsOn ":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,
|
||||
sourceSets.hashInteropStubs.output,
|
||||
sourceSets.filesInteropStubs.output,
|
||||
sourceSets.llvmInteropStubs.output
|
||||
|
||||
dependsOn ':runtime:hostRuntime', 'external_jars'
|
||||
}
|
||||
|
||||
def externalJars = ['compiler', 'stdlib', 'reflect', 'script_runtime']
|
||||
|
||||
task trove4jCopy(type: Copy) {
|
||||
from configurations.getByName("trove4j_jar") {
|
||||
include "trove4j*.jar"
|
||||
rename "trove4j(.*).jar", "trove4j.jar"
|
||||
|
||||
into 'build/external_jars'
|
||||
}
|
||||
}
|
||||
|
||||
externalJars.each { arg ->
|
||||
def jar = arg.replace('_', '-') // :(
|
||||
task("${arg}Copy", type: Copy) {
|
||||
from configurations.getByName("kotlin_${arg}_jar") {
|
||||
include "kotlin-${jar}*.jar"
|
||||
rename "kotlin-${jar}(.*).jar", "kotlin-${jar}.jar"
|
||||
|
||||
into 'build/external_jars'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task external_jars(type: Copy) {
|
||||
dependsOn externalJars.collect { "${it}Copy" }
|
||||
dependsOn trove4jCopy
|
||||
|
||||
from configurations.compilerCompile {
|
||||
|
||||
include "protobuf-java-${protobufVersion}.jar"
|
||||
|
||||
into 'build/external_jars'
|
||||
}
|
||||
}
|
||||
|
||||
protobuf {
|
||||
protoc {
|
||||
artifact = "com.google.protobuf:protoc:${protobufVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
task debugCompiler(type: JavaExec) {
|
||||
dependsOn ':dist'
|
||||
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
|
||||
classpath = project.fileTree("${distDir.canonicalPath}/konan/lib/") {
|
||||
include '*.jar'
|
||||
}
|
||||
jvmArgs "-Dorg.jetbrains.kotlin.native.home=${distDir.canonicalPath}"
|
||||
enableAssertions = true
|
||||
args = findProperty("konan.debug.args").toString().tokenize() ?: []
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven { url = "$buildDir/repo" }
|
||||
}
|
||||
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = 'org.jetbrains.kotlin'
|
||||
artifactId = 'backend.native'
|
||||
version = konanVersionFull
|
||||
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user