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