Merge pull request #25 from JetBrains/drop-kotlin-build
Use kotlin-compiler.jar from repo to get rid of building the Big Kotlin
This commit is contained in:
@@ -1,7 +1,3 @@
|
|||||||
[submodule "experiments/kotlin-ir"]
|
|
||||||
path = backend.native/kotlin-ir
|
|
||||||
url = https://github.com/JetBrains/kotlin.git
|
|
||||||
branch = master
|
|
||||||
[submodule "third-party/ios/libffi"]
|
[submodule "third-party/ios/libffi"]
|
||||||
path = third-party/ios/libffi
|
path = third-party/ios/libffi
|
||||||
url = https://github.com/ksjogo/libffi
|
url = https://github.com/ksjogo/libffi
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ kotlinNativeInterop {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
compile kotlinNativeInterop['llvm']
|
compile kotlinNativeInterop['llvm'].configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
mainClassName = 'MainKt'
|
mainClassName = 'MainKt'
|
||||||
|
|||||||
+45
-23
@@ -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-20161025.164748-245'
|
||||||
"$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://oss.sonatype.org/content/repositories/snapshots'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compilerCompile deps
|
|
||||||
compilerCompile kotlinNativeInterop['llvm']
|
|
||||||
compilerCompile kotlinNativeInterop['hash']
|
|
||||||
|
|
||||||
cli_bcCompile deps
|
|
||||||
cli_bcCompile sourceSets.compiler.output
|
|
||||||
|
|
||||||
bc_frontendCompile deps
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
cli_bcRuntime.extendsFrom compilerRuntime
|
cli_bcRuntime.extendsFrom compilerRuntime
|
||||||
|
|
||||||
|
cli_bc {
|
||||||
|
extendsFrom cli_bcRuntime
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compilerCompile kotlinCompilerModule
|
||||||
|
compilerCompile kotlinNativeInterop['llvm'].configuration
|
||||||
|
compilerCompile kotlinNativeInterop['hash'].configuration
|
||||||
|
|
||||||
|
cli_bcCompile "org.jetbrains.kotlin:kotlin-runtime:$kotlin_version"
|
||||||
|
cli_bcCompile sourceSets.compiler.output
|
||||||
|
|
||||||
|
bc_frontendCompile kotlinCompilerModule
|
||||||
|
|
||||||
|
cli_bc sourceSets.cli_bc.output
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -27,7 +27,10 @@ class ModuleIndex(val module: IrModuleFragment) {
|
|||||||
override fun visitClass(declaration: IrClass) {
|
override fun visitClass(declaration: IrClass) {
|
||||||
super.visitClass(declaration)
|
super.visitClass(declaration)
|
||||||
|
|
||||||
map[declaration.descriptor.classId] = declaration
|
val classId = declaration.descriptor.classId
|
||||||
|
if (classId != null) {
|
||||||
|
map[classId] = declaration
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Submodule backend.native/kotlin-ir deleted from 82364ad3e5
@@ -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}",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.gradle.api.Named
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.internal.AbstractNamedDomainObjectContainer
|
import org.gradle.api.internal.AbstractNamedDomainObjectContainer
|
||||||
import org.gradle.api.internal.file.AbstractFileCollection
|
import org.gradle.api.internal.file.AbstractFileCollection
|
||||||
@@ -12,7 +13,7 @@ import org.gradle.api.tasks.SourceSet
|
|||||||
import org.gradle.api.tasks.TaskDependency
|
import org.gradle.api.tasks.TaskDependency
|
||||||
import org.gradle.internal.reflect.Instantiator
|
import org.gradle.internal.reflect.Instantiator
|
||||||
|
|
||||||
class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
|
class NamedNativeInteropConfig implements Named {
|
||||||
|
|
||||||
private final Project project
|
private final Project project
|
||||||
final String name
|
final String name
|
||||||
@@ -31,6 +32,8 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
|
|||||||
private FileCollection linkFiles;
|
private FileCollection linkFiles;
|
||||||
private List<String> linkTasks = []
|
private List<String> linkTasks = []
|
||||||
|
|
||||||
|
Configuration configuration
|
||||||
|
|
||||||
void defFile(String value) {
|
void defFile(String value) {
|
||||||
defFile = value
|
defFile = value
|
||||||
genTask.inputs.file(project.file(defFile))
|
genTask.inputs.file(project.file(defFile))
|
||||||
@@ -117,6 +120,7 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
|
|||||||
|
|
||||||
interopStubs = project.sourceSets.create(name + "InteropStubs")
|
interopStubs = project.sourceSets.create(name + "InteropStubs")
|
||||||
genTask = project.task(interopStubs.getTaskName("gen", ""), type: JavaExec)
|
genTask = project.task(interopStubs.getTaskName("gen", ""), type: JavaExec)
|
||||||
|
configuration = project.configurations.create(interopStubs.name)
|
||||||
|
|
||||||
this.configure()
|
this.configure()
|
||||||
}
|
}
|
||||||
@@ -178,22 +182,9 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
this.configuration.extendsFrom project.configurations[interopStubs.runtimeConfigurationName]
|
||||||
String getDisplayName() {
|
project.dependencies.add(this.configuration.name, interopStubs.output)
|
||||||
return "Native interop config $name"
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Set<File> getFiles() {
|
|
||||||
return interopStubs.output.getFiles() +
|
|
||||||
interopStubs.compileClasspath.files // TODO: workaround to add Interop:Runtime
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
TaskDependency getBuildDependencies() {
|
|
||||||
return interopStubs.output.getBuildDependencies()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user