Update to emscripten 6 and pre-build sdl2 in web packaging image

This commit is contained in:
Nikita Lisitsa 2026-07-06 22:36:21 +03:00
parent f30da1a2ad
commit 8587ba6bc0
3 changed files with 22 additions and 19 deletions

View file

@ -13,16 +13,17 @@
#include <psemek/util/terminal_color.hpp> #include <psemek/util/terminal_color.hpp>
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#include <emscripten/html5.h> #include <emscripten/html5.h>
#include <emscripten.h> #include <emscripten.h>
#include <emscripten/wasmfs.h>
struct em_state struct em_state
{ {
std::unique_ptr<psemek::app::application> application; std::unique_ptr<psemek::app::application> application;
std::unique_ptr<psemek::sdl2::window> window; std::unique_ptr<psemek::sdl2::window> window;
psemek::app::application::context context; psemek::app::application::context context;
} em_state; } em_state;
#endif #endif
#undef main #undef main
@ -111,19 +112,17 @@ int main(int argc, char ** argv) try
SDL_StopTextInput(); SDL_StopTextInput();
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
emscripten_request_animation_frame_loop([](double, void*) -> EM_BOOL { emscripten_set_main_loop([]{
if (sdl2::poll_events(*em_state.application)) if (sdl2::poll_events(*em_state.application))
em_state.application->stop(); em_state.application->stop();
if (!em_state.application->running()) if (!em_state.application->running())
return EM_FALSE; emscripten_cancel_main_loop();
em_state.application->update(); em_state.application->update();
em_state.application->present(); em_state.application->present();
em_state.window->swap(); em_state.window->swap();
}, 0, 1);
return EM_TRUE;
}, nullptr);
#else #else
while (application->running()) while (application->running())
{ {
@ -134,9 +133,10 @@ int main(int argc, char ** argv) try
application->present(); application->present();
window.swap(); window.swap();
} }
#endif
log::info() << "Quitting"; log::info() << "Quitting";
#endif
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
catch (psemek::util::exception const & e) catch (psemek::util::exception const & e)

View file

@ -2,10 +2,12 @@ FROM lisyarus/psemek:package-linux
# Install emsdk - the version the build was tested at # Install emsdk - the version the build was tested at
WORKDIR /home WORKDIR /home
RUN git clone --branch 3.1.46 https://github.com/emscripten-core/emsdk.git RUN git clone --branch 6.0.2 https://github.com/emscripten-core/emsdk.git
WORKDIR /home/emsdk WORKDIR /home/emsdk
RUN ./emsdk install 3.1.46 RUN ./emsdk install 6.0.2
RUN ./emsdk activate 3.1.46 RUN ./emsdk activate 6.0.2
RUN . ./emsdk_env.sh && embuilder build sdl2 sdl2-mt
WORKDIR /home WORKDIR /home
COPY env-helper.sh . COPY env-helper.sh .
# Source emsdk env variables when running the container # Source emsdk env variables when running the container
@ -13,6 +15,7 @@ ENTRYPOINT ["/home/env-helper.sh"]
# Install Boost sources # Install Boost sources
WORKDIR /home WORKDIR /home
RUN git config --global advice.detachedHead false
RUN git clone --recurse-submodules --branch boost-1.87.0 https://github.com/boostorg/boost.git RUN git clone --recurse-submodules --branch boost-1.87.0 https://github.com/boostorg/boost.git
# Install toolchain file & main packaging script # Install toolchain file & main packaging script

View file

@ -14,7 +14,7 @@ rm -rf ./*
# right toolchain. # right toolchain.
emcmake cmake \ emcmake cmake \
-DBOOST_SOURCE_ROOT=$(realpath ../source)/psemek/3rdparty/boost \ -DBOOST_SOURCE_ROOT=$(realpath ../source)/psemek/3rdparty/boost \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_BUILD_TYPE=Release \
-DPSEMEK_PACKAGE_MODE=ON \ -DPSEMEK_PACKAGE_MODE=ON \
-DPSEMEK_PACKAGE_HOST=OFF \ -DPSEMEK_PACKAGE_HOST=OFF \
-DPSEMEK_PACKAGE_TARGET=ON \ -DPSEMEK_PACKAGE_TARGET=ON \