Rewrite samples using new API (#3021)

This commit is contained in:
LepilkinaElena
2019-05-28 11:12:17 +03:00
committed by Ilya Matveev
parent c1a4272e7a
commit 16a8fdcf4e
36 changed files with 296 additions and 397 deletions
+19 -21
View File
@@ -53,13 +53,13 @@ android {
}
kotlin {
targets {
fromPreset(presets.androidNativeArm32, 'arm32')
fromPreset(presets.androidNativeArm64, 'arm64')
configure([arm32, arm64]) {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.androidnative.main'
[new Tuple(presets.androidNativeArm32, 'arm32'), new Tuple(presets.androidNativeArm64, 'arm64')].each {
targetFromPreset(it[0], it[1]) {
binaries {
executable() {
entryPoint = 'sample.androidnative.main'
}
}
compilations.main.cinterops {
bmpformat
}
@@ -77,24 +77,22 @@ tasks.compileKotlinMetadata.enabled = false
afterEvaluate {
kotlin.targets { targets ->
[arm32, arm64].collect { target ->
target.compilations.main { mainCompilation ->
String buildType = 'RELEASE' // Change to 'DEBUG' to include debug symbols.
Object linkTask = mainCompilation.getLinkTask('EXECUTABLE', buildType)
String buildType = 'RELEASE' // Change to 'DEBUG' to include debug symbols.
Object linkTask = binaries.getExecutable(buildType).linkTask
// Rename binary files to 'libpoly.so' and put them to the appropriate location.
File binaryFile = linkTask.outputFile.get()
linkTask.doLast {
copy {
from binaryFile
into libsDirMapping[target.targetName]
rename {
'libpoly.so'
}
// Rename binary files to 'libpoly.so' and put them to the appropriate location.
File binaryFile = binaries.getExecutable(buildType).outputFile
linkTask.doLast {
copy {
from binaryFile
into libsDirMapping[target.targetName]
rename {
'libpoly.so'
}
}
tasks.preBuild.dependsOn linkTask
}
tasks.preBuild.dependsOn linkTask
}
}
}
+1 -14
View File
@@ -8,7 +8,7 @@
import groovy.lang.Closure
import org.gradle.api.Project
import org.gradle.api.Task
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
import org.jetbrains.kotlin.konan.target.KonanTarget
@@ -65,16 +65,3 @@ fun defaultHostPreset(
else
throw Exception("Host OS '$hostOs' is not supported in Kotlin/Native ${subproject.displayName}.")
}
// A short-cut to add a Kotlin/Native run task.
@JvmOverloads
fun createRunTask(
subproject: Project,
name: String,
target: KotlinTarget,
configureClosure: Closure<Any>? = null
): Task {
val task = subproject.tasks.create(name, RunKotlinNativeTask::class.java, target)
task.configure(configureClosure ?: task.emptyConfigureClosure())
return task
}
@@ -1,51 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
import groovy.lang.Closure
import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.tasks.TaskAction
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import javax.inject.Inject
open class RunKotlinNativeTask @Inject constructor(
private val myTarget: KotlinTarget
): DefaultTask() {
var buildType = "RELEASE"
var workingDir: Any = project.projectDir
private var myArgs: List<String> = emptyList()
private val myEnvironment: MutableMap<String, Any> = mutableMapOf()
fun args(vararg args: Any) {
myArgs = args.map { it.toString() }
}
fun environment(map: Map<String, Any>) {
myEnvironment += map
}
override fun configure(configureClosure: Closure<Any>): Task {
val task = super.configure(configureClosure)
this.dependsOn += myTarget.compilations.main.linkTaskName("EXECUTABLE", buildType)
return task
}
@TaskAction
fun run() {
project.exec {
it.executable = myTarget.compilations.main.getBinary("EXECUTABLE", buildType).toString()
it.args = myArgs
it.environment = myEnvironment
it.workingDir(workingDir)
}
}
internal fun emptyConfigureClosure() = object : Closure<Any>(this) {
override fun call(): RunKotlinNativeTask {
return this@RunKotlinNativeTask
}
}
}
+1 -3
View File
@@ -20,7 +20,5 @@ dependencies {
}
kotlin {
targets {
fromPreset(presets.android, 'android')
}
android()
}
+1 -1
View File
@@ -2,7 +2,7 @@ apply plugin: 'org.jetbrains.kotlin.multiplatform'
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
jvm()
}
sourceSets {
+1 -1
View File
@@ -6,7 +6,7 @@ from EU is being used.
To build use `../gradlew assemble`.
To run use `../gradlew runProgram` or execute the program directly:
To run use `../gradlew runReleaseExecutableCsvParser` or execute the program directly:
./build/bin/csvParser/main/release/executable/csvparser.kexe ./European_Mammals_Red_List_Nov_2009.csv 4 100
+7 -9
View File
@@ -6,14 +6,12 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project)
kotlin {
targets {
fromPreset(hostPreset, 'csvParser') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.csvparser.main'
targetFromPreset(hostPreset, 'csvParser') {
binaries {
executable() {
entryPoint = 'sample.csvparser.main'
runTask.args './European_Mammals_Red_List_Nov_2009.csv', 4, 100
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.csvParser) {
args './European_Mammals_Red_List_Nov_2009.csv', 4, 100
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ built by [libcurl sample](../libcurl) so you need to run it first.
To build use `../gradlew assemble`.
To run use `../gradlew runProgram` or execute the program directly:
To run use `../gradlew runReleaseExecutableCurl` or execute the program directly:
./build/bin/curl/main/release/executable/curl.kexe 'https://www.jetbrains.com/'
+10 -15
View File
@@ -12,14 +12,16 @@ repositories {
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64, kotlin.presets.mingwX64])
kotlin {
targets {
fromPreset(hostPreset, 'curl') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.curl.main'
if (presets.mingwX64 == hostPreset) {
// Add lib path to `libcurl` and its dependencies:
compilations.main.linkerOpts "-L${MPPTools.mingwPath()}/lib"
targetFromPreset(hostPreset, 'curl') {
binaries {
executable() {
entryPoint = 'sample.curl.main'
if (presets.mingwX64 == hostPreset) {
// Add lib path to `libcurl` and its dependencies:
linkerOpts += ["-L${MPPTools.mingwPath()}/lib".toString()]
runTask.environment('PATH': "${MPPTools.mingwPath()}/bin".toString())
}
runTask.args('https://www.jetbrains.com/')
}
}
}
@@ -33,13 +35,6 @@ kotlin {
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.curl) {
if (kotlin.presets.mingwX64 == hostPreset) {
environment 'PATH': "${MPPTools.mingwPath()}/bin"
}
args 'https://www.jetbrains.com/'
}
// The code snippet below is needed to make all compile tasks depend on publication of
// "libcurl" library. So that to the time of compilation the library will already be
// in Maven repo and will be successfully resolved as a dependency of this project.
+1 -1
View File
@@ -2,7 +2,7 @@
To build use `../gradlew assemble`.
To run use `../gradlew runProgram` or execute the program directly:
To run use `../gradlew runReleaseExecutableEchoServer` or execute the program directly:
./build/bin/echoServer/main/release/executable/echoServer.kexe 3000 &
+6 -8
View File
@@ -9,10 +9,12 @@ def hostPreset = MPPTools.defaultHostPreset(project)
def raspberryPiPresets = [kotlin.presets.linuxArm32Hfp, kotlin.presets.linuxArm64]
kotlin {
targets {
fromPreset(hostPreset, 'echoServer') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.echoserver.main'
targetFromPreset(hostPreset, 'echoServer') {
binaries {
executable() {
entryPoint = 'sample.echoserver.main'
runTask.args(3000)
}
}
raspberryPiPresets.each { preset ->
@@ -31,7 +33,3 @@ kotlin {
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.echoServer) {
args 3000
}
+1 -1
View File
@@ -9,7 +9,7 @@ not have MSYS2-MinGW64 installed - install it first as described in http://www.m
To build use `../gradlew assemble`.
To run use `../gradlew runProgram` or execute the program directly:
To run use `../gradlew runReleaseExecutableGitChurn` or execute the program directly:
./build/bin/gitChurn/main/release/executable/gitchurn.kexe ../../
+22 -26
View File
@@ -6,35 +6,31 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project)
kotlin {
targets {
fromPreset(hostPreset, 'gitChurn') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.gitchurn.main'
compilations.main.cinterops {
libgit2 {
switch (hostPreset) {
case presets.macosX64:
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
break
case presets.linuxX64:
includeDirs.headerFilterOnly '/usr/include'
break
case presets.mingwX64:
includeDirs.headerFilterOnly "${MPPTools.mingwPath()}/include"
break
}
targetFromPreset(hostPreset, 'gitChurn') {
binaries {
executable() {
entryPoint = 'sample.gitchurn.main'
if (presets.mingwX64 == hostPreset) {
linkerOpts = ["-L${MPPTools.mingwPath()}/lib".toString()]
runTask.environment('PATH', "${MPPTools.mingwPath()}/bin".toString())
}
runTask.args(project.getRootProject().getRootDir().toString() + '/..')
}
if (presets.mingwX64 == hostPreset) {
compilations.main.linkerOpts "-L${MPPTools.mingwPath()}/lib"
}
compilations.main.cinterops {
libgit2 {
switch (hostPreset) {
case presets.macosX64:
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
break
case presets.linuxX64:
includeDirs.headerFilterOnly '/usr/include'
break
case presets.mingwX64:
includeDirs.headerFilterOnly "${MPPTools.mingwPath()}/include"
break
}
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.gitChurn) {
if (kotlin.presets.mingwX64 == hostPreset) {
environment 'PATH': "${MPPTools.mingwPath()}/bin"
}
args project.getRootProject().getRootDir().toString() + '/..'
}
+1 -1
View File
@@ -4,6 +4,6 @@ This example shows how one could implement global shared state using interop mec
To build use `../gradlew assemble`.
To run use `../gradlew runProgram` or execute the program directly:
To run use `../gradlew runReleaseExecutableGlobalState` or execute the program directly:
./build/bin/globalState/main/release/executable/globalState.kexe
+8 -9
View File
@@ -6,15 +6,14 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project)
kotlin {
targets {
fromPreset(hostPreset, 'globalState') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.globalstate.main'
compilations.main.cinterops {
global
targetFromPreset(hostPreset, 'globalState') {
binaries {
executable() {
entryPoint = 'sample.globalstate.main'
}
}
compilations.main.cinterops {
global
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.globalState)
}
+1 -1
View File
@@ -5,7 +5,7 @@ org.gradle.parallel=true
# Pin Kotlin version:
# CHANGE_VERSION_WITH_RELEASE
kotlin_version=1.3.40-dev-2451
kotlin_version=1.3.40-eap-40
# Use custom Kotlin/Native home:
org.jetbrains.kotlin.native.home=../../dist
+1 -1
View File
@@ -7,7 +7,7 @@ To build use `../gradlew assemble`.
Do not forget to install GTK3. See bellow.
To run on Mac also install XQuartz X server (https://www.xquartz.org/), and then `../gradlew runProgram` or execute the program directly:
To run on Mac also install XQuartz X server (https://www.xquartz.org/), and then `../gradlew runReleaseExecutableGtk` or execute the program directly:
./build/bin/gtk/main/release/executable/gtk.kexe
+39 -43
View File
@@ -6,51 +6,47 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project)
kotlin {
targets {
fromPreset(hostPreset, 'gtk') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.gtk.main'
compilations.main.cinterops {
gtk3 {
switch (hostPreset) {
case presets.macosX64:
case presets.linuxX64:
['/opt/local/include',
'/usr/include',
'/usr/local/include'
].each {
includeDirs "$it/atk-1.0",
"$it/gdk-pixbuf-2.0",
"$it/cairo",
"$it/pango-1.0",
"$it/gtk-3.0",
"$it/glib-2.0"
}
includeDirs '/opt/local/lib/glib-2.0/include',
'/usr/lib/x86_64-linux-gnu/glib-2.0/include',
'/usr/local/lib/glib-2.0/include'
break
case presets.mingwX64:
includeDirs "${MPPTools.mingwPath()}/include/atk-1.0",
"${MPPTools.mingwPath()}/include/gdk-pixbuf-2.0",
"${MPPTools.mingwPath()}/include/cairo",
"${MPPTools.mingwPath()}/include/pango-1.0",
"${MPPTools.mingwPath()}/include/gtk-3.0",
"${MPPTools.mingwPath()}/include/glib-2.0",
"${MPPTools.mingwPath()}/lib/glib-2.0/include"
break
}
targetFromPreset(hostPreset, 'gtk') {
binaries {
executable() {
entryPoint = 'sample.gtk.main'
if (presets.mingwX64 == hostPreset) {
linkerOpts += ["-L${MPPTools.mingwPath()}/lib".toString()]
runTask.environment('PATH', "${MPPTools.mingwPath()}/bin".toString())
}
}
if (presets.mingwX64 == hostPreset) {
compilations.main.linkerOpts "-L${MPPTools.mingwPath()}/lib"
}
compilations.main.cinterops {
gtk3 {
switch (hostPreset) {
case presets.macosX64:
case presets.linuxX64:
['/opt/local/include',
'/usr/include',
'/usr/local/include'
].each {
includeDirs "$it/atk-1.0",
"$it/gdk-pixbuf-2.0",
"$it/cairo",
"$it/pango-1.0",
"$it/gtk-3.0",
"$it/glib-2.0"
}
includeDirs '/opt/local/lib/glib-2.0/include',
'/usr/lib/x86_64-linux-gnu/glib-2.0/include',
'/usr/local/lib/glib-2.0/include'
break
case presets.mingwX64:
includeDirs "${MPPTools.mingwPath()}/include/atk-1.0",
"${MPPTools.mingwPath()}/include/gdk-pixbuf-2.0",
"${MPPTools.mingwPath()}/include/cairo",
"${MPPTools.mingwPath()}/include/pango-1.0",
"${MPPTools.mingwPath()}/include/gtk-3.0",
"${MPPTools.mingwPath()}/include/glib-2.0",
"${MPPTools.mingwPath()}/lib/glib-2.0/include"
break
}
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.gtk) {
if (kotlin.presets.mingwX64 == hostPreset) {
environment 'PATH': "${MPPTools.mingwPath()}/bin"
}
}
}
+6 -5
View File
@@ -16,13 +16,14 @@ String packageName = 'kotlinx.interop.wasm.dom'
String jsinteropKlibFileName = Paths.get(buildDir.toString(), 'klib', "$packageName-jsinterop.klib").toString()
kotlin {
targets {
fromPreset(presets.wasm32, 'html5Canvas') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.html5canvas.main'
targetFromPreset(presets.wasm32, 'html5Canvas') {
binaries {
executable() {
entryPoint = 'sample.html5canvas.main'
}
}
fromPreset(presets.jvm, 'httpServer')
}
jvm('httpServer')
sourceSets {
html5CanvasMain {
dependencies {
+1 -1
View File
@@ -9,7 +9,7 @@ each individual connection handler is written in simple linear manner.
To build use `../gradlew assemble`.
To run use `../gradlew runProgram` or execute the program directly:
To run use `../gradlew runReleaseExecutableNonBlockingEchoServer` or execute the program directly:
./build/bin/nonBlockingEchoServer/main/release/executable/nonBlockingEchoServer.kexe 3000 &
+7 -9
View File
@@ -6,14 +6,12 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64])
kotlin {
targets {
fromPreset(hostPreset, 'nonBlockingEchoServer') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.nbechoserver.main'
targetFromPreset(hostPreset, 'nonBlockingEchoServer') {
binaries {
executable() {
entryPoint = 'sample.nbechoserver.main'
runTask.args(3000)
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.nonBlockingEchoServer) {
args 3000
}
}
+6 -7
View File
@@ -6,12 +6,11 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64])
kotlin {
targets {
fromPreset(hostPreset, 'objc') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.objc.main'
targetFromPreset(hostPreset, 'objc') {
binaries {
executable() {
entryPoint = 'sample.objc.main'
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.objc)
}
+1 -1
View File
@@ -5,7 +5,7 @@ MacOS shall work as is.
To build use `../gradlew assemble`.
To run use `../gradlew runProgram` or execute the program directly:
To run use `../gradlew runReleaseExecutableOpengl` or execute the program directly:
./build/bin/opengl/main/release/executable/opengl.kexe
+6 -7
View File
@@ -6,12 +6,11 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64])
kotlin {
targets {
fromPreset(hostPreset, 'opengl') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.opengl.main'
targetFromPreset(hostPreset, 'opengl') {
binaries {
executable() {
entryPoint = 'sample.opengl.main'
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.opengl)
}
+9 -12
View File
@@ -6,18 +6,15 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project)
kotlin {
targets {
fromPreset(hostPreset, 'symbolication') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'symbolication.main'
compilations.main.cinterops {
coreSymbolication {
}
targetFromPreset(hostPreset, 'symbolication') {
binaries {
executable() {
entryPoint = 'symbolication.main'
}
}
compilations.main.cinterops {
coreSymbolication {
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.symbolication) {
//args "./test.kexe.dSYM/Contents/Resources/DWARF/test.kexe"
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ To build use `../gradlew assemble`.
Then run
../gradlew runProgram
../gradlew runReleaseExecutableTensorflow
Alternatively you can run the artifact directly through
+13 -16
View File
@@ -8,15 +8,18 @@ def tensorflowHome = "${MPPTools.kotlinNativeDataPath()}/third-party/tensorflow"
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64])
kotlin {
targets {
fromPreset(hostPreset, 'tensorflow') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.tensorflow.main'
compilations.main.linkerOpts "-L$tensorflowHome/lib", '-ltensorflow'
compilations.main.cinterops {
tensorflow {
includeDirs "$tensorflowHome/include"
}
targetFromPreset(hostPreset, 'tensorflow') {
binaries {
executable() {
entryPoint = 'sample.tensorflow.main'
linkerOpts += ["-L$tensorflowHome/lib".toString(), '-ltensorflow']
runTask.environment('LD_LIBRARY_PATH', "$tensorflowHome/lib".toString())
runTask.environment('DYLD_LIBRARY_PATH', "$tensorflowHome/lib".toString())
}
}
compilations.main.cinterops {
tensorflow {
includeDirs "$tensorflowHome/include"
}
}
}
@@ -26,10 +29,4 @@ task downloadTensorflow(type: Exec) {
workingDir projectDir
commandLine './downloadTensorflow.sh'
}
tasks[kotlin.targets.tensorflow.compilations.main.cinterops.tensorflow.interopProcessingTaskName].dependsOn downloadTensorflow
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.tensorflow) {
environment 'LD_LIBRARY_PATH': "$tensorflowHome/lib"
environment 'DYLD_LIBRARY_PATH': "$tensorflowHome/lib"
}
tasks[kotlin.targets.tensorflow.compilations.main.cinterops.tensorflow.interopProcessingTaskName].dependsOn downloadTensorflow
+1 -1
View File
@@ -15,7 +15,7 @@ To build Tetris application for your host platform use `../gradlew assemble`.
Note that SDL2 must be installed on the host.
Now you can run the game using `../gradlew runProgram` or directly with
Now you can run the game using `../gradlew runReleaseExecutableTetris` or directly with
./build/bin/tetris/main/release/executable/tetris.kexe
+53 -56
View File
@@ -6,56 +6,59 @@ File winCompiledResourceFile = file("$buildDir/compiledWindowsResources/Tetris.r
def hostPreset = determinePreset()
kotlin {
targets {
fromPreset(hostPreset, 'tetris') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.tetris.main'
switch (hostPreset) {
case presets.macosX64:
compilations.main.linkerOpts '-L/opt/local/lib', '-L/usr/local/lib', '-lSDL2'
break
case presets.linuxX64:
compilations.main.linkerOpts '-L/usr/lib64', '-L/usr/lib/x86_64-linux-gnu', '-lSDL2'
break
case presets.mingwX86:
case presets.mingwX64:
compilations.main.linkerOpts winCompiledResourceFile.path,
"-L${MPPTools.mingwPath(hostPreset)}/lib",
'-Wl,-Bstatic',
'-lstdc++',
'-static',
'-lSDL2',
'-limm32',
'-lole32',
'-loleaut32',
'-lversion',
'-lwinmm',
'-lsetupapi',
'-mwindows'
break
case presets.linuxArm32Hfp:
compilations.main.linkerOpts '-lSDL2'
break
targetFromPreset(hostPreset, 'tetris') {
binaries {
executable() {
entryPoint = 'sample.tetris.main'
switch (hostPreset) {
case presets.macosX64:
linkerOpts += ['-L/opt/local/lib', '-L/usr/local/lib', '-lSDL2']
break
case presets.linuxX64:
linkerOpts += ['-L/usr/lib64', '-L/usr/lib/x86_64-linux-gnu', '-lSDL2']
break
case presets.mingwX86:
case presets.mingwX64:
linkerOpts += [winCompiledResourceFile.path,
"-L${MPPTools.mingwPath(hostPreset)}/lib".toString(),
'-Wl,-Bstatic',
'-lstdc++',
'-static',
'-lSDL2',
'-limm32',
'-lole32',
'-loleaut32',
'-lversion',
'-lwinmm',
'-lsetupapi',
'-mwindows']
break
case presets.linuxArm32Hfp:
linkerOpts += ['-lSDL2']
break
}
runTask.workingDir(project.provider {
kotlin.targets.tetris.binaries.getExecutable(buildType).outputDirectory
})
}
compilations.main.cinterops {
sdl {
switch (hostPreset) {
case presets.macosX64:
includeDirs '/opt/local/include/SDL2', '/usr/local/include/SDL2'
break
case presets.linuxX64:
includeDirs '/usr/include/SDL2'
break
case presets.mingwX86:
case presets.mingwX64:
includeDirs "${MPPTools.mingwPath(hostPreset)}/include/SDL2"
break
case presets.linuxArm32Hfp:
includeDirs "${MPPTools.kotlinNativeDataPath()}/dependencies/target-sysroot-1-raspberrypi/usr/include/SDL2"
break
}
}
compilations.main.cinterops {
sdl {
switch (hostPreset) {
case presets.macosX64:
includeDirs '/opt/local/include/SDL2', '/usr/local/include/SDL2'
break
case presets.linuxX64:
includeDirs '/usr/include/SDL2'
break
case presets.mingwX86:
case presets.mingwX64:
includeDirs "${MPPTools.mingwPath(hostPreset)}/include/SDL2"
break
case presets.linuxArm32Hfp:
includeDirs "${MPPTools.kotlinNativeDataPath()}/dependencies/target-sysroot-1-raspberrypi/usr/include/SDL2"
break
}
}
}
@@ -82,16 +85,10 @@ if ((hostPreset == kotlin.presets.mingwX86) || (hostPreset == kotlin.presets.min
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.tetris) {
workingDir = project.provider {
kotlin.targets.tetris.compilations.main.getBinary('EXECUTABLE', buildType).parentFile
}
}
afterEvaluate {
kotlin.targets.tetris.compilations.main { mainCompilation ->
def linkTasks = ['RELEASE', 'DEBUG']
.collect { mainCompilation.findLinkTask('EXECUTABLE', it) }
.collect { kotlin.targets.tetris.binaries.getExecutable(it).linkTask }
.findAll { it != null }
def compileWindowsResourcesTask = tasks.findByName('compileWindowsResources')
+1 -1
View File
@@ -35,7 +35,7 @@ will download and unzip the [MNIST dataset](https://en.wikipedia.org/wiki/MNIST_
Then run
../gradlew runProgram
../gradlew runReleaseExecutableTorch
Alternatively you can run the artifact directly through
+14 -16
View File
@@ -8,15 +8,19 @@ def torchHome = "${MPPTools.kotlinNativeDataPath()}/third-party/torch"
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64])
kotlin {
targets {
fromPreset(hostPreset, 'torch') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.torch.main'
compilations.main.linkerOpts "-L$torchHome/lib", '-lATen'
compilations.main.cinterops {
torch {
includeDirs "$torchHome/include", "$torchHome/include/TH"
}
targetFromPreset(hostPreset, 'torch') {
binaries {
executable() {
entryPoint = 'sample.torch.main'
linkerOpts += ["-L$torchHome/lib".toString(), '-lATen']
runTask.dependsOn 'downloadMNIST'
runTask.environment('LD_LIBRARY_PATH', "$torchHome/lib".toString())
runTask.environment('DYLD_LIBRARY_PATH', "$torchHome/lib".toString())
}
}
compilations.main.cinterops {
torch {
includeDirs "$torchHome/include", "$torchHome/include/TH"
}
}
}
@@ -31,10 +35,4 @@ tasks[kotlin.targets.torch.compilations.main.cinterops.torch.interopProcessingTa
task downloadMNIST(type: Exec) {
workingDir projectDir
commandLine './downloadMNIST.sh'
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.torch) {
dependsOn downloadMNIST
environment 'LD_LIBRARY_PATH': "$torchHome/lib"
environment 'DYLD_LIBRARY_PATH': "$torchHome/lib"
}
}
+42 -41
View File
@@ -6,49 +6,50 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64, kotlin.presets.mingwX64])
kotlin {
targets {
fromPreset(hostPreset, 'videoPlayer') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.videoplayer.main'
targetFromPreset(hostPreset, 'videoPlayer') {
binaries {
executable() {
entryPoint = 'sample.videoplayer.main'
switch (hostPreset) {
case presets.macosX64:
compilations.main.linkerOpts '-L/opt/local/lib', '-L/usr/local/lib'
break
case presets.linuxX64:
compilations.main.linkerOpts '-L/usr/lib/x86_64-linux-gnu', '-L/usr/lib64'
break
case presets.mingwX64:
compilations.main.linkerOpts "-L${MPPTools.mingwPath()}/lib"
break
}
compilations.main.cinterops {
ffmpeg {
switch (hostPreset) {
case presets.macosX64:
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
break
case presets.linuxX64:
includeDirs.headerFilterOnly '/usr/include', '/usr/include/x86_64-linux-gnu', '/usr/include/ffmpeg'
break
case presets.mingwX64:
includeDirs "${MPPTools.mingwPath()}/include"
break
}
switch (hostPreset) {
case presets.macosX64:
linkerOpts += ['-L/opt/local/lib', '-L/usr/local/lib']
break
case presets.linuxX64:
linkerOpts += ['-L/usr/lib/x86_64-linux-gnu', '-L/usr/lib64']
break
case presets.mingwX64:
linkerOpts += ["-L${MPPTools.mingwPath()}/lib".toString()]
break
}
sdl {
switch (hostPreset) {
case presets.macosX64:
includeDirs '/opt/local/include/SDL2', '/usr/local/include/SDL2'
break
case presets.linuxX64:
includeDirs '/usr/include/SDL2'
break
case presets.mingwX64:
includeDirs "${MPPTools.mingwPath()}/include/SDL2"
break
}
}
}
compilations.main.cinterops {
ffmpeg {
switch (hostPreset) {
case presets.macosX64:
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
break
case presets.linuxX64:
includeDirs.headerFilterOnly '/usr/include', '/usr/include/x86_64-linux-gnu', '/usr/include/ffmpeg'
break
case presets.mingwX64:
includeDirs "${MPPTools.mingwPath()}/include"
break
}
}
sdl {
switch (hostPreset) {
case presets.macosX64:
includeDirs '/opt/local/include/SDL2', '/usr/local/include/SDL2'
break
case presets.linuxX64:
includeDirs '/usr/include/SDL2'
break
case presets.mingwX64:
includeDirs "${MPPTools.mingwPath()}/include/SDL2"
break
}
}
}
+1 -1
View File
@@ -2,6 +2,6 @@
To build use `..\gradlew assemble`.
To run use `..\gradlew runProgram` or execute the program directly:
To run use `..\gradlew runReleaseExecutableWin32` or execute the program directly:
`.\build\exe\main\release\MessageBox.exe`.
+6 -7
View File
@@ -6,13 +6,12 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.mingwX64])
kotlin {
targets {
fromPreset(hostPreset, 'win32') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.win32.main'
compilations.main.linkerOpts '-Wl,--subsystem,windows'
targetFromPreset(hostPreset, 'win32') {
binaries {
executable() {
entryPoint = 'sample.win32.main'
linkerOpts += ['-Wl,--subsystem,windows']
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.win32)
+1 -1
View File
@@ -38,6 +38,6 @@ computation results. Afterwards, worker execution termination is requested with
To build use `../gradlew assemble`.
To run use `../gradlew runProgram` or execute the program directly:
To run use `../gradlew runReleaseExecutableWorkers` or execute the program directly:
./build/bin/workers/main/release/executable/workers.kexe
+6 -7
View File
@@ -6,12 +6,11 @@ plugins {
def hostPreset = MPPTools.defaultHostPreset(project)
kotlin {
targets {
fromPreset(hostPreset, 'workers') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.workers.main'
targetFromPreset(hostPreset, 'workers') {
binaries {
executable() {
entryPoint = 'sample.workers.main'
}
}
}
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.workers)
}