Skip to content

Commit

Permalink
Add hydra support
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Jan 10, 2024
1 parent e52f292 commit dc5af5a
Show file tree
Hide file tree
Showing 7 changed files with 5,029 additions and 22 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,24 @@ jobs:
name: NanoBoyAdvance-${{ runner.os }}
path: NanoBoyAdvance.dmg
if-no-files-found: error

build-wasm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v10
with:
version: 3.1.50
actions-cache-folder: 'emsdk-cache'
- name: Build
run: |
emcmake cmake -B build -DPLATFORM_HYDRA=ON -DPLATFORM_QT=OFF
cmake --build build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: libNanoBoyAdvance-hydra.wasm
path: build/bin/hydra/libNanoBoyAdvance-hydra.wasm
if-no-files-found: error
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(PLATFORM_QT "Build Qt frontend." ON)
option(PLATFORM_HYDRA "Build Hydra core" OFF)

if (PLATFORM_HYDRA)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(src/platform/hydra ${CMAKE_CURRENT_BINARY_DIR}/bin/hydra/)
endif()

add_subdirectory(src/nba)
add_subdirectory(src/platform/core)
Expand Down
49 changes: 27 additions & 22 deletions src/platform/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ option(USE_STATIC_SDL "Link against static version of SDL library." OFF)
option(USE_SYSTEM_TOML11 "Use system-provided toml11 library." OFF)
option(USE_SYSTEM_UNARR "Use system-provided unarr library." OFF)

if(USE_STATIC_SDL)
find_package(SDL2 2.0.10
REQUIRED COMPONENTS SDL2-static
OPTIONAL_COMPONENTS SDL2main
CONFIG)
else()
find_package(SDL2 2.0.10
REQUIRED COMPONENTS SDL2
OPTIONAL_COMPONENTS SDL2main
CONFIG)
endif()
# probably move sdl stuff to qt/cmakelists
if (NOT EMSCRIPTEN)
if(USE_STATIC_SDL)
find_package(SDL2 2.0.10
REQUIRED COMPONENTS SDL2-static
OPTIONAL_COMPONENTS SDL2main
CONFIG)
else()
find_package(SDL2 2.0.10
REQUIRED COMPONENTS SDL2
OPTIONAL_COMPONENTS SDL2main
CONFIG)
endif()

find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
endif()

if(USE_SYSTEM_TOML11)
find_package(toml11 3.7 REQUIRED)
Expand Down Expand Up @@ -54,7 +57,7 @@ endif()

set(SOURCES
src/device/ogl_video_device.cpp
src/device/sdl_audio_device.cpp
# src/device/sdl_audio_device.cpp
src/loader/bios.cpp
src/loader/rom.cpp
src/loader/save_state.cpp
Expand Down Expand Up @@ -92,17 +95,19 @@ add_library(platform-core STATIC)
target_sources(platform-core PRIVATE ${SOURCES} ${HEADERS} ${HEADERS_PUBLIC})
target_include_directories(platform-core PRIVATE src PUBLIC include)

if(TARGET SDL2::SDL2main)
target_link_libraries(platform-core PUBLIC SDL2::SDL2main)
endif()
if (NOT EMSCRIPTEN)
if(TARGET SDL2::SDL2main)
target_link_libraries(platform-core PUBLIC SDL2::SDL2main)
endif()

if(USE_STATIC_SDL)
target_link_libraries(platform-core PUBLIC SDL2::SDL2-static)
else()
target_link_libraries(platform-core PUBLIC SDL2::SDL2)
if(USE_STATIC_SDL)
target_link_libraries(platform-core PUBLIC SDL2::SDL2-static)
else()
target_link_libraries(platform-core PUBLIC SDL2::SDL2)
endif()
endif()

target_link_libraries(platform-core
PRIVATE unarr::unarr
PUBLIC nba toml11::toml11 OpenGL::GL GLEW::GLEW
PUBLIC nba toml11::toml11
)
13 changes: 13 additions & 0 deletions src/platform/hydra/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if (EMSCRIPTEN)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX ".wasm")
set(CMAKE_STRIP FALSE)
endif()

add_library(NanoBoyAdvance-hydra SHARED src/core.cpp)

target_include_directories(NanoBoyAdvance-hydra PUBLIC include)
target_include_directories(NanoBoyAdvance-hydra PRIVATE src)
target_link_libraries(NanoBoyAdvance-hydra PRIVATE platform-core)
Loading

0 comments on commit dc5af5a

Please sign in to comment.