Files
kotlin-fork/samples/tetris/build.gradle
T
2018-08-31 15:31:14 +07:00

86 lines
2.6 KiB
Groovy

apply plugin: 'org.jetbrains.kotlin.platform.native'
def konanUserDir = System.getenv("KONAN_DATA_DIR") ?: "${System.getProperty("user.home")}/.konan"
def resFile = file("$buildDir/konan/res/Tetris.res")
components.main {
targets = ['macos_x64', 'linux_x64', 'raspberrypi', 'mingw_x64']
outputKinds = [EXECUTABLE]
baseName = 'tetris'
target 'macbook', {
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 'linux', {
linkerOpts '-L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lSDL2'
}
target 'raspberrypi', {
linkerOpts '-lSDL2'
}
target 'mingw', {
linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -Wl,-Bstatic -lstdc++ -static -lSDL2 -limm32 -lole32 -loleaut32 -lversion -lwinmm -mwindows"
}
dependencies {
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 'linux_x64', {
includeDirs '/usr/include/SDL2'
}
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
}
}
}
}
task windowsResources (type: Exec) {
def rcFile = file('Tetris.rc')
def path = System.getenv("PATH")
def windresDir = "$konanUserDir/dependencies/msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1/bin"
commandLine "$windresDir/windres", rcFile, '-O', 'coff', '-o', resFile
environment 'PATH', "$windresDir;$path"
inputs.file rcFile
outputs.file resFile
}
project.tasks.matching {
name == 'compileDebugMingw_x64KotlinNative' ||
name == 'compileReleaseMingw_x64KotlinNative'
}.all {
dependsOn 'windowsResources'
inputs.file resFile
}