Fix Windows resource linking (#633)
This commit is contained in:
+10
-12
@@ -50,6 +50,8 @@ internal abstract class PlatformFlags(val distribution: Distribution) {
|
||||
abstract fun linkCommand(objectFiles: List<ObjectFile>,
|
||||
executable: ExecutableFile, optimize: Boolean): List<String>
|
||||
|
||||
open fun linkCommandSuffix(): List<String> = emptyList()
|
||||
|
||||
protected fun propertyHostString(name: String)
|
||||
= properties.propertyString(name, hostSuffix)!!
|
||||
protected fun propertyHostList(name: String)
|
||||
@@ -133,9 +135,9 @@ internal open class LinuxBasedPlatform(distribution: Distribution)
|
||||
"-L${llvmLib}", "-L${libGcc}") +
|
||||
specificLibs +
|
||||
listOf("-L${targetSysRoot}/../lib", "-L${targetSysRoot}/lib", "-L${targetSysRoot}/usr/lib") +
|
||||
if (optimize) listOf("-plugin", "$llvmLib/LLVMgold.so") + pluginOptimizationFlags else {listOf<String>()} +
|
||||
if (optimize) listOf("-plugin", "$llvmLib/LLVMgold.so") + pluginOptimizationFlags else emptyList<String>() +
|
||||
objectFiles +
|
||||
if (optimize) linkerOptimizationFlags else {listOf<String>()} +
|
||||
if (optimize) linkerOptimizationFlags else emptyList<String>() +
|
||||
linkerKonanFlags +
|
||||
listOf("-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed",
|
||||
"-lc", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed",
|
||||
@@ -154,9 +156,10 @@ internal open class MingwPlatform(distribution: Distribution)
|
||||
override fun linkCommand(objectFiles: List<String>, executable: String, optimize: Boolean): List<String> {
|
||||
return listOf(linker, "-o", executable) +
|
||||
objectFiles +
|
||||
(if (optimize) linkerOptimizationFlags else {listOf<String>()}) +
|
||||
linkerKonanFlags
|
||||
(if (optimize) linkerOptimizationFlags else emptyList())
|
||||
}
|
||||
|
||||
override fun linkCommandSuffix() = linkerKonanFlags
|
||||
}
|
||||
|
||||
internal class LinkStage(val context: Context) {
|
||||
@@ -234,7 +237,8 @@ internal class LinkStage(val context: Context) {
|
||||
val linkCommand = platform.linkCommand(objectFiles, executable, optimize) +
|
||||
distribution.libffi +
|
||||
asLinkerArgs(config.getNotNull(KonanConfigKeys.LINKER_ARGS)) +
|
||||
entryPointSelector
|
||||
entryPointSelector +
|
||||
platform.linkCommandSuffix()
|
||||
|
||||
runTool(*linkCommand.toTypedArray())
|
||||
if (platform is MacOSBasedPlatform && context.shouldContainDebugInfo()) {
|
||||
@@ -278,13 +282,7 @@ internal class LinkStage(val context: Context) {
|
||||
|
||||
val phaser = PhaseManager(context)
|
||||
phaser.phase(KonanPhase.OBJECT_FILES) {
|
||||
objectFiles = if (optimize) {
|
||||
listOf( llvmLto(bitcodeFiles ) )
|
||||
} else {
|
||||
listOf( llvmLto(bitcodeFiles ) )
|
||||
// Or, alternatively, go through llc bitcode compiler.
|
||||
//bitcodeFiles.map{ it -> llvmLlc(it) }
|
||||
}
|
||||
objectFiles = listOf( llvmLto(bitcodeFiles ) )
|
||||
}
|
||||
phaser.phase(KonanPhase.LINKER) {
|
||||
link(objectFiles)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "JetBrains LLC"
|
||||
VALUE "FileDescription", "Tetris Demo Game"
|
||||
VALUE "FileVersion", "1.0"
|
||||
VALUE "InternalName", "Tetris"
|
||||
VALUE "LegalCopyright", "©JetBrains"
|
||||
VALUE "OriginalFilename", "Tetris.exe"
|
||||
VALUE "ProductName", "Tetris for Windows"
|
||||
VALUE "ProductVersion", "1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x809, 1252
|
||||
END
|
||||
END
|
||||
@@ -1,14 +1,19 @@
|
||||
@echo off
|
||||
setlocal
|
||||
set DIR=.
|
||||
set "PATH=..\..\dist\bin;..\..\bin;%PATH%"
|
||||
set "PATH=..\..\dist\bin;..\..\bin;..\..\dist\dependencies\msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64\bin;%PATH%"
|
||||
if "%TARGET%" == "" set TARGET=mingw
|
||||
rem Requires default mingw64 install path yet.
|
||||
set MINGW=\msys64\mingw64
|
||||
|
||||
set CFLAGS=-I\msys64\mingw64\include\SDL2
|
||||
set LFLAGS=-L\msys64\mingw64\lib -lSDL2
|
||||
set "CFLAGS=-I%MINGW%\include\SDL2"
|
||||
rem Add -Wl,--subsystem,windows for making GUI subsystem application.
|
||||
set "LFLAGS=%DIR%\Tetris.res -L%MINGW%\lib -lSDL2"
|
||||
|
||||
call cinterop -def "%DIR%\sdl.def" -compilerOpts "%CFLAGS%" -target "%TARGET%" -o sdl || exit /b
|
||||
rem Windows build requires Windows Resource Compiler in paths.
|
||||
call windres "%DIR%\Tetris.rc" -O coff -o "%DIR%\Tetris.res" || exit /b
|
||||
call konanc -target "%TARGET%" "%DIR%\Tetris.kt" -library sdl -linkerOpts "%LFLAGS%" -opt -o Tetris || exit /b
|
||||
|
||||
copy Tetris.kexe Tetris.exe
|
||||
copy \msys64\mingw64\bin\SDL2.dll SDL2.dll
|
||||
copy %MINGW%\bin\SDL2.dll SDL2.dll
|
||||
|
||||
Reference in New Issue
Block a user