More accurate host- and cross- target separations.

This commit is contained in:
Alexander Gorshenev
2017-01-23 20:32:24 +03:00
committed by alexander-gorshenev
parent e895c0939c
commit a856b0d9ce
5 changed files with 48 additions and 44 deletions
+17 -17
View File
@@ -143,7 +143,7 @@ kotlinNativeInterop {
compilerOpts '-fPIC'
linkerOpts '-fPIC'
linker 'clang++'
linkOutputs ':common:compileHash'
linkOutputs ':common:hostHash'
headers fileTree('../common/src/hash/headers') {
include '**/*.h'
@@ -191,48 +191,48 @@ task start(dependsOn: 'hostStart')
// so we provide custom values for
// -runtime, -properties, -library and -Djava.library.path
targetList.each { platformName ->
task("${platformName}Stdlib", type: JavaExec) {
targetList.each { target ->
task("${target}Stdlib", type: JavaExec) {
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
classpath = project.configurations.cli_bc
jvmArgs "-ea",
"-Dkonan.home=${project.parent.file('dist')}",
"-Djava.library.path=${project.buildDir}/nativelibs"
args('-output', project(':runtime').file("build/${platformName}/stdlib.kt.bc"),
args('-output', project(':runtime').file("build/${target}/stdlib.kt.bc"),
'-nolink', '-nostdlib',
'-target', platformName,
'-runtime', project(':runtime').file("build/${platformName}/runtime.bc"),
'-target', target,
'-runtime', project(':runtime').file("build/${target}/runtime.bc"),
'-properties', project(':backend.native').file('konan.properties'),
project(':runtime').file('src/main/kotlin'),
*project.globalArgs)
inputs.dir(project(':runtime').file('src/main/kotlin'))
outputs.file(project(':runtime').file("build/${platformName}/stdlib.kt.bc"))
outputs.file(project(':runtime').file("build/${target}/stdlib.kt.bc"))
dependsOn ":runtime:build"
dependsOn ":runtime:${target}Runtime"
}
}
targetList.each { platformName ->
task("${platformName}Start", type: JavaExec) {
targetList.each { target ->
task("${target}Start", type: JavaExec) {
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
classpath = project.configurations.cli_bc
jvmArgs "-ea",
"-Dkonan.home=${project.parent.file('dist')}",
"-Djava.library.path=${project.buildDir}/nativelibs"
args('-output', project(':runtime').file("build/${platformName}/start.kt.bc"),
args('-output', project(':runtime').file("build/${target}/start.kt.bc"),
'-nolink', '-nostdlib',
'-target', platformName,
'-library', project(':runtime').file("build/${platformName}/stdlib.kt.bc"),
'-runtime', project(':runtime').file("build/${platformName}/runtime.bc"),
'-target', target,
'-library', project(':runtime').file("build/${target}/stdlib.kt.bc"),
'-runtime', project(':runtime').file("build/${target}/runtime.bc"),
'-properties', project(':backend.native').file('konan.properties'),
project(':runtime').file('src/launcher/kotlin'),
*project.globalArgs)
inputs.dir(project(':runtime').file('src/launcher/kotlin'))
outputs.file(project(':runtime').file("build/${platformName}/start.kt.bc"))
outputs.file(project(':runtime').file("build/${target}/start.kt.bc"))
dependsOn ":runtime:build", "${platformName}Stdlib"
dependsOn ":runtime:${target}Runtime", "${target}Stdlib"
}
}
@@ -248,7 +248,7 @@ task jars(type: Jar) {
'build/classes/hashInteropStubs',
'build/classes/llvmInteropStubs'
dependsOn 'build', ':runtime:build', 'external_jars'
dependsOn 'build', ':runtime:hostRuntime', 'external_jars'
}
task external_jars(type: Copy) {
@@ -11,6 +11,7 @@ class Runtime(private val bitcodeFile: String) {
val bufRef = alloc<LLVMMemoryBufferRefVar>()
val errorRef = allocPointerTo<CInt8Var>()
val res = LLVMCreateMemoryBufferWithContentsOfFile(bitcodeFile, bufRef.ptr, errorRef.ptr)
if (res != 0) {
throw Error(errorRef.value?.asCString()?.toString())
+2 -2
View File
@@ -148,7 +148,7 @@ task list_dist(type: Exec) {
}
task dist_runtime(type: Copy) {
dependsOn ':runtime:build'
dependsOn ':runtime:hostRuntime'
dependsOn ':backend.native:hostStdlib'
dependsOn ':backend.native:hostStart'
@@ -161,7 +161,7 @@ task dist_runtime(type: Copy) {
}
task cross_dist_runtime(type: Copy) {
dependsOn ':runtime:build'
dependsOn.addAll(targetList.collect { ":runtime:${it}Runtime" })
dependsOn.addAll(targetList.collect { ":backend.native:${it}Stdlib" })
dependsOn.addAll(targetList.collect { ":backend.native:${it}Start" })
+8 -6
View File
@@ -1,15 +1,17 @@
import org.jetbrains.kotlin.CompilePerTarget
import org.jetbrains.kotlin.CompileCppToBitcode
// TODO: consider using some Gradle plugins to build and test
task compileHash(type: CompilePerTarget) {
name 'hash'
targetList targetList
targetArgs targetArgs
targetList.each { targetName ->
task ("${targetName}Hash", type: CompileCppToBitcode) {
name 'hash'
target targetName
compilerArgs targetArgs[targetName]
}
}
task build {
dependsOn compileHash
dependsOn hostHash
}
task clean << {
+20 -19
View File
@@ -1,28 +1,29 @@
import org.jetbrains.kotlin.CompilePerTarget
import org.jetbrains.kotlin.CompileCppToBitcode
// TODO: consider using some Gradle plugins to build and test
task build(type: CompilePerTarget) {
name 'runtime'
srcRoot file('src/main')
dependsOn ":common:compileHash"
dependsOn "launcher"
targetList targetList
targetArgs targetArgs
compilerArgs '-I' + project.file('../common/src/hash/headers') // TODO: copy-pasted from 'common'
targetLinkerArgs targetList.collectEntries {
[it,[project.file("../common/build/$it/hash.bc")]]
targetList.each { targetName ->
task("${targetName}Runtime", type: CompileCppToBitcode) {
name "runtime"
srcRoot file('src/main')
dependsOn ":common:${targetName}Hash"
dependsOn "${targetName}Launcher"
target targetName
compilerArgs targetArgs[targetName]
compilerArgs '-I' + project.file('../common/src/hash/headers')
linkerArgs project.file("../common/build/$targetName/hash.bc").path
}
}
task launcher(type: CompilePerTarget) {
name 'launcher'
srcRoot file('src/launcher')
targetList targetList
targetArgs targetArgs
compilerArgs '-I' + project.file('../common/src/hash/headers') // TODO: copy-pasted from 'common'
compilerArgs '-I' + project.file('src/main/cpp')
targetList.each { targetName ->
task("${targetName}Launcher", type: CompileCppToBitcode) {
name "launcher"
srcRoot file('src/launcher')
target targetName
compilerArgs targetArgs[targetName]
compilerArgs '-I' + project.file('../common/src/hash/headers')
compilerArgs '-I' + project.file('src/main/cpp')
}
}
task clean << {