[samples] Switch to the new DSL in some samples
This commit is contained in:
committed by
Ilya Matveev
parent
b876fdb5bc
commit
e491ef45c4
@@ -1,15 +1,11 @@
|
|||||||
subprojects {
|
subprojects {
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven { url 'https://cache-redirector.jetbrains.com/maven-central' }
|
||||||
url 'https://cache-redirector.jetbrains.com/maven-central'
|
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
|
||||||
}
|
maven {
|
||||||
maven {
|
url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_13M1_Compiler),number:1.3-M1-eap-77,branch:default:any/artifacts/content/maven/"
|
||||||
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
|
}
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_13M1_Compiler),number:1.3-M1-eap-77,branch:default:any/artifacts/content/maven/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -4,16 +4,11 @@
|
|||||||
A sample data [European Mammals Red List for 2009](https://data.europa.eu/euodp/en/data/dataset?res_format=CSV)
|
A sample data [European Mammals Red List for 2009](https://data.europa.eu/euodp/en/data/dataset?res_format=CSV)
|
||||||
from EU is being used.
|
from EU is being used.
|
||||||
|
|
||||||
To build use `../gradlew build` or `./build.sh`.
|
To build use `../gradlew assemble` or `./build.sh`.
|
||||||
|
|
||||||
To run use `../gradlew run`
|
Now you can run artifact directly
|
||||||
|
|
||||||
To change run arguments, change property runArgs in gradle.propeties file
|
./build/exe/main/release/csvparser.kexe ./European_Mammals_Red_List_Nov_2009.csv 4 100
|
||||||
or pass `-PrunArgs="./European_Mammals_Red_List_Nov_2009.csv 4 100"` to gradle run.
|
|
||||||
|
|
||||||
Alternatively you can run artifact directly
|
|
||||||
|
|
||||||
./build/konan/bin/<target>/CsvParser.kexe ./European_Mammals_Red_List_Nov_2009.csv 4 100
|
|
||||||
|
|
||||||
It will print number of all unique entries in fifth column
|
It will print number of all unique entries in fifth column
|
||||||
(Family, zero-based index) in first 100 rows of the CSV file.
|
(Family, zero-based index) in first 100 rows of the CSV file.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konanArtifacts {
|
components.main {
|
||||||
program('CsvParser')
|
outputKinds = [ EXECUTABLE ]
|
||||||
}
|
}
|
||||||
@@ -4,15 +4,10 @@ This example shows how to communicate with libcurl, HTTP/HTTPS/FTP/etc client li
|
|||||||
depend on an artifact published in a maven repository. The sample depends on a library
|
depend on an artifact published in a maven repository. The sample depends on a library
|
||||||
built by [libcurl sample](../libcurl) so you need to run it first.
|
built by [libcurl sample](../libcurl) so you need to run it first.
|
||||||
|
|
||||||
To build use `../gradlew build`.
|
To build use `../gradlew assemble`.
|
||||||
|
|
||||||
To run use `../gradlew run`.
|
Now you can run the client directly
|
||||||
|
|
||||||
To change run arguments, change property runArgs in gradle.propeties file
|
./build/exe/main/release/<platform>/curl.kexe https://www.jetbrains.com
|
||||||
or pass `-PrunArgs="https://www.jetbrains.com"` to gradle run.
|
|
||||||
|
|
||||||
Alternatively you can run artifact directly
|
|
||||||
|
|
||||||
./build/konan/bin/<platform>/Curl.kexe https://www.jetbrains.com
|
|
||||||
|
|
||||||
It will perform HTTP get and print out the data obtained.
|
It will perform HTTP get and print out the data obtained.
|
||||||
|
|||||||
+10
-17
@@ -1,14 +1,8 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven { url 'https://cache-redirector.jetbrains.com/maven-central' }
|
||||||
url 'https://cache-redirector.jetbrains.com/maven-central'
|
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
|
||||||
}
|
maven { url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_13M1_Compiler),number:1.3-M1-eap-77,branch:default:any/artifacts/content/maven/" }
|
||||||
maven {
|
|
||||||
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_13M1_Compiler),number:1.3-M1-eap-77,branch:default:any/artifacts/content/maven/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -16,9 +10,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ['macbook', 'linux']
|
|
||||||
|
|
||||||
def localMavenRepo="file://${new File(System.properties['user.home'] as String)}/.m2-kotlin-native"
|
def localMavenRepo="file://${new File(System.properties['user.home'] as String)}/.m2-kotlin-native"
|
||||||
|
|
||||||
@@ -28,10 +20,11 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
konanArtifacts {
|
components.main {
|
||||||
program('Curl') {
|
targets = ['macos_x64', 'linux_x64']
|
||||||
dependencies {
|
outputKinds = [ EXECUTABLE ]
|
||||||
artifactCurl 'org.jetbrains.kotlin.native:libcurl:1.0'
|
|
||||||
}
|
dependencies {
|
||||||
|
implementation 'org.jetbrains.kotlin.native:libcurl:1.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
konan.home=../../dist
|
konan.home=../../dist
|
||||||
konan.plugin.version=+
|
konan.plugin.version=+
|
||||||
runArgs=https://www.jetbrains.com
|
|
||||||
@@ -1,3 +1,23 @@
|
|||||||
|
import org.konan.libcurl.*
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
org.konan.libcurl.main(args)
|
if (args.size == 0)
|
||||||
}
|
return help()
|
||||||
|
|
||||||
|
val curl = CUrl(args[0])
|
||||||
|
curl.header += {
|
||||||
|
println("[H] $it")
|
||||||
|
}
|
||||||
|
|
||||||
|
curl.body += {
|
||||||
|
println("[B] $it")
|
||||||
|
}
|
||||||
|
|
||||||
|
curl.fetch()
|
||||||
|
curl.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun help() {
|
||||||
|
println("ERROR: missing URL command line argument")
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
package org.konan.libcurl
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
if (args.size == 0)
|
|
||||||
return help()
|
|
||||||
|
|
||||||
val curl = CUrl(args[0])
|
|
||||||
curl.header += {
|
|
||||||
println("[H] $it")
|
|
||||||
}
|
|
||||||
|
|
||||||
curl.body += {
|
|
||||||
println("[B] $it")
|
|
||||||
}
|
|
||||||
|
|
||||||
curl.fetch()
|
|
||||||
curl.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun help() {
|
|
||||||
println("ERROR: missing URL command line argument")
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -3,15 +3,10 @@
|
|||||||
This example shows how one could perform statistics on Git repository.
|
This example shows how one could perform statistics on Git repository.
|
||||||
libgit2 is required for this to work (`apt-get install libgit2-dev`).
|
libgit2 is required for this to work (`apt-get install libgit2-dev`).
|
||||||
|
|
||||||
To build use `../gradlew build` or `./build.sh`.
|
To build use `../gradlew assemble` or `./build.sh`.
|
||||||
|
|
||||||
To run use `../gradlew run`.
|
Now you can run the program directly
|
||||||
|
|
||||||
To change run arguments, change property runArgs in gradle.propeties file
|
./build/exe/main/release/<platform>/gitchurn.kexe ../../
|
||||||
or pass `-PrunArgs="../../"` to gradle run.
|
|
||||||
|
|
||||||
Alternatively you can run artifact directly
|
|
||||||
|
|
||||||
./build/konan/bin/<target>/GitChurn.kexe ../../
|
|
||||||
|
|
||||||
It will print most frequently modified (by number of commits) files in repository.
|
It will print most frequently modified (by number of commits) files in repository.
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ['macbook', 'linux']
|
components.main {
|
||||||
|
targets = ['macos_x64', 'linux_x64']
|
||||||
|
outputKinds = [EXECUTABLE]
|
||||||
|
|
||||||
konanArtifacts {
|
dependencies {
|
||||||
interop('libgit2') {
|
cinterop('libgit2') {
|
||||||
target('linux') {
|
target('linux') {
|
||||||
includeDirs.headerFilterOnly '/usr/include'
|
includeDirs.headerFilterOnly '/usr/include'
|
||||||
}
|
}
|
||||||
|
|
||||||
target('macbook') {
|
target('macbook') {
|
||||||
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
program('GitChurn') {
|
|
||||||
libraries {
|
|
||||||
artifact 'libgit2'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
runArgs=../../
|
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This example shows how one could implement global shared state using interop mechanisms.
|
This example shows how one could implement global shared state using interop mechanisms.
|
||||||
|
|
||||||
To build use `../gradlew build`.
|
To build use `../gradlew assemble`.
|
||||||
|
|
||||||
To run use `./build/konan/bin/<platform>/Globals.exe`.
|
To run use `./build/exe/main/release/<platform>/globalState.kexe`.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ['macbook', 'linux', 'mingw']
|
components.main {
|
||||||
|
targets = ['macos_x64', 'linux_x64', 'mingw_x64']
|
||||||
|
outputKinds = [EXECUTABLE]
|
||||||
|
|
||||||
konanArtifacts {
|
dependencies {
|
||||||
interop('global') {
|
cinterop('global')
|
||||||
defFile 'src/main/c_interop/global.def'
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
program('Globals') {
|
|
||||||
libraries {
|
|
||||||
artifact 'global'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,18 +3,14 @@
|
|||||||
This example shows how one may use _Kotlin/Native_ to build GUI
|
This example shows how one may use _Kotlin/Native_ to build GUI
|
||||||
applications with the GTK toolkit.
|
applications with the GTK toolkit.
|
||||||
|
|
||||||
To build use `../gradlew build` or `./build.sh [-I=/include/path]`.
|
To build use `../gradlew assemble` or `./build.sh [-I=/include/path]`.
|
||||||
|
|
||||||
Do not forget to install GTK3. See bellow.
|
Do not forget to install GTK3. See bellow.
|
||||||
|
|
||||||
On Mac use `port install gtk3`, on Debian flavours of Linux - `apt-get install libgtk-3-dev`.
|
On Mac use `port install gtk3`, on Debian flavours of Linux - `apt-get install libgtk-3-dev`.
|
||||||
To run on Mac also install XQuartz X server (https://www.xquartz.org/), and then
|
To run on Mac also install XQuartz X server (https://www.xquartz.org/), and then
|
||||||
|
|
||||||
../gradlew run
|
./build/exe/main/release/<platform>/gtk.kexe
|
||||||
|
|
||||||
Alternatively you can run artifact directly
|
|
||||||
|
|
||||||
./build/konan/bin/<platform>/Gtk3Demo.kexe
|
|
||||||
|
|
||||||
Dialog box with the button will be shown, and application will print message
|
Dialog box with the button will be shown, and application will print message
|
||||||
and terminate on button click.
|
and terminate on button click.
|
||||||
|
|||||||
+10
-16
@@ -1,23 +1,17 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan {
|
|
||||||
targets = ['macbook', 'linux']
|
|
||||||
jvmArgs = ['-Xmx8g']
|
|
||||||
}
|
|
||||||
|
|
||||||
def includePrefixes = [ '/opt/local/include', '/usr/include', '/usr/local/include' ]
|
def includePrefixes = [ '/opt/local/include', '/usr/include', '/usr/local/include' ]
|
||||||
|
|
||||||
konanArtifacts {
|
components.main {
|
||||||
interop('gtk3') {
|
targets = ['macos_x64', 'linux_x64']
|
||||||
includePrefixes.each {
|
outputKinds = [EXECUTABLE]
|
||||||
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'
|
|
||||||
}
|
|
||||||
|
|
||||||
program('Gtk3Demo') {
|
dependencies {
|
||||||
libraries {
|
cinterop('gtk3') {
|
||||||
artifact 'gtk3'
|
includePrefixes.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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
konan.jvmArgs=-Xmx8g
|
||||||
@@ -4,7 +4,7 @@ This example shows how to build and publish an interop library to communicate wi
|
|||||||
HTTP/HTTPS/FTP/etc client library. Debian-like distros may need to
|
HTTP/HTTPS/FTP/etc client library. Debian-like distros may need to
|
||||||
`apt-get install libcurl4-openssl-dev`.
|
`apt-get install libcurl4-openssl-dev`.
|
||||||
|
|
||||||
To build use `../gradlew build`
|
To build use `../gradlew assemble`
|
||||||
|
|
||||||
To publish the library into a local repo use `../gradlew publish`
|
To publish the library into a local repo use `../gradlew publish`
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,36 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
konan.targets = ['macbook', 'linux']
|
|
||||||
|
|
||||||
group 'org.jetbrains.kotlin.native'
|
group 'org.jetbrains.kotlin.native'
|
||||||
version '1.0'
|
version '1.0'
|
||||||
|
|
||||||
konanArtifacts {
|
// Native component
|
||||||
interop('libcurl') {
|
components.main {
|
||||||
target('linux') {
|
targets = ['macos_x64', 'linux_x64']
|
||||||
includeDirs.headerFilterOnly '/usr/include'
|
|
||||||
}
|
dependencies {
|
||||||
target('macbook') {
|
cinterop('libcurl-interop') {
|
||||||
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
defFile 'src/main/c_interop/libcurl.def'
|
||||||
}
|
|
||||||
pom {
|
target('linux_x64') {
|
||||||
withXml {
|
includeDirs.headerFilterOnly '/usr/include'
|
||||||
def root = asNode()
|
|
||||||
root.appendNode('name', 'libcurl interop library')
|
|
||||||
root.appendNode('description', 'A library providing interoperability with host libcurl')
|
|
||||||
}
|
}
|
||||||
|
target('macos_x64') {
|
||||||
|
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pom {
|
||||||
|
withXml {
|
||||||
|
def root = asNode()
|
||||||
|
root.appendNode('name', 'libcurl interop library')
|
||||||
|
root.appendNode('description', 'A library providing interoperability with host libcurl')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'maven-publish'
|
// Publishing
|
||||||
def localMavenRepo="file://${new File(System.properties['user.home'] as String)}/.m2-kotlin-native"
|
def localMavenRepo="file://${new File(System.properties['user.home'] as String)}/.m2-kotlin-native"
|
||||||
|
|
||||||
task cleanLocalRepo(type: Delete) {
|
task cleanLocalRepo(type: Delete) {
|
||||||
@@ -31,20 +38,9 @@ task cleanLocalRepo(type: Delete) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications{
|
|
||||||
libcurl(MavenPublication) {
|
|
||||||
artifact sourceJar{
|
|
||||||
classifier "source"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url = localMavenRepo
|
url = localMavenRepo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
task sourceJar(type: Jar) {
|
|
||||||
from project.files('src/main')
|
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
runArgs=https://www.jetbrains.com
|
|
||||||
@@ -7,18 +7,11 @@ are being suspended and resumed whenever relevant.
|
|||||||
Thus, while server can process multiple connections concurrently,
|
Thus, while server can process multiple connections concurrently,
|
||||||
each individual connection handler is written in simple linear manner.
|
each individual connection handler is written in simple linear manner.
|
||||||
|
|
||||||
To build use `../gradlew build` or `./build.sh`.
|
To build use `../gradlew assemble` or `./build.sh`.
|
||||||
|
|
||||||
Run the server:
|
Now you can run the server
|
||||||
|
|
||||||
../gradlew run
|
./build/exe/main/release/<platform>/EchoServer.kexe 3000 &
|
||||||
|
|
||||||
To change run arguments, change property runArgs in gradle.propeties file
|
|
||||||
or pass `-PrunArgs="3000"` to gradle run.
|
|
||||||
|
|
||||||
Alternatively you can run artifact directly
|
|
||||||
|
|
||||||
./build/konan/bin/<platform>/EchoServer.kexe 3000 &
|
|
||||||
|
|
||||||
Test the server by connecting to it, for example with telnet:
|
Test the server by connecting to it, for example with telnet:
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ['macbook', 'linux']
|
components.main {
|
||||||
|
targets = ['macos_x64', 'linux_x64']
|
||||||
konanArtifacts {
|
outputKinds = [EXECUTABLE]
|
||||||
program('EchoServer')
|
baseName = 'EchoServer'
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ['macbook']
|
components.main {
|
||||||
|
targets = ['macos_x64']
|
||||||
konanArtifacts {
|
outputKinds = [EXECUTABLE]
|
||||||
program('Window')
|
baseName = 'Window'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
# OpenGL application
|
# OpenGL application
|
||||||
|
|
||||||
This example shows interaction with OpenGL library, to render classical 3D test model. Linux build requires `apt-get install freeglut3-dev` or similar,
|
This example shows interaction with OpenGL library, to render classical 3D test model. Linux build requires `apt-get install freeglut3-dev` or similar,
|
||||||
MacOS shall work as is.
|
MacOS shall work as is.
|
||||||
|
|
||||||
To build use `../gradlew build` or `./build.sh`.
|
To build use `../gradlew assemble` or `./build.sh`.
|
||||||
|
|
||||||
To run use `../gradlew run`
|
Now you can run the application
|
||||||
|
|
||||||
Alternatively you can run artifact directly
|
|
||||||
|
|
||||||
./build/konan/bin/<platform>/OpenGlTeapot.kexe
|
./build/exe/main/release/OpenGlTeapot.kexe
|
||||||
|
|
||||||
It will render 3D model of teapot. Feel free to experiment with it, the whole power of OpenGL
|
It will render 3D model of teapot. Feel free to experiment with it, the whole power of OpenGL
|
||||||
is at your hands.
|
is at your hands.
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ["macbook"]
|
components.main {
|
||||||
|
targets = ['macos_x64']
|
||||||
konanArtifacts {
|
outputKinds = [EXECUTABLE]
|
||||||
program('OpenGlTeapot')
|
baseName = 'OpenGlTeapot'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,9 @@
|
|||||||
|
|
||||||
To build use `../gradlew build` or `./build.sh`.
|
To build use `../gradlew build` or `./build.sh`.
|
||||||
|
|
||||||
Run the server:
|
Now you can run the server
|
||||||
|
|
||||||
../gradlew run
|
./build/exe/main/release/EchoServer.kexe 3000 &
|
||||||
|
|
||||||
To change run arguments, change property runArgs in gradle.propeties file
|
|
||||||
or pass `-PrunArgs="3000"` to gradle run.
|
|
||||||
|
|
||||||
Alternatively you can run artifact directly
|
|
||||||
|
|
||||||
./build/konan/bin/<platform>/EchoServer.kexe 3000 &
|
|
||||||
|
|
||||||
Test the server by conecting to it, for example with telnet:
|
Test the server by conecting to it, for example with telnet:
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konanArtifacts {
|
components.main {
|
||||||
program('EchoServer')
|
outputKinds = [EXECUTABLE]
|
||||||
|
baseName = 'EchoServer'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
runArgs=3000
|
|
||||||
@@ -13,28 +13,18 @@ use `apt-get install libsdl2-dev`.
|
|||||||
For Windows - `pacman -S mingw-w64-x86_64-SDL2` in MinGW64 console, if you do
|
For Windows - `pacman -S mingw-w64-x86_64-SDL2` in MinGW64 console, if you do
|
||||||
not have MSYS2-MinGW64 installed - install it first as described in http://www.msys2.org
|
not have MSYS2-MinGW64 installed - install it first as described in http://www.msys2.org
|
||||||
|
|
||||||
To build Tetris application for your host platform (Mac or Linux) use `../gradlew build`.
|
To build Tetris application for your host platform (Mac or Linux) use `../gradlew assemble`.
|
||||||
|
|
||||||
Aleternatively for Mac and Linux `./build.sh`.
|
Aleternatively for Mac and Linux `./build.sh`.
|
||||||
|
|
||||||
For Windows use `build.bat`.
|
For Windows use `build.bat`.
|
||||||
|
|
||||||
This task builds the sample for your host platform. Note that SDL2 must be installed on the host.
|
Note that SDL2 must be installed on the host.
|
||||||
|
|
||||||
To run it on the host use `../gradlew run`
|
Now you can run the game
|
||||||
|
|
||||||
Alternatively you can run artifact directly
|
|
||||||
|
|
||||||
./build/konan/bin/Tetris${target}/Tetris${target}.kexe
|
|
||||||
|
|
||||||
For cross-compilation to iOS (on Mac host) use gradle property
|
|
||||||
|
|
||||||
konan.build.targets=iphone
|
|
||||||
|
|
||||||
For cross-compilation to Raspberry Pi (on Linux host) use
|
|
||||||
|
|
||||||
konan.build.targets=raspberrypi
|
|
||||||
|
|
||||||
|
./build/exe/main/release/<platform>/tetris.[kexe|exe]
|
||||||
|
|
||||||
During build process compilation script creates interoperability bindings to SDL2, using SDL C headers,
|
During build process compilation script creates interoperability bindings to SDL2, using SDL C headers,
|
||||||
and then compiles an application with the produced bindings.
|
and then compiles an application with the produced bindings.
|
||||||
|
|
||||||
|
|||||||
+56
-54
@@ -1,59 +1,63 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ['macbook', 'linux', 'raspberrypi', 'mingw']
|
|
||||||
|
|
||||||
def konanUserDir = System.getenv("KONAN_DATA_DIR") ?: "${System.getProperty("user.home")}/.konan"
|
def konanUserDir = System.getenv("KONAN_DATA_DIR") ?: "${System.getProperty("user.home")}/.konan"
|
||||||
def resFile = file("$buildDir/konan/res/Tetris.res")
|
def resFile = file("$buildDir/konan/res/Tetris.res")
|
||||||
|
|
||||||
konanArtifacts {
|
components.main {
|
||||||
|
targets = ['macos_x64', 'linux_x64', 'raspberrypi', 'mingw_x64']
|
||||||
|
outputKinds = [EXECUTABLE]
|
||||||
|
baseName = 'tetris'
|
||||||
|
|
||||||
interop ('sdl') {
|
target 'macbook', {
|
||||||
defFile 'src/main/c_interop/sdl.def'
|
linkerOpts "-F ${System.getProperty("user.home")}/Library/Frameworks -F /Library/Frameworks -framework SDL2"
|
||||||
packageName 'sdl'
|
// Use this line instead of the previous one if you've got a 'No SDL-framework' error.
|
||||||
|
//linkerOpts "-L/opt/local/lib -L/usr/local/lib -lSDL2"
|
||||||
target 'macbook', {
|
|
||||||
includeDirs '/Library/Frameworks/SDL2.framework/Headers',
|
|
||||||
"${System.getProperty("user.home")}/Library/Frameworks/SDL2.framework/Headers",
|
|
||||||
'/opt/local/include/SDL2',
|
|
||||||
'/usr/local/include/SDL2'
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'linux', {
|
|
||||||
includeDirs '/usr/include/SDL2'
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'raspberrypi', {
|
|
||||||
includeDirs "$konanUserDir/dependencies/target-sysroot-1-raspberrypi/usr/include/SDL2"
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'mingw', {
|
|
||||||
includeDirs "${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/include/SDL2"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
program ('tetris') {
|
target 'linux', {
|
||||||
libraries {
|
linkerOpts '-L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lSDL2'
|
||||||
artifact 'sdl'
|
}
|
||||||
}
|
|
||||||
|
|
||||||
target 'macbook', {
|
target 'raspberrypi', {
|
||||||
linkerOpts "-F ${System.getProperty("user.home")}/Library/Frameworks -F /Library/Frameworks -framework SDL2"
|
linkerOpts '-lSDL2'
|
||||||
// Use this line instead of the previous one if you've got a 'No SDL-framework' error.
|
}
|
||||||
//linkerOpts "-L/opt/local/lib -L/usr/local/lib -lSDL2"
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'linux', {
|
target 'mingw', {
|
||||||
linkerOpts '-L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lSDL2'
|
linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -Wl,-Bstatic -lstdc++ -static -lSDL2 -limm32 -lole32 -loleaut32 -lversion -lwinmm -mwindows"
|
||||||
}
|
}
|
||||||
|
|
||||||
target 'raspberrypi', {
|
dependencies {
|
||||||
linkerOpts '-lSDL2'
|
cinterop('sdl') {
|
||||||
}
|
packageName 'sdl'
|
||||||
|
target 'macos_x64', {
|
||||||
|
includeDirs '/Library/Frameworks/SDL2.framework/Headers',
|
||||||
|
"${System.getProperty("user.home")}/Library/Frameworks/SDL2.framework/Headers",
|
||||||
|
'/opt/local/include/SDL2',
|
||||||
|
'/usr/local/include/SDL2'
|
||||||
|
}
|
||||||
|
|
||||||
target 'mingw', {
|
target 'linux_x64', {
|
||||||
linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -Wl,-Bstatic -lstdc++ -static -lSDL2 -limm32 -lole32 -loleaut32 -lversion -lwinmm -mwindows"
|
includeDirs '/usr/include/SDL2'
|
||||||
dependsOn 'windowsResources'
|
}
|
||||||
inputs.file resFile
|
|
||||||
|
target 'raspberrypi', {
|
||||||
|
includeDirs "$konanUserDir/dependencies/target-sysroot-1-raspberrypi/usr/include/SDL2"
|
||||||
|
}
|
||||||
|
|
||||||
|
target 'mingw_x64', {
|
||||||
|
includeDirs "${System.getenv("MINGW64_DIR") ?: "c:/msys64/mingw64"}/include/SDL2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assemble {
|
||||||
|
doLast {
|
||||||
|
components.withType(KotlinNativeExecutable.class).all { binary ->
|
||||||
|
copy {
|
||||||
|
from 'src/main/resources'
|
||||||
|
into binary.runtimeFile.asFile.get().parentFile
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,13 +75,11 @@ task windowsResources (type: Exec) {
|
|||||||
outputs.file resFile
|
outputs.file resFile
|
||||||
}
|
}
|
||||||
|
|
||||||
compileKonan {
|
project.tasks.matching {
|
||||||
doLast {
|
name == 'compileDebugMingw_x64KotlinNative' ||
|
||||||
konanArtifacts.tetris.forEach() { task ->
|
name == 'compileReleaseMingw_x64KotlinNative'
|
||||||
copy {
|
}.all {
|
||||||
from 'src/main/resources'
|
dependsOn 'windowsResources'
|
||||||
into task.artifact.parentFile
|
inputs.file resFile
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ ffmpeg and SDL2 is needed for that to work, i.e.
|
|||||||
apt install libsdl2-dev
|
apt install libsdl2-dev
|
||||||
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-ffmpeg
|
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-ffmpeg
|
||||||
|
|
||||||
To build use `../gradlew build`.
|
To build use `../gradlew assemble`.
|
||||||
|
|
||||||
To run use `./build/konan/bin/<platform>/Player.kexe file.mp4`.
|
To run use `./build/exe/main/release/<platform>/Player.kexe file.mp4`.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,60 +1,54 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ['macbook', 'linux', 'mingw']
|
components.main {
|
||||||
|
targets = ['macos_x64', 'linux_x64', 'mingw_x64']
|
||||||
|
outputKinds = [EXECUTABLE]
|
||||||
|
baseName = 'Player'
|
||||||
|
|
||||||
konanArtifacts {
|
dependencies {
|
||||||
interop('ffmpeg') {
|
cinterop('ffmpeg') {
|
||||||
defFile 'src/main/c_interop/ffmpeg.def'
|
target 'macos_x64', {
|
||||||
|
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
||||||
|
}
|
||||||
|
|
||||||
target 'linux', {
|
target 'linux_x64', {
|
||||||
includeDirs.headerFilterOnly '/usr/include', '/usr/include/x86_64-linux-gnu', '/usr/include/ffmpeg'
|
includeDirs.headerFilterOnly '/usr/include', '/usr/include/x86_64-linux-gnu', '/usr/include/ffmpeg'
|
||||||
|
}
|
||||||
|
|
||||||
|
target 'mingw_x64', {
|
||||||
|
includeDirs 'C:/msys64/mingw64/include'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target 'macbook', {
|
cinterop ('sdl') {
|
||||||
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
target 'macos_x64', {
|
||||||
}
|
includeDirs '/Library/Frameworks/SDL2.framework/Headers',
|
||||||
|
"${System.getProperty("user.home")}/Library/Frameworks/SDL2.framework/Headers",
|
||||||
|
'/opt/local/include/SDL2',
|
||||||
|
'/usr/local/include/SDL2'
|
||||||
|
}
|
||||||
|
|
||||||
target 'mingw', {
|
target 'linux_x64', {
|
||||||
includeDirs 'C:/msys64/mingw64/include'
|
includeDirs '/usr/include/SDL2'
|
||||||
|
}
|
||||||
|
|
||||||
|
target 'mingw_x64', {
|
||||||
|
includeDirs 'C:/msys64/mingw64/include/SDL2'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interop ('sdl') {
|
target 'macos_x64', {
|
||||||
defFile 'src/main/c_interop/sdl.def'
|
linkerOpts "-F ${System.getProperty("user.home")}/Library/Frameworks", "-F /Library/Frameworks",
|
||||||
|
"-L/opt/local/lib", "-L/usr/local/lib"
|
||||||
target 'macbook', {
|
|
||||||
includeDirs '/Library/Frameworks/SDL2.framework/Headers',
|
|
||||||
"${System.getProperty("user.home")}/Library/Frameworks/SDL2.framework/Headers",
|
|
||||||
'/opt/local/include/SDL2',
|
|
||||||
'/usr/local/include/SDL2'
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'linux', {
|
|
||||||
includeDirs '/usr/include/SDL2'
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'mingw', {
|
|
||||||
includeDirs 'C:/msys64/mingw64/include/SDL2'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
program('Player') {
|
target 'linux_x64', {
|
||||||
libraries {
|
linkerOpts '-L/usr/lib/x86_64-linux-gnu', '-L/usr/lib64'
|
||||||
artifact 'ffmpeg'
|
}
|
||||||
artifact 'sdl'
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'macbook', {
|
target 'mingw_x64', {
|
||||||
linkerOpts "-F ${System.getProperty("user.home")}/Library/Frameworks", "-F /Library/Frameworks",
|
linkerOpts '-LC:/msys64/mingw64/lib'
|
||||||
"-L/opt/local/lib", "-L/usr/local/lib"
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'linux', {
|
|
||||||
linkerOpts '-L/usr/lib/x86_64-linux-gnu', '-L/usr/lib64'
|
|
||||||
}
|
|
||||||
|
|
||||||
target 'mingw', {
|
|
||||||
linkerOpts '-LC:/msys64/mingw64/lib'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# WIN32 Hello World
|
# WIN32 Hello World
|
||||||
|
|
||||||
To build use `..\gradlew build` or `build.bat`.
|
To build use `..\gradlew assemble` or `build.bat`.
|
||||||
|
|
||||||
To run use `..\gradlew run` or `MessageBox.exe`.
|
To run use `.\build\exe\main\release\MessageBox.exe`.
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konan.targets = ['mingw']
|
components.main {
|
||||||
|
targets = ['mingw_x64']
|
||||||
|
outputKinds = [EXECUTABLE]
|
||||||
|
baseName = 'MessageBox'
|
||||||
|
|
||||||
konanArtifacts {
|
target('mingw_x64') {
|
||||||
program('MessageBox') {
|
|
||||||
linkerOpts "-Wl,--subsystem,windows"
|
linkerOpts "-Wl,--subsystem,windows"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,6 @@ Then it continues execution, and waits on future objects encapsulating the
|
|||||||
computation results. Afterwards, worker execution termination is requested with the
|
computation results. Afterwards, worker execution termination is requested with the
|
||||||
`requestTermination()` operation.
|
`requestTermination()` operation.
|
||||||
|
|
||||||
To build use `./build.sh`.
|
To build use `./build.sh` or `./gradlew assemble`
|
||||||
|
|
||||||
To run use `./build/konan/bin/Worker.kexe`
|
To run use `./build/exe/main/release/workers.kexe`
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
apply plugin: 'konan'
|
apply plugin: 'org.jetbrains.kotlin.platform.native'
|
||||||
|
|
||||||
konanArtifacts {
|
components.main {
|
||||||
program('Workers')
|
outputKinds = [ EXECUTABLE ]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user