backend/build: depend on kotlin-compiler.jar from repo

instead of the jars from backend.native/kotlin-ir
This commit is contained in:
Svyatoslav Scherbina
2016-10-31 13:13:46 +07:00
parent 74ab1503c3
commit 394b4ce6ec
2 changed files with 47 additions and 25 deletions
+40 -18
View File
@@ -1,5 +1,4 @@
buildscript { buildscript {
ext.kotlin_ir_path = "$projectDir/kotlin-ir/dist"
repositories { repositories {
mavenCentral() mavenCentral()
} }
@@ -14,11 +13,29 @@ apply plugin: 'java'
apply plugin: 'kotlin' apply plugin: 'kotlin'
apply plugin: org.jetbrains.kotlin.NativeInteropPlugin apply plugin: org.jetbrains.kotlin.NativeInteropPlugin
def deps = files("$kotlin_ir_path/kotlinc/lib/kotlin-compiler.jar", String kotlinCompilerModule = 'org.jetbrains.kotlin:kotlin-compiler:1.1.0-dev-4137'
"$kotlin_ir_path/kotlinc/lib/kotlin-runtime.jar",
"$kotlin_ir_path/kotlinc/lib/kotlin-reflect.jar") // (gets applied to this project and all its subprojects)
//export dependencies jars allprojects {
ext['deps'] = deps repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/kotlin/kotlin-dev"
}
}
configurations.all {
// kotlin-compiler module includes Kotlin runtime bundled;
// make Gradle aware of this to avoid multiple Kotlin runtimes in classpath:
resolutionStrategy.dependencySubstitution {
substitute module('org.jetbrains.kotlin:kotlin-runtime') with module(kotlinCompilerModule)
substitute module('org.jetbrains.kotlin:kotlin-stdlib') with module(kotlinCompilerModule)
substitute module('org.jetbrains.kotlin:kotlin-reflect') with module(kotlinCompilerModule)
}
// TODO: probably we should use kotlin-compiler without bundled runtime
}
}
sourceSets { sourceSets {
compiler { compiler {
@@ -103,27 +120,35 @@ kotlinNativeInterop {
} }
} }
configurations {
cli_bcRuntime.extendsFrom compilerRuntime
cli_bc {
extendsFrom cli_bcRuntime
}
}
dependencies { dependencies {
compilerCompile deps compilerCompile kotlinCompilerModule
compilerCompile kotlinNativeInterop['llvm'].configuration compilerCompile kotlinNativeInterop['llvm'].configuration
compilerCompile kotlinNativeInterop['hash'].configuration compilerCompile kotlinNativeInterop['hash'].configuration
cli_bcCompile deps cli_bcCompile "org.jetbrains.kotlin:kotlin-runtime:$kotlin_version"
cli_bcCompile sourceSets.compiler.output cli_bcCompile sourceSets.compiler.output
bc_frontendCompile deps bc_frontendCompile kotlinCompilerModule
cli_bc sourceSets.cli_bc.output
} }
configurations {
cli_bcRuntime.extendsFrom compilerRuntime
}
build.dependsOn 'compilerClasses','cli_bcClasses','bc_frontendClasses' build.dependsOn 'compilerClasses','cli_bcClasses','bc_frontendClasses'
task run(type: JavaExec) { task run(type: JavaExec) {
main 'org.jetbrains.kotlin.cli.bc.K2NativeKt' main 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
classpath sourceSets.cli_bc.runtimeClasspath classpath configurations.cli_bc
args 'tests/codegen/function/sum.kt' args 'tests/codegen/function/sum.kt'
@@ -144,13 +169,10 @@ task run(type: JavaExec) {
task jars { task jars {
println "kotlin-ir: $kotlin_ir_path" doFirst {
project.buildscript.configurations.classpath.each { project.buildscript.configurations.classpath.each {
String jarName = it.getName(); String jarName = it.getName();
print jarName + ":" print jarName + ":"
} }
} }
repositories {
mavenCentral()
} }
+7 -7
View File
@@ -1,6 +1,10 @@
import org.gradle.api.internal.file.DefaultCompositeFileTree configurations {
import org.gradle.api.internal.file.FileTreeInternal cli_bc
}
dependencies {
cli_bc project(path: ':backend.native', configuration: 'cli_bc')
}
public class KonanTest extends DefaultTask { public class KonanTest extends DefaultTask {
protected String source protected String source
@@ -16,17 +20,13 @@ public class KonanTest extends DefaultTask {
@TaskAction @TaskAction
public void compileBc() { public void compileBc() {
def classpathSs = new DefaultCompositeFileTree(new ArrayList<FileTreeInternal>())
project.sourceSets.each{classpathSs += it.output}
project.project(":Interop:Runtime").sourceSets.each{ classpathSs += it.output }
classpathSs += backendNative.ext.deps
def sourceKt = project.file(source) def sourceKt = project.file(source)
def sourceBc = new File("${sourceKt.absolutePath}.bc") def sourceBc = new File("${sourceKt.absolutePath}.bc")
def runtimeBc = new File("${runtimeProject.buildDir.canonicalPath}/runtime.bc") def runtimeBc = new File("${runtimeProject.buildDir.canonicalPath}/runtime.bc")
println "${runtimeBc}" println "${runtimeBc}"
project.javaexec { project.javaexec {
main='org.jetbrains.kotlin.cli.bc.K2NativeKt' main='org.jetbrains.kotlin.cli.bc.K2NativeKt'
classpath = classpathSs classpath = project.configurations.cli_bc
args "-output", "${sourceBc.absolutePath}", args "-output", "${sourceBc.absolutePath}",
"-runtime", "${runtimeBc.absolutePath}", "-runtime", "${runtimeBc.absolutePath}",
"${sourceKt.absolutePath}", "${sourceKt.absolutePath}",