Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Igotti committed Apr 3, 2017
1 parent a553768 commit ac37d95
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 9 deletions.
41 changes: 41 additions & 0 deletions DISTRO_README.md
Original file line number Diff line number Diff line change
@@ -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-<platform>-<version>/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.
8 changes: 7 additions & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Q: How do I run my program?

A: Define top level function `fun main(args: Array<String>)`, please ensure it's not
in a package.
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.
2 changes: 1 addition & 1 deletion GRADLE_PLUGIN.md
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 1 addition & 4 deletions samples/tetris/Tetris.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions samples/tetris/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit ac37d95

Please sign in to comment.