Initial checkin of klib support.

The libraries exist in two incarnations:
    packed foo.klib and unpacked foo/ .
The compiler when given '-library foo' expects to find either
a foo.klib file and unpack it, or an already unpacked foo/ directory.

The stdlib is always unpacked in dist/klib .

The semantics of -o has changed slightly.
It now accepts '-o foo' and the compiler
either produces foo.kexe or foo.klib .
This commit is contained in:
Alexander Gorshenev
2017-04-27 16:14:17 +03:00
committed by alexander-gorshenev
parent 77e093354f
commit 3b5ce031f8
24 changed files with 564 additions and 203 deletions
+52 -26
View File
@@ -67,8 +67,9 @@ void setupCompilationFlags() {
final String binDir
if (isLinux()) {
ext.host = "linux"
ext.targetArgs <<
["host":
[(ext.host):
["--sysroot=${gccToolchainDir}/${gnuTriplet}/sysroot"],
"raspberrypi":
["-target", "armv7-unknown-linux-gnueabihf",
@@ -79,9 +80,10 @@ void setupCompilationFlags() {
"-I$raspberryPiSysrootDir/usr/include/c++/4.8.3/arm-linux-gnueabihf"]
]
} else {
ext.host = "macbook"
ext.targetArgs <<
["host":
["--sysroot=$hostSysrootDir", "-mmacosx-version-min=$minMacOsVersion"],
[(ext.host):
["--sysroot=$macbookSysrootDir", "-mmacosx-version-min=$minMacOsVersion"],
"iphone":
["-stdlib=libc++", "-arch", "arm64", "-isysroot", "$iphoneSysrootDir",
"-miphoneos-version-min=8.0.0"]
@@ -99,11 +101,11 @@ void setupCompilationFlags() {
"-L$llvmDir/lib"
])
} else {
binDir = "$hostSysrootDir/usr/bin"
binDir = "$macbookSysrootDir/usr/bin"
}
ext.clangArgs << "-B$binDir"
ext.hostClangArgs = ext.clangArgs.clone()
ext.hostClangArgs.addAll(ext.targetArgs['host'])
ext.hostClangArgs.addAll(ext.targetArgs[host])
ext.clangPath << binDir
ext.jvmArgs = ["-ea"]
@@ -164,7 +166,12 @@ class PlatformInfo {
}
}
task dist_compiler(type: Copy) {
task dist_compiler(dependsOn: "distCompiler")
task dist_runtime(dependsOn: "distRuntime")
task cross_dist(dependsOn: "crossDist")
task list_dist(dependsOn: "listDist")
task distCompiler(type: Copy) {
dependsOn ':backend.native:jars'
dependsOn ':tools:helpers:jar'
@@ -221,46 +228,65 @@ task dist_compiler(type: Copy) {
}
}
task list_dist(type: Exec) {
task listDist(type: Exec) {
commandLine 'find', 'dist'
}
task dist_runtime(type: Copy) {
dependsOn ':runtime:hostRuntime'
dependsOn ':backend.native:hostStdlib'
dependsOn ':backend.native:hostStart'
task distRuntime(type: Copy) {
dependsOn "${host}CrossDistRuntime"
dependsOn('commonDistRuntime')
}
task commonDistRuntime(type: Copy) {
destinationDir file('dist')
from(project(':runtime').file('build')) {
include('*/*.bc')
into('lib')
// Target independant common part.
from(project(':runtime').file("build/${host}Stdlib")) {
include('**')
into('klib/stdlib')
}
}
task cross_dist_runtime(type: Copy) {
dependsOn.addAll(targetList.collect { ":runtime:${it}Runtime" })
dependsOn.addAll(targetList.collect { ":backend.native:${it}Stdlib" })
dependsOn.addAll(targetList.collect { ":backend.native:${it}Start" })
task crossDistRuntime(type: Copy) {
dependsOn.addAll(targetList.collect { "${it}CrossDistRuntime" })
dependsOn('commonDistRuntime')
}
destinationDir file('dist')
targetList.each { target ->
task("${target}CrossDistRuntime", type: Copy) {
dependsOn ":runtime:${target}Runtime"
dependsOn ":backend.native:${target}Stdlib"
dependsOn ":backend.native:${target}Start"
from(project(':runtime').file('build')) {
include('*/*.bc')
into('lib')
destinationDir file('dist')
from(project(':runtime').file("build/$target")) {
include("*.bc")
eachFile {println("eachfile= $it")}
into("klib/stdlib/$target/native")
}
from(project(':runtime').file("build/${target}Stdlib")) {
include('**')
into('klib/stdlib')
}
from(project(':runtime').file("build/${target}Start/$target/kotlin")) {
include("program.kt.bc")
rename('program.kt.bc', 'start.kt.bc')
into("klib/stdlib/$target/native")
}
}
}
task dist {
dependsOn 'dist_compiler', 'dist_runtime', ':tools:gradle-plugin:dist'
dependsOn 'distCompiler', 'distRuntime', ':tools:gradle-plugin:dist'
}
task cross_dist {
dependsOn 'cross_dist_runtime', 'dist'
task crossDist {
dependsOn 'crossDistRuntime', 'distCompiler'
}
task bundle(type: Tar) {
dependsOn('cross_dist')
dependsOn('crossDist')
baseName = "kotlin-native-${simpleOsName()}-${project.konanVersion}"
from("$project.rootDir/dist") {
include '**'