Implement resource packaging for web builds
All checks were successful
Run tests / Run tests (push) Successful in 8m28s
All checks were successful
Run tests / Run tests (push) Successful in 8m28s
This commit is contained in:
parent
ce019229bb
commit
b989eba66d
2 changed files with 14 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
#include <psemek/app/application.hpp>
|
#include <psemek/app/application.hpp>
|
||||||
|
#include <psemek/app/resource.hpp>
|
||||||
#include <psemek/gfx/init.hpp>
|
#include <psemek/gfx/init.hpp>
|
||||||
#include <psemek/sdl2/init.hpp>
|
#include <psemek/sdl2/init.hpp>
|
||||||
#include <psemek/sdl2/window.hpp>
|
#include <psemek/sdl2/window.hpp>
|
||||||
|
|
@ -50,6 +51,12 @@ int main(int argc, char ** argv) try
|
||||||
log::add_sink(log::default_sink(std::move(synchronized_stdout_stderr[1]), log::level::warning, log::level::error));
|
log::add_sink(log::default_sink(std::move(synchronized_stdout_stderr[1]), log::level::warning, log::level::error));
|
||||||
log::register_thread("main");
|
log::register_thread("main");
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
// In web builds, resources are in the root of
|
||||||
|
// the Emscripten virtual filesystem
|
||||||
|
app::set_resource_root("/");
|
||||||
|
#endif
|
||||||
|
|
||||||
auto const factory = app::make_application_factory();
|
auto const factory = app::make_application_factory();
|
||||||
auto const options = factory->options();
|
auto const options = factory->options();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ function(psemek_add_executable_impl target is_application)
|
||||||
|
|
||||||
list(APPEND _TARGET_RUNTIME ${_TARGET_NOEXT}.js)
|
list(APPEND _TARGET_RUNTIME ${_TARGET_NOEXT}.js)
|
||||||
list(APPEND _TARGET_RUNTIME ${_TARGET_NOEXT}.wasm)
|
list(APPEND _TARGET_RUNTIME ${_TARGET_NOEXT}.wasm)
|
||||||
|
list(APPEND _TARGET_RUNTIME ${_TARGET_NOEXT}.data)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(_COPY_FILES ${_TARGET_FILE} ${_TARGET_RUNTIME} ${PSEMEK_PACKAGE_COPY_FILES})
|
set(_COPY_FILES ${_TARGET_FILE} ${_TARGET_RUNTIME} ${PSEMEK_PACKAGE_COPY_FILES})
|
||||||
|
|
@ -228,6 +229,12 @@ function(psemek_package_files target)
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||||
COMMAND ${PSEMEK_COPY_FILES} ${ARGN}
|
COMMAND ${PSEMEK_COPY_FILES} ${ARGN}
|
||||||
)
|
)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||||
|
foreach(_FILE IN LISTS ARGN)
|
||||||
|
target_link_options(${target} PRIVATE
|
||||||
|
"--preload-file=${CMAKE_CURRENT_LIST_DIR}/${_FILE}@/${_FILE}"
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
else()
|
else()
|
||||||
psemek_package_output_path(${target} _OUTPUT_PATH)
|
psemek_package_output_path(${target} _OUTPUT_PATH)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue