mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 21:39:57 +00:00
Emscriptein port
This commit is contained in:
parent
1160d21769
commit
db037c6b31
5 changed files with 52 additions and 86 deletions
104
CMakeLists.txt
104
CMakeLists.txt
|
|
@ -5,9 +5,7 @@ include(FindPackageHandleStandardArgs)
|
|||
# Options
|
||||
option(STEAM "Build for Steam" OFF)
|
||||
option(DEBUG "Debug mode" OFF)
|
||||
option(FORCE32 "Force 32bit compile on 64bit OS" OFF) # from MKXP
|
||||
option(NATIVE "Use native instructions(for local use only)" OFF)
|
||||
option(EXTRA_SECURITY "Extra security" OFF)
|
||||
|
||||
set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE)
|
||||
set(VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION "5.1.2600.0")
|
||||
|
|
@ -16,53 +14,38 @@ set(ZLIB_USE_STATIC_LIBS ON)
|
|||
set(OPENSSL_USE_STATIC_LIBS ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# from MKXP
|
||||
if(FORCE32)
|
||||
if(APPLE)
|
||||
set(CMAKE_OSX_ARCHITECTURES "i386")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NATIVE)
|
||||
if (MSVC)
|
||||
#TODO
|
||||
add_compile_options()
|
||||
else()
|
||||
if (!MSVC)
|
||||
add_compile_options(-march=native -mtune=native)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEBUG)
|
||||
# Debug stuff
|
||||
if (MSVC)
|
||||
add_compile_options(/EHr /fsanitize /validate-charset /DEBUG /RTCu /RTCs /RTCc)
|
||||
else()
|
||||
add_compile_options(-g3 -O0 -fno-omit-frame-pointer -ggdb -fcheck-new -gbtf)
|
||||
endif()
|
||||
else()
|
||||
# Optimization stuff
|
||||
if (MSVC)
|
||||
add_compile_options(/O2 /fp:fast /GL /GF /GA)
|
||||
else()
|
||||
#bruh....
|
||||
add_compile_options(-Ofast -funroll-loops -fipa-pta -ftree-vectorize -fstdarg-opt -fomit-frame-pointer -frename-registers)
|
||||
if(!WIN32)
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
add_link_options(-Wl,-O2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(EXTRA_SECURITY)
|
||||
if (MSVC)
|
||||
add_compile_options(/guard:cf /GS /sdl /DYNAMICBASE /HIGHENTROPYVA /SAFESEH /guard:ehcont)
|
||||
else()
|
||||
add_compile_options(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -fstrict-flex-arrays=3 -fstack-clash-protection -fstack-protector-strong -Wl,--no-copy-dt-needed-entries -fPIE -pie)
|
||||
endif()
|
||||
#https://github.com/Ravbug/sdl3-sample/blob/main/CMakeLists.txt
|
||||
if ((APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") OR EMSCRIPTEN)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "") # Disable shared builds on platforms where it does not make sense to use them
|
||||
set(SDL_SHARED OFF)
|
||||
else()
|
||||
set(SDL_SHARED ON)
|
||||
endif()
|
||||
|
||||
## Setup main source ##
|
||||
|
||||
# main stuff
|
||||
set(MAIN_HEADERS
|
||||
src/quadarray.h
|
||||
|
|
@ -188,14 +171,17 @@ elseif(LINUX)
|
|||
list(APPEND MAIN_SOURCE src/xdg-user-dir-lookup.c)
|
||||
list(APPEND MAIN_HEADERS src/xdg-user-dir-lookup.h)
|
||||
elseif(BSD)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LINUXPKGS REQUIRED gtk+-3.0 libxfconf-0)
|
||||
include_directories(${LINUXPKGS_INCLUDE_DIRS})
|
||||
add_compile_options(${LINUXPKGS_CFLAGS_OTHER})
|
||||
list(APPEND PLATFORM_LIBRARIES ${LINUXPKGS_LDFLAGS})
|
||||
list(APPEND MAIN_SOURCE src/xdg-user-dir-lookup.c)
|
||||
list(APPEND MAIN_HEADERS src/xdg-user-dir-lookup.h)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LINUXPKGS REQUIRED gtk+-3.0 libxfconf-0)
|
||||
include_directories(${LINUXPKGS_INCLUDE_DIRS})
|
||||
add_compile_options(${LINUXPKGS_CFLAGS_OTHER})
|
||||
list(APPEND PLATFORM_LIBRARIES ${LINUXPKGS_LDFLAGS})
|
||||
list(APPEND MAIN_SOURCE src/xdg-user-dir-lookup.c)
|
||||
list(APPEND MAIN_HEADERS src/xdg-user-dir-lookup.h)
|
||||
set(STEAM OFF)
|
||||
elseif(EMSCRIPTEN)
|
||||
set(STEAM OFF)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if (STEAM)
|
||||
|
|
@ -363,48 +349,36 @@ find_package(SDL3_ttf CONFIG)
|
|||
find_package(OpenAL CONFIG)
|
||||
find_package(Boost REQUIRED COMPONENTS program_options chrono)
|
||||
find_package(PhysFS CONFIG)
|
||||
find_package(OpenSSL CONFIG REQUIRED COMPONENTS Crypto)
|
||||
find_path(PIXMAN_INCLUDE_DIR NAMES pixman.h PATH_SUFFIXES pixman-1)
|
||||
find_library(PIXMAN_LIBRARY NAMES pixman-1 pixman-1_static pixman-1_staticd)
|
||||
find_package(Ruby 3.0 REQUIRED COMPONENTS Development)
|
||||
pkg_check_modules(SIGC2 REQUIRED sigc++-2.0)
|
||||
pkg_check_modules(VORBISFILE REQUIRED vorbisfile)
|
||||
find_package_handle_standard_args(pixman-1 DEFAULT_MSG PIXMAN_LIBRARY PIXMAN_INCLUDE_DIR)
|
||||
mark_as_advanced(PIXMAN_INCLUDE_DIR PIXMAN_LIBRARY)
|
||||
pkg_check_modules(LIBZIP REQUIRED libzip)
|
||||
|
||||
if(!EMSCRIPTEN)
|
||||
find_package(OpenSSL CONFIG REQUIRED COMPONENTS Crypto)
|
||||
pkg_check_modules(SIGC2 REQUIRED sigc++-2.0)
|
||||
pkg_check_modules(LIBZIP REQUIRED libzip)
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${DEFINES})
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
src
|
||||
include
|
||||
${LIBZIP_INCLUDE_DIRS}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${PIXMAN_INCLUDE_DIR}
|
||||
${SIGC2_INCLUDE_DIRS}
|
||||
${Ruby_INCLUDE_DIRS}
|
||||
Boost::boost ${Boost_INCLUDE_DIRS}
|
||||
${VORBISFILE_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIRS})
|
||||
if(!EMSCRIPTEN)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE src include ${PIXMAN_INCLUDE_DIR}
|
||||
${Ruby_INCLUDE_DIRS} Boost::boost ${Boost_INCLUDE_DIRS} ${VORBISFILE_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
SDL3::SDL3 SDL3_image::SDL3_image SDL3_sound::SDL3_sound SDL3_ttf::SDL3_ttf
|
||||
OpenSSL::Crypto
|
||||
OpenAL::OpenAL
|
||||
physfs
|
||||
${LIBZIP_LIBRARIES}
|
||||
${PIXMAN_LIBRARY}
|
||||
${SIGC2_LIBRARIES}
|
||||
${PLATFORM_LIBRARIES}
|
||||
${Ruby_LIBRARIES}
|
||||
Boost::boost Boost::chrono ${Boost_LIBRARIES}
|
||||
${VORBISFILE_LIBRARIES}
|
||||
ZLIB::ZLIB
|
||||
${PLATFORM_LIBS})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3 SDL3_image::SDL3_image SDL3_sound::SDL3_sound SDL3_ttf::SDL3_ttf OpenAL::OpenAL
|
||||
physfs ${PIXMAN_LIBRARY} ${PLATFORM_LIBRARIES} ${Ruby_LIBRARIES} Boost::boost Boost::chrono ${Boost_LIBRARIES}
|
||||
${VORBISFILE_LIBRARIES} ZLIB::ZLIB ${PLATFORM_LIBS})
|
||||
else()
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE src include ${LIBZIP_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${PIXMAN_INCLUDE_DIR} ${SIGC2_INCLUDE_DIRS}
|
||||
${Ruby_INCLUDE_DIRS} Boost::boost ${Boost_INCLUDE_DIRS} ${VORBISFILE_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3 SDL3_image::SDL3_image SDL3_sound::SDL3_sound SDL3_ttf::SDL3_ttf OpenSSL::Crypto OpenAL::OpenAL
|
||||
physfs ${LIBZIP_LIBRARIES} ${PIXMAN_LIBRARY} ${SIGC2_LIBRARIES} ${PLATFORM_LIBRARIES} ${Ruby_LIBRARIES} Boost::boost Boost::chrono ${Boost_LIBRARIES}
|
||||
${VORBISFILE_LIBRARIES} ZLIB::ZLIB ${PLATFORM_LIBS})
|
||||
endif()
|
||||
|
||||
IF(APPLE)
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND cmake -P "${CMAKE_SOURCE_DIR}/patches/mac/CompleteBundle.cmake" VERBATIM)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
Programmers:
|
||||
|
||||
* Issac332
|
||||
* "Визя"
|
||||
* DepressedTWM
|
||||
|
||||
Artists:
|
||||
|
||||
* Issac332
|
||||
* Creature_of_steel1
|
||||
* Dess
|
||||
|
||||
Testers:
|
||||
|
||||
* Rubik
|
||||
* Prime 223432
|
||||
|
||||
|
|
@ -19,6 +16,5 @@ External artists:
|
|||
* "Ргинша"
|
||||
|
||||
Donators:
|
||||
|
||||
* Kodu
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/log.h>
|
||||
#elif __EMSCRIPTEN__
|
||||
#include <emscripten/console.h>
|
||||
#endif
|
||||
|
||||
#include <SDL3/SDL_platform_defines.h>
|
||||
|
||||
/* A cheap replacement for qDebug() */
|
||||
|
||||
class Debug{
|
||||
|
|
@ -58,21 +58,9 @@ public:
|
|||
|
||||
~Debug(){
|
||||
#ifdef __ANDROID__
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "mkxp", buf.str().c_str());
|
||||
#elif SDL_PLATFORM_3DS
|
||||
//TODO
|
||||
#elif SDL_PLATFORM_IOS
|
||||
//TODO
|
||||
#elif SDL_PLATFORM_PS2
|
||||
//TODO
|
||||
#elif SDL_PLATFORM_PSP
|
||||
//TODO
|
||||
#elif SDL_PLATFORM_VITA
|
||||
//TODO
|
||||
#elif SDL_PLATFORM_XBOXONE
|
||||
//TODO
|
||||
#elif SDL_PLATFORM_XBOXSERIES
|
||||
//TODO
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "sunshine", buf.str().c_str());
|
||||
#elif __EMSCRIPTEN__
|
||||
emscripten_console_log(buf.str().c_str());
|
||||
#else
|
||||
std::cerr << buf.str() << std::endl;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -333,6 +333,8 @@ int main(int argc, char *argv[]){
|
|||
* dealing with icons; don't interfere with them */
|
||||
#ifdef __LINUX__
|
||||
setupWindowIcon(conf, win);
|
||||
#elif __EMSCRIPTEN__
|
||||
Debug() << "meow";
|
||||
#else
|
||||
(void) setupWindowIcon;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -94,6 +94,11 @@ std::string sha256_file(const std::string &fn) {
|
|||
return out;
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
std::string ModLoader(Config conf){
|
||||
return "";
|
||||
}
|
||||
#else
|
||||
std::string ModLoader(Config conf){
|
||||
std::string path = conf.Modloader.ModsDirPath;
|
||||
if (!fs::exists(path) || !std::filesystem::is_directory(path)) {
|
||||
|
|
@ -211,3 +216,4 @@ std::string ModLoader(Config conf){
|
|||
crash(Exception::ModLoaderError, "Something is wrong, Exception: %s ", e.what());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue