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

Resources: Bundle resources for preloading when targeting Emscripten/WASM #12922

Merged
merged 2 commits into from
Mar 5, 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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,14 @@ if (APPLE)
endif()
endif()

if(EMSCRIPTEN)
# Package resources for the web using preloading.
# This will generate a mixxx.data file containing all the resources.
# See https://emscripten.org/docs/porting/files/packaging_files.html
# TODO: Strip this down by only including what we need (i.e. no macOS/Linux packaging, ...)
target_link_options(mixxx-lib PUBLIC --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/res@/res")
endif()

if(WIN32)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${MIXXX_INSTALL_BINDIR}")
if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug")
Expand Down
7 changes: 7 additions & 0 deletions src/preferences/configobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ QString computeResourcePathImpl() {
QString qResourcePath = CmdlineArgs::Instance().getResourcePath();

if (qResourcePath.isEmpty()) {
#ifdef __EMSCRIPTEN__
// When targeting Emscripten/WebAssembly, we have a virtual file system
// that is populated by our preloaded resources located at /res. See
// also https://emscripten.org/docs/porting/files/packaging_files.html
qResourcePath = "/res";
#else
QDir mixxxDir = QCoreApplication::applicationDirPath();

// We used to support using the mixxx.cfg's [Config],Path setting but
Expand Down Expand Up @@ -76,6 +82,7 @@ QString computeResourcePathImpl() {
// TODO(rryan): What should we do here?
}
#endif
#endif // !defined(__EMSCRIPTEN__)
} else {
//qDebug() << "Setting qResourcePath from location in resourcePath commandline arg:" << qResourcePath;
}
Expand Down
Loading