emscripten: add emscripten platform support (#720)
This commit is contained in:
parent
e37cbb89a5
commit
4a57df3a45
4 changed files with 25 additions and 9 deletions
|
|
@ -41,7 +41,11 @@ set(YAPB_SRC
|
|||
"src/vistable.cpp"
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED ${YAPB_SRC})
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
|
||||
add_executable(${PROJECT_NAME} ${YAPB_SRC})
|
||||
else ()
|
||||
add_library(${PROJECT_NAME} SHARED ${YAPB_SRC})
|
||||
endif ()
|
||||
find_package(Git QUIET)
|
||||
|
||||
if(GIT_FOUND)
|
||||
|
|
@ -66,11 +70,19 @@ endif()
|
|||
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND NOT MSVC)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -DCR_NATIVE_BUILD -flto=auto -fno-exceptions -fno-rtti -fno-threadsafe-statics -pthread)
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten")
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -march=armv8-a+fp+simd)
|
||||
elseif(BUILD_X86)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -mmmx -msse -msse2 -msse3 -mfpmath=sse)
|
||||
endif()
|
||||
else ()
|
||||
#target_compile_options(${PROJECT_NAME} PRIVATE -msse -msse2 -msse3 -msimd128 -fPIC)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE CR_DISABLE_SIMD)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -fPIC -fvisibility=hidden)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE -sSIDE_MODULE=1)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".wasm")
|
||||
endif ()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -funroll-loops -fomit-frame-pointer -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden -fno-math-errno)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 43f0acc90e9042efb8e9f7287bfa6935a0f4bc90
|
||||
Subproject commit 89cfcf74cc870844d6e5029c296f6c4a6b2b6070
|
||||
|
|
@ -867,6 +867,10 @@ bool Game::loadCSBinary () {
|
|||
}
|
||||
}
|
||||
|
||||
if (plat.emscripten) {
|
||||
path = String(plat.env ("XASH3D_GAMELIBPATH")); // defined by launcher
|
||||
}
|
||||
|
||||
if (path.empty()) {
|
||||
path = strings.joinPath (modname, "dlls", lib) + kLibrarySuffix;
|
||||
|
||||
|
|
@ -1003,7 +1007,7 @@ bool Game::postload () {
|
|||
// register engine lib handle
|
||||
m_engineLib.locate (reinterpret_cast <void *> (engfuncs.pfnPrecacheModel));
|
||||
|
||||
if (plat.android) {
|
||||
if (plat.android || plat.emscripten) {
|
||||
m_gameFlags |= (GameFlags::Xash3D | GameFlags::Mobility | GameFlags::HasBotVoice | GameFlags::ReGameDLL);
|
||||
|
||||
if (is (GameFlags::Metamod)) {
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ StringRef BotStorage::getRunningPath () {
|
|||
static String path {};
|
||||
|
||||
// we're do not do relative (against bot's library) paths on android
|
||||
if (plat.android) {
|
||||
if (plat.android || plat.emscripten) {
|
||||
if (path.empty ()) {
|
||||
path = strings.joinPath (game.getRunningModName (), folders.addons, folders.bot);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue