From ac37d95ff1446c88bb1a6c6b99e876c00a9fcb13 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Mon, 3 Apr 2017 17:22:30 +0300 Subject: [PATCH] Minor fixes --- DISTRO_README.md | 41 +++++++++++++++++++++++++++++++++++++ FAQ.md | 8 +++++++- GRADLE_PLUGIN.md | 2 +- build.gradle | 8 +++++++- samples/tetris/Tetris.kt | 5 +---- samples/tetris/build.gradle | 4 ++-- 6 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 DISTRO_README.md diff --git a/DISTRO_README.md b/DISTRO_README.md new file mode 100644 index 00000000000..15ff8bbbcaf --- /dev/null +++ b/DISTRO_README.md @@ -0,0 +1,41 @@ + Kotlin/Native # + +_Kotlin/Native_ is a LLVM backend for the Kotlin compiler, runtime +implementation and native code generation facility using LLVM toolchain. + + _Kotlin/Native_ is primarily designed to allow compilation for platforms where +virtual machines are not desirable or possible (such as iOS, embedded targets), +or where developer is willing to produce reasonably-sized self-contained program +without need to ship an additional execution runtime. + + To get started with _Kotlin/Native_ take a look at the attached samples. + + * `csvparser` - simple CSV file parser and analyzer + * `gitchurn` - program interoperating with `libgit2` for GIT repository analysis + * `libcurl` - using of FTP/HTTP/HTTPS client library `libcurl` + * `opengl` - OpenGL/GLUT teapot example + * `socket` - TCP/IP echo server + * `tetris` - Tetris game implementation (using SDL2 for rendering) + + See `README.md` in each sample directory for more information and build instructions. + + _Kotlin/Native_ could be used either as standalone compiler toolchain or as Gradle +plugin. See `GRADLE_PLUGIN.md` for more details on how to use this plugin. + +Compile your programs like that: + + export PATH=kotlin-native--/bin:$PATH + kotlinc hello.kt -o hello + +For an optimized compilation use -opt: + + kotlinc hello.kt -o hello -opt + +To generate interoperability stubs create library definition file +(take a look on `samples/tetris/tetris.sdl`) and run `cinterop` tool like this: + + cinterop -def lib.def + +See `INTEROP.md` for more information on how to use C libraries from _Kotlin/Native_. + +See `RELEASE_NOTES.md` for information on supported platforms and current limitations. \ No newline at end of file diff --git a/FAQ.md b/FAQ.md index 92dd01a0610..142ba164e12 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,4 +1,10 @@ Q: How do I run my program? A: Define top level function `fun main(args: Array)`, please ensure it's not -in a package. \ No newline at end of file +in a package. + +Q: How do I create shared library? + +A: It is not possible at the moment. Currently Kotlin/Native could be used to produce either +_Kotlin/Native_ own library format, which can be statically linked with application or +or an executable for target. \ No newline at end of file diff --git a/GRADLE_PLUGIN.md b/GRADLE_PLUGIN.md index 1593477c777..c85b708fdfa 100644 --- a/GRADLE_PLUGIN.md +++ b/GRADLE_PLUGIN.md @@ -1,7 +1,7 @@ # Kotlin/Native Gradle plugin #### Overview -You may use the Gradle plugin to build Kotlin/Native projects. To use it you need to include the following snippet in +You may use the Gradle plugin to build _Kotlin/Native_ projects. To use it you need to include the following snippet in a build script (see projects in `samples` directory): buildscript { diff --git a/build.gradle b/build.gradle index 1a6c8b24da1..588ff7ed0ca 100644 --- a/build.gradle +++ b/build.gradle @@ -283,9 +283,15 @@ task bundle(type: Tar) { exclude 'dependencies' into baseName } + from(project.rootDir) { + include 'DISTRO_README.md' + rename { + return "README.md" + } + into baseName + } from(project.rootDir) { include 'samples/**' - include 'README.md' include 'INTEROP.md' include 'RELEASE_NOTES.md' include 'GRADLE_PLUGIN.md' diff --git a/samples/tetris/Tetris.kt b/samples/tetris/Tetris.kt index 8941c3d5db4..4b29184e3a2 100644 --- a/samples/tetris/Tetris.kt +++ b/samples/tetris/Tetris.kt @@ -459,9 +459,6 @@ class Game(width: Int, height: Int, val visualizer: GameFieldVisualizer, val use private val LOCK_DELAY = 1 private fun mainLoop() { - var prevCmd: UserCommand? = null - var das = false - var dasTicks = 0 var attemptsToLock = 0 while (!gameOver) { sleep(1000 / 60) // Refresh rate - 60 frames per second. @@ -635,7 +632,7 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User fieldWidth = width * (CELL_SIZE + MARGIN) + MARGIN + BORDER_WIDTH * 2 fieldHeight = height * (CELL_SIZE + MARGIN) + MARGIN + BORDER_WIDTH * 2 var windowWidth = fieldWidth + INFO_SPACE_WIDTH - var windowHeight = 0 + var windowHeight: Int if (platform == "iOS") { val gamePadHeight = (displayHeight * windowWidth - fieldHeight * displayWidth) / displayWidth windowHeight = fieldHeight + gamePadHeight diff --git a/samples/tetris/build.gradle b/samples/tetris/build.gradle index 00731c8a6bf..1fc653f4c94 100644 --- a/samples/tetris/build.gradle +++ b/samples/tetris/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'konan' konanInterop { sdlMacbook { defFile 'sdl.def' - includeDirs '/Library/Frameworks/SDL2.framework/Headers', '/opt/local/include/SDL2', '/usr/local/include/SDL2', "${System.getProperty("user.home")}/Library/Frameworks/SDL2.framework/Headers" + includeDirs '/Library/Frameworks/SDL2.framework/Headers', "${System.getProperty("user.home")}/Library/Frameworks/SDL2.framework/Headers" target 'macbook' } @@ -44,7 +44,7 @@ konanArtifacts { TetrisMacbook { inputFiles project.file('Tetris.kt') useInterop 'sdlMacbook' - linkerOpts "-F ${System.getProperty("user.home")}/Library/Frameworks -F /Library/Frameworks -framework SDL2 -L/usr/local/lib -L/opt/local/lib -lSDL2" + linkerOpts "-F ${System.getProperty("user.home")}/Library/Frameworks -F /Library/Frameworks -framework SDL2" // 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'