Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove WASM support #153

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ include(cmake/util.cmake)
cerlib_log("Looking for Python")
find_package(Python3 COMPONENTS Interpreter REQUIRED)

if (EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif ()

include(cmake/CPM.cmake)
include(CheckIPOSupported)

Expand Down
65 changes: 0 additions & 65 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@
"CPM_SOURCE_CACHE": "${sourceDir}/build/cpm_source_cache"
}
},
{
"name": "wasm-base",
"hidden": true,
"inherits": "default",
"generator": "Ninja",
"toolchainFile": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"cacheVariables": {
"CERLIB_ENABLE_CLANG_TIDY": "OFF"
}
},
{
"name": "dev",
"inherits": "default",
Expand All @@ -49,20 +39,6 @@
"CERLIB_ENABLE_CLANG_TIDY": "ON"
}
},
{
"name": "wasm",
"inherits": "wasm-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "wasm-debug",
"inherits": "wasm-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "android",
"inherits": "release",
Expand Down Expand Up @@ -107,21 +83,6 @@
"name": "release",
"inherits": "build-base",
"configurePreset": "release"
},
{
"name": "wasm",
"inherits": "build-base",
"configurePreset": "wasm"
},
{
"name": "wasm-debug",
"inherits": "build-base",
"configurePreset": "wasm-debug"
},
{
"name": "android",
"inherits": "build-base",
"configurePreset": "android"
}
],
"workflowPresets": [
Expand Down Expand Up @@ -164,32 +125,6 @@
}
]
},
{
"name": "wasm",
"steps": [
{
"type": "configure",
"name": "wasm"
},
{
"type": "build",
"name": "wasm"
}
]
},
{
"name": "wasm-debug",
"steps": [
{
"type": "configure",
"name": "wasm-debug"
},
{
"type": "build",
"name": "wasm-debug"
}
]
},
{
"name": "android",
"steps": [
Expand Down
135 changes: 67 additions & 68 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,81 +19,80 @@ if (CERLIB_ENABLE_ENTT)
)
endif()

if (NOT EMSCRIPTEN)
set(sdl_version "3.1.3")
set(build_static_sdl ON)
set(build_shared_sdl OFF)
# SDL
set(sdl_version "3.1.3")
set(build_static_sdl ON)
set(build_shared_sdl OFF)

if (ANDROID)
set(build_shared_sdl ON)
set(build_static_sdl OFF)
endif()
if (ANDROID)
set(build_shared_sdl ON)
set(build_static_sdl OFF)
endif()

set(enable_opengles OFF)
set(enable_opengles OFF)

if (ANDROID OR EMSCRIPTEN)
set(enable_opengles ON)
endif()
if (ANDROID)
set(enable_opengles ON)
endif()

CPMAddPackage(
NAME SDL
GITHUB_REPOSITORY libsdl-org/SDL
GIT_TAG preview-3.1.3
OPTIONS
"SDL_MISC OFF"
"SDL_OFFSCREEN OFF"
"SDL_POWER OFF"
"SDL_TEST OFF"
"SDL_TESTS OFF"
"SDL_TEST_LIBRARY OFF"
"SDL_TEST_ENABLED_BY_DEFAULT OFF"
"SDL_VULKAN OFF"
"SDL_OPENGL ON"
"SDL_OPENGLES ${enable_opengles}"
"SDL_RENDER OFF"
"SDL_RENDER_D3D OFF"
"SDL_RENDER_METAL OFF"
"SDL_DIRECTX OFF"
"SDL_DISABLE_INSTALL ON"
"SDL_DISABLE_UNINSTALL ON"
"SDL_VENDOR_INFO OFF"
"SDL_3DNOW OFF"
"SDL_ALTIVEC OFF"
"SDL_CCACHE ON"
"SDL_DUMMYVIDEO OFF"
"SDL_WASAPI OFF"
"SDL_ATOMIC OFF"
"SDL_DIALOG OFF"
"SDL_LIBUDEV OFF"
"SDL_STATIC_VCRT ON"
"SDL_ASSERTIONS disabled"
"SDL_CAMERA OFF"
"SDL_STATIC ${build_static_sdl}"
"SDL_SHARED ${build_shared_sdl}"
"SDL_GPU OFF"
GIT_SHALLOW
SYSTEM
)
CPMAddPackage(
NAME SDL
GITHUB_REPOSITORY libsdl-org/SDL
GIT_TAG preview-3.1.3
OPTIONS
"SDL_MISC OFF"
"SDL_OFFSCREEN OFF"
"SDL_POWER OFF"
"SDL_TEST OFF"
"SDL_TESTS OFF"
"SDL_TEST_LIBRARY OFF"
"SDL_TEST_ENABLED_BY_DEFAULT OFF"
"SDL_VULKAN OFF"
"SDL_OPENGL ON"
"SDL_OPENGLES ${enable_opengles}"
"SDL_RENDER OFF"
"SDL_RENDER_D3D OFF"
"SDL_RENDER_METAL OFF"
"SDL_DIRECTX OFF"
"SDL_DISABLE_INSTALL ON"
"SDL_DISABLE_UNINSTALL ON"
"SDL_VENDOR_INFO OFF"
"SDL_3DNOW OFF"
"SDL_ALTIVEC OFF"
"SDL_CCACHE ON"
"SDL_DUMMYVIDEO OFF"
"SDL_WASAPI OFF"
"SDL_ATOMIC OFF"
"SDL_DIALOG OFF"
"SDL_LIBUDEV OFF"
"SDL_STATIC_VCRT ON"
"SDL_ASSERTIONS disabled"
"SDL_CAMERA OFF"
"SDL_STATIC ${build_static_sdl}"
"SDL_SHARED ${build_shared_sdl}"
"SDL_GPU OFF"
GIT_SHALLOW
SYSTEM
)

if (TARGET SDL3-shared)
set_target_properties(SDL3-shared PROPERTIES FOLDER "cerlib")
endif()
if (TARGET SDL3-shared)
set_target_properties(SDL3-shared PROPERTIES FOLDER "cerlib")
endif()

if (TARGET SDL3-static)
set_target_properties(SDL3-static PROPERTIES FOLDER "cerlib")
endif()
if (TARGET SDL3-static)
set_target_properties(SDL3-static PROPERTIES FOLDER "cerlib")
endif()

if (TARGET SDL_uclibc)
set_target_properties(SDL_uclibc PROPERTIES FOLDER "cerlib")
endif ()
if (TARGET SDL_uclibc)
set_target_properties(SDL_uclibc PROPERTIES FOLDER "cerlib")
endif ()

if (MSVC)
if (TARGET SDL3-shared)
set_property(TARGET SDL3-shared PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if (MSVC)
if (TARGET SDL3-shared)
set_property(TARGET SDL3-shared PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

if (TARGET SDL3-static)
set_property(TARGET SDL3-static PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if (TARGET SDL3-static)
set_property(TARGET SDL3-static PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif ()
endif()
30 changes: 1 addition & 29 deletions cmake/support/cerlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ function(cerlib_add_game)
message(STATUS " AssetsDirectory: ${assets_dir}")
endif ()

if (EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif ()

if (ANDROID)
add_library(${target_name} SHARED)
else ()
Expand All @@ -53,30 +49,6 @@ function(cerlib_add_game)

target_link_libraries(${target_name} PRIVATE cerlib)

if (EMSCRIPTEN)
target_compile_options(${target_name} PRIVATE -Wno-unused-command-line-argument)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(link_flags
"SHELL:-s ALLOW_MEMORY_GROWTH"
"SHELL:-s ASSERTIONS"
"SHELL:-s NO_DISABLE_EXCEPTION_CATCHING"
"SHELL:-s LZ4"
"SHELL:-s GL_ENABLE_GET_PROC_ADDRESS"
"SHELL:--preload-file ${assets_dir}@"
)
else ()
set(link_flags
"SHELL:-s ALLOW_MEMORY_GROWTH"
"SHELL:-s LZ4"
"SHELL:-s GL_ENABLE_GET_PROC_ADDRESS"
"SHELL:--preload-file ${assets_dir}@"
)
endif ()

target_link_options(${target_name} PRIVATE ${link_flags})
endif ()

get_target_property(target_type cerlib TYPE)

if (target_type STREQUAL "SHARED_LIBRARY")
Expand Down Expand Up @@ -158,7 +130,7 @@ function(cerlib_add_game)
)
endif ()

if (NOT EMSCRIPTEN AND cerlib_FOUND)
if (cerlib_FOUND)
add_custom_command(
TARGET ${target_name}
POST_BUILD
Expand Down
31 changes: 0 additions & 31 deletions include/cerlib/Game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#include <cerlib/details/ObjectMacros.hpp>
#include <functional>

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif

namespace cer
{
class Window;
Expand Down Expand Up @@ -161,32 +157,10 @@ class Game final
template <typename Action>
void run(const Action& action)
{
#ifdef __EMSCRIPTEN__
struct State
{
Game& game;
const Action& action;
};

auto s = State{
.game = *this,
.action = action,
};

const auto callback = [](void* user_param) {
const auto& state = *static_cast<const State*>(user_param);
state.game.tick();
state.action();
state.game.endFrame();
};

emscripten_set_main_loop_arg(callback, &s, 0, 1);
#else
while (tick())
{
action();
}
#endif
}

template <typename... Handler>
Expand All @@ -197,10 +171,5 @@ class Game final
std::visit(util::VariantSwitch{std::forward<Handler>(handlers)...}, event);
}
}

#ifdef __EMSCRIPTEN__
private:
void endFrame();
#endif
};
} // namespace cer
3 changes: 0 additions & 3 deletions include/cerlib/Main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@
#endif
#endif

#ifdef __EMSCRIPTEN__
#define SDL_PLATFORM_EMSCRIPTEN 1
#endif
#ifdef __NetBSD__
#define SDL_PLATFORM_NETBSD 1
#endif
Expand Down
4 changes: 0 additions & 4 deletions misc/mygame/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ project(
LANGUAGES CXX
)

if (EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif ()

set(company_name %%COMPANY_SHORT_NAME%%)

# Set up build directories for Android.
Expand Down
Loading