Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
|
|
|
include(PlatformGlob)
|
|
|
|
|
2021-09-11 19:02:46 +00:00
|
|
|
include_directories("${PROJECT_SOURCE_DIR}"
|
2021-09-15 22:46:38 +00:00
|
|
|
"${PROJECT_SOURCE_DIR}/thirdparty/loguru/"
|
2023-01-08 21:27:13 +00:00
|
|
|
)
|
2020-02-03 13:36:30 +00:00
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
platform_glob(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/adb/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/i2c/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/ata/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/pci/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/scsi/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/ethernet/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/floppy/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/ioctrl/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/memctrl/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/serial/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/sound/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/storage/*.cpp"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/video/*.cpp"
|
2023-06-15 04:37:21 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/adb/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/firewire/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/i2c/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/ata/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/pci/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/scsi/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/usb/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/ethernet/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/floppy/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/ioctrl/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/memctrl/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/serial/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/sound/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/storage/*.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/video/*.h"
|
2021-10-23 18:17:47 +00:00
|
|
|
)
|
2020-02-03 13:36:30 +00:00
|
|
|
|
|
|
|
add_library(devices OBJECT ${SOURCES})
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
if (EMSCRIPTEN)
|
|
|
|
target_link_libraries(devices PRIVATE)
|
|
|
|
else()
|
|
|
|
target_link_libraries(devices PRIVATE cubeb SDL2::SDL2)
|
|
|
|
endif()
|