143 lines
3.2 KiB
Groovy
143 lines
3.2 KiB
Groovy
buildscript {
|
|
ext.kotlin_ir_path = "$projectDir/kotlin-ir/dist"
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
}
|
|
|
|
}
|
|
|
|
apply plugin: 'java'
|
|
apply plugin: 'kotlin'
|
|
apply plugin: org.jetbrains.kotlin.NativeInteropPlugin
|
|
|
|
def deps = files("$kotlin_ir_path/kotlinc/lib/kotlin-compiler.jar",
|
|
"$kotlin_ir_path/kotlinc/lib/kotlin-runtime.jar",
|
|
"$kotlin_ir_path/kotlinc/lib/kotlin-reflect.jar")
|
|
//export dependencies jars
|
|
ext['deps'] = deps
|
|
|
|
sourceSets {
|
|
compiler {
|
|
java.srcDir 'compiler/ir/backend.native/src/'
|
|
kotlin.srcDir 'compiler/ir/backend.native/src/'
|
|
}
|
|
cli_bc {
|
|
java.srcDir 'cli.bc/src'
|
|
kotlin.srcDir 'cli.bc/src'
|
|
}
|
|
bc_frontend {
|
|
java.srcDir 'bc.frontend/src'
|
|
kotlin.srcDir 'bc.frontend/src'
|
|
}
|
|
}
|
|
|
|
kotlinNativeInterop {
|
|
llvm {
|
|
defFile 'llvm.def'
|
|
compilerOpts "-I$llvmDir/include"
|
|
linkerOpts "-L$llvmDir/lib -lc++ ",
|
|
"-Wl,--whole-archive",
|
|
"-lLLVMX86Disassembler",
|
|
"-lLLVMX86AsmParser",
|
|
"-lLLVMX86CodeGen",
|
|
"-lLLVMSelectionDAG",
|
|
"-lLLVMAsmPrinter",
|
|
"-lLLVMX86Desc",
|
|
"-lLLVMMCDisassembler",
|
|
"-lLLVMX86Info",
|
|
"-lLLVMX86AsmPrinter",
|
|
"-lLLVMX86Utils",
|
|
"-lLLVMInterpreter",
|
|
"-lLLVMCodeGen",
|
|
"-lLLVMScalarOpts",
|
|
"-lLLVMInstCombine",
|
|
"-lLLVMInstrumentation",
|
|
"-lLLVMProfileData",
|
|
"-lLLVMTransformUtils",
|
|
"-lLLVMBitWriter",
|
|
"-lLLVMExecutionEngine",
|
|
"-lLLVMTarget",
|
|
"-lLLVMAnalysis",
|
|
"-lLLVMRuntimeDyld",
|
|
"-lLLVMObject",
|
|
"-lLLVMMCParser",
|
|
"-lLLVMBitReader",
|
|
"-lLLVMMC",
|
|
"-lLLVMCore",
|
|
"-lLLVMSupport",
|
|
"-Wl,--no-whole-archive",
|
|
"-L$libffiDir/lib -lffi"
|
|
}
|
|
|
|
hash { // TODO: copy-pasted from ':common:compileHash'
|
|
compilerOpts '-fPIC'
|
|
linkerOpts '-fPIC'
|
|
linker 'clang++'
|
|
linkOutputs ':common:compileHash'
|
|
|
|
headers fileTree('../common/src/hash/headers') {
|
|
include '**/*.h'
|
|
include '**/*.hpp'
|
|
}
|
|
|
|
pkg 'org.jetbrains.kotlin.backend.native.hash'
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compilerCompile deps
|
|
compilerCompile kotlinNativeInterop['llvm']
|
|
compilerCompile kotlinNativeInterop['hash']
|
|
|
|
cli_bcCompile deps
|
|
cli_bcCompile sourceSets.compiler.output
|
|
|
|
bc_frontendCompile deps
|
|
}
|
|
|
|
configurations {
|
|
cli_bcRuntime.extendsFrom compilerRuntime
|
|
}
|
|
|
|
build.dependsOn 'compilerClasses','cli_bcClasses','bc_frontendClasses'
|
|
|
|
|
|
task run(type: JavaExec) {
|
|
main 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
|
|
classpath sourceSets.cli_bc.runtimeClasspath
|
|
|
|
args 'tests/codegen/function/sum.kt'
|
|
|
|
args project(':runtime').file('src/main/kotlin')
|
|
|
|
args '-output', "$buildDir/out.bc"
|
|
|
|
jvmArgs '-ea', "-Djava.library.path=${llvmDir}/lib:${project.buildDir}/nativelibs"
|
|
|
|
dependsOn ':runtime:build'
|
|
|
|
doFirst {
|
|
args '-runtime', project(':runtime').build.outputs.files.singleFile
|
|
}
|
|
environment 'LD_LIBRARY_PATH' : "${llvmDir}/lib:${project.buildDir}/nativelibs"
|
|
|
|
}
|
|
|
|
|
|
|
|
task jars {
|
|
println "kotlin-ir: $kotlin_ir_path"
|
|
project.buildscript.configurations.classpath.each {
|
|
String jarName = it.getName();
|
|
print jarName + ":"
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|