[tetris] Support Windows resources in Gradle build

This commit is contained in:
Ilya Matveev
2018-05-23 16:54:31 +07:00
committed by ilmat192
parent 9b9f0412ce
commit 41ea12a4e7
2 changed files with 18 additions and 2 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
@echo off
setlocal
set DIR=.
if "%KONAN_DATA_DIR%"=="" (set KONAN_DATA_DIR="%HOME%\.konan")
if "%KONAN_DATA_DIR%"=="" (set "KONAN_DATA_DIR=%userprofile%\.konan")
set "PATH=..\..\dist\bin;..\..\bin;%KONAN_DATA_DIR%\dependencies\msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64\bin;%PATH%"
if "%TARGET%" == "" set TARGET=mingw
rem Requires default mingw64 install path yet.
+17 -1
View File
@@ -3,6 +3,7 @@ apply plugin: 'konan'
konan.targets = ['macbook', 'linux', 'raspberrypi', 'mingw']
def konanUserDir = System.getenv("KONAN_DATA_DIR") ?: "${System.getProperty("user.home")}/.konan"
def resFile = file("$buildDir/konan/res/Tetris.res")
konanArtifacts {
@@ -50,11 +51,26 @@ konanArtifacts {
}
target 'mingw', {
linkerOpts "-L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -lSDL2 -mwindows"
linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -lSDL2 -mwindows"
dependsOn 'windowsResources'
inputs.file resFile
}
}
}
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.2.0-clang-llvm-5.0.0-windows-x86-64/bin"
commandLine "$windresDir/windres", rcFile, '-O', 'coff', '-o', resFile
environment 'PATH', "$windresDir;$path"
inputs.file rcFile
outputs.file resFile
}
compileKonan {
doLast {
konanArtifacts.tetris.forEach() { task ->