[emscripten] build recent
This commit is contained in:
parent
d93b5a6293
commit
68dcc8a7e0
|
@ -30,6 +30,23 @@ endif()
|
|||
|
||||
message(STATUS "dethrace version ${DETHRACE_VERSION}")
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Emscripten")
|
||||
set(USE_FLAGS "--use-port=sdl2 --use-port=sdl2_image")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${USE_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${USE_FLAGS} \
|
||||
-Wl,-u,scalbnl \
|
||||
-sASYNCIFY \
|
||||
-sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=256mb -sMEMORY_GROWTH_LINEAR_STEP=128mb \
|
||||
-sSTACK_SIZE=1024kb \
|
||||
-sENVIRONMENT=web \
|
||||
-sMODULARIZE \
|
||||
-sEXPORT_ALL -sEXPORTED_RUNTIME_METHODS=callMain,addRunDependency,removeRunDependency \
|
||||
-sEXIT_RUNTIME \
|
||||
-lwebsocket.js -lidbfs.js -sCASE_INSENSITIVE_FS -sASSERTIONS=2 --profiling-funcs")
|
||||
endif ()
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
set(DETHRACE_IDE_ARGUMENTS "" CACHE STRING "DethRace arguments (only used by MSVC when debugging")
|
||||
|
@ -67,19 +84,23 @@ option(DETHRACE_PLATFORM_SDL2 "Support SDL 2 platform driver" ON)
|
|||
set(count_sdl_platforms 0)
|
||||
|
||||
set(DETHRACE_PLATFORMS )
|
||||
if(DETHRACE_PLATFORM_SDL1)
|
||||
find_package(SDL REQUIRED)
|
||||
list(APPEND DETHRACE_PLATFORMS SDL1)
|
||||
math(EXPR count_sdl_platforms "${count_sdl_platforms} + 1")
|
||||
endif()
|
||||
if(DETHRACE_PLATFORM_SDL2)
|
||||
find_package(SDL2 CONFIG)
|
||||
if(NOT SDL2_FOUND)
|
||||
find_package(SDL2 MODULE REQUIRED)
|
||||
if (NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten")
|
||||
if(DETHRACE_PLATFORM_SDL1)
|
||||
find_package(SDL REQUIRED)
|
||||
list(APPEND DETHRACE_PLATFORMS SDL1)
|
||||
math(EXPR count_sdl_platforms "${count_sdl_platforms} + 1")
|
||||
endif()
|
||||
if(DETHRACE_PLATFORM_SDL2)
|
||||
find_package(SDL2 CONFIG)
|
||||
if(NOT SDL2_FOUND)
|
||||
find_package(SDL2 MODULE REQUIRED)
|
||||
endif()
|
||||
list(APPEND DETHRACE_PLATFORMS SDL2)
|
||||
math(EXPR count_sdl_platforms "${count_sdl_platforms} + 1")
|
||||
endif()
|
||||
else ()
|
||||
list(APPEND DETHRACE_PLATFORMS SDL2)
|
||||
math(EXPR count_sdl_platforms "${count_sdl_platforms} + 1")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if(count_sdl_platforms GREATER 1)
|
||||
# Force dynamic SDL when enabling 2 (or more) SDL platform backends
|
||||
|
|
|
@ -82,7 +82,9 @@ if(DETHRACE_PLATFORM_SDL2)
|
|||
set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/platforms/sdl2.c" APPEND PROPERTY INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:SDL2::SDL2,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
set_property(GLOBAL APPEND PROPERTY DETHRACE_BUILD_RPATHS "$<TARGET_FILE_DIR:SDL2::SDL2>")
|
||||
else()
|
||||
target_link_libraries(harness PRIVATE SDL2::SDL2)
|
||||
if (NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten")
|
||||
target_link_libraries(harness PRIVATE SDL2::SDL2)
|
||||
endif ()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
#include <dirent.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <libgen.h>
|
||||
|
@ -73,6 +75,7 @@ int addr2line(char const* const program_name, void const* const addr) {
|
|||
}
|
||||
|
||||
static void print_stack_trace(void) {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
int i, trace_size = 0;
|
||||
char** messages = (char**)NULL;
|
||||
|
||||
|
@ -91,6 +94,7 @@ static void print_stack_trace(void) {
|
|||
if (messages) {
|
||||
free(messages);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void signal_handler(int sig, siginfo_t* siginfo, void* context) {
|
||||
|
@ -205,10 +209,11 @@ void OS_InstallSignalHandler(char* program_name) {
|
|||
}
|
||||
ss.ss_size = 2 * MINSIGSTKSZ;
|
||||
ss.ss_flags = 0;
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (sigaltstack(&ss, NULL) != 0) {
|
||||
err(1, "sigaltstack");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* register our signal handlers */
|
||||
|
|
|
@ -137,7 +137,9 @@ static void SDL2_Harness_ProcessWindowMessages(void) {
|
|||
}
|
||||
} else if (event.key.type == SDL_KEYUP) {
|
||||
if (is_only_key_modifier(event.key.keysym.mod, KMOD_ALT)) {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
SDL2_SetWindowFullscreen(window, (SDL2_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_DESKTOP) ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +320,9 @@ static void SDL2_Harness_CreateWindow(const char* title, int width, int height,
|
|||
viewport.scale_y = 1;
|
||||
|
||||
if (harness_game_config.start_full_screen) {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
SDL2_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue