Skip to content

Commit

Permalink
#1269: fixed mingw console app
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed Dec 16, 2020
1 parent 1aad283 commit a24bd33
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ if(BUILD_SDL AND BUILD_PLAYER AND NOT RPI)

if(MINGW)
target_link_libraries(player-sdl mingw32)
target_link_options(player-sdl PRIVATE -static)
endif()

target_link_libraries(player-sdl tic80core SDL2-static SDL2main)
Expand Down Expand Up @@ -399,6 +400,7 @@ if(BUILD_PLAYER AND BUILD_SOKOL)

if(MINGW)
target_link_libraries(player-sokol mingw32)
target_link_options(player-sokol PRIVATE -static)
endif()

target_include_directories(player-sokol PRIVATE
Expand Down Expand Up @@ -677,10 +679,6 @@ endif()

endif()

if(MINGW)
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()

################################
# CURL
################################
Expand Down Expand Up @@ -756,6 +754,7 @@ if(BUILD_SDL)

if(MINGW)
target_link_libraries(tic80 mingw32)
target_link_options(tic80 PRIVATE -static -mconsole)
endif()

if(EMSCRIPTEN)
Expand Down Expand Up @@ -833,6 +832,7 @@ if(BUILD_SOKOL)

if(MINGW)
target_link_libraries(tic80-sokol mingw32)
target_link_options(tic80-sokol PRIVATE -static -mconsole)
endif()

target_link_libraries(tic80-sokol tic80studio sokol net)
Expand Down
7 changes: 5 additions & 2 deletions src/system/sdl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1761,8 +1761,11 @@ static s32 emsStart(s32 argc, char **argv, const char* folder)
s32 main(s32 argc, char **argv)
{
#if defined(__TIC_WINDOWS__)
if (argc == 1)
FreeConsole();
{
CONSOLE_SCREEN_BUFFER_INFO info;
if(GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info) && !info.dwCursorPosition.X && !info.dwCursorPosition.Y)
FreeConsole();
}
#endif

const char* folder = getAppFolder();
Expand Down
12 changes: 12 additions & 0 deletions src/system/sokol/sokol.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "system/sokol/sokol.h"
#include "net/net.h"

#if defined(__TIC_WINDOWS__)
#include <windows.h>
#endif

static struct
{
Studio* studio;
Expand Down Expand Up @@ -419,6 +423,14 @@ static void app_cleanup(void)

sapp_desc sokol_main(s32 argc, char* argv[])
{
#if defined(__TIC_WINDOWS__)
{
CONSOLE_SCREEN_BUFFER_INFO info;
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info) && !info.dwCursorPosition.X && !info.dwCursorPosition.Y)
FreeConsole();
}
#endif

memset(&platform, 0, sizeof platform);

platform.audio.desc.num_channels = TIC_STEREO_CHANNELS;
Expand Down

0 comments on commit a24bd33

Please sign in to comment.