diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index faf5f7e..b9c0342 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -24,5 +24,6 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v7 with: + name: xsystem35-android-sdl3 path: android/app/build/outputs/apk/release/app-release.apk archive: false diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 4a26d50..be4f7f2 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -8,6 +8,11 @@ env: jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdl-version: [2, 3] + name: Emscripten SDL${{ matrix.sdl-version }} steps: - uses: actions/checkout@v6 @@ -17,7 +22,7 @@ jobs: uses: actions/cache@v5 with: path: ${{env.EM_CACHE_FOLDER}} - key: ${{env.EM_VERSION}}-${{ runner.os }} + key: ${{env.EM_VERSION}}-${{ runner.os }}-sdl${{ matrix.sdl-version }} - name: Setup Emscripten toolchain uses: emscripten-core/setup-emsdk@v16 @@ -30,15 +35,16 @@ jobs: - name: Build run: | - mkdir -p out/wasm - cd out/wasm - emcmake cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_COMPILE_WARNING_AS_ERROR=YES ../../ - make -j4 - mkdir xsystem35 - mv src/xsystem35.* xsystem35/ + emcmake cmake -S . -B out/wasm \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=YES \ + -DXSYSTEM35_SDL_VERSION=${{ matrix.sdl-version }} + cmake --build out/wasm -j4 + mkdir out/wasm/xsystem35 + mv out/wasm/src/xsystem35.* out/wasm/xsystem35/ - name: Upload artifacts uses: actions/upload-artifact@v7 with: - name: xsystem35-wasm + name: xsystem35-wasm-sdl${{ matrix.sdl-version }} path: out/wasm/xsystem35 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 0bee837..dd16e1f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -3,33 +3,38 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04 strategy: + fail-fast: false matrix: build-type: ["Debug", "Release"] + sdl-version: [2, 3] - name: Linux ${{ matrix.build-type }} + name: Linux SDL${{ matrix.sdl-version }} ${{ matrix.build-type }} steps: - uses: actions/checkout@v6 - name: Install Deps run: | sudo apt update - sudo apt install libsdl2-dev libfreetype-dev libsdl2-mixer-dev libwebp-dev libportmidi-dev libcjson-dev asciidoctor gettext + sudo apt install libfreetype-dev libwebp-dev libportmidi-dev libcjson-dev asciidoctor gettext + if [ "${{ matrix.sdl-version }}" = 2 ]; then + sudo apt install libsdl2-dev libsdl2-mixer-dev + else + sudo apt install libsdl3-dev libsdl3-mixer-dev + fi - name: Build run: | - mkdir -p out/${{ matrix.build-type }} - cd out/${{ matrix.build-type }} - cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} ../../ - make -j4 + cmake -S . -B out/build -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ + -DXSYSTEM35_SDL_VERSION=${{ matrix.sdl-version }} + cmake --build out/build -j4 - name: Test - run: ctest --output-on-failure - working-directory: out/${{ matrix.build-type }} + run: ctest --test-dir out/build --output-on-failure - name: Verify xsystem35.pot is up to date - if: matrix.build-type == 'Debug' + if: matrix.build-type == 'Debug' && matrix.sdl-version == 2 run: | xgettext --default-domain=xsystem35 --directory=. \ --keyword=_ --keyword=N_ \ diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2c4aa02..2cba4c5 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -9,11 +9,23 @@ jobs: matrix: include: - sys: mingw32 - package: "xsystem35-32bit" + package: "xsystem35-sdl2-32bit" + sdl-version: 2 + sdl-deps: "SDL2:p SDL2_mixer:p" cmake_args: "-DENABLE_DEBUGGER=no" deps: "" - sys: ucrt64 - package: "xsystem35-64bit" + package: "xsystem35-sdl2-64bit" + sdl-version: 2 + sdl-deps: "SDL2:p SDL2_mixer:p" + cmake_args: "" + deps: >- + cjson:p + portmidi:p + - sys: ucrt64 + package: "xsystem35-sdl3-64bit" + sdl-version: 3 + sdl-deps: "sdl3:p sdl3-mixer:p" cmake_args: "" deps: >- cjson:p @@ -21,7 +33,7 @@ jobs: defaults: run: shell: msys2 {0} - name: MSYS2 ${{ matrix.sys }} + name: MSYS2 SDL${{ matrix.sdl-version }} ${{ matrix.sys }} steps: - name: Set up MSYS2 @@ -29,9 +41,8 @@ jobs: with: msystem: ${{ matrix.sys }} pacboy: >- - SDL2:p + ${{ matrix.sdl-deps }} freetype:p - SDL2_mixer:p libwebp:p ${{ matrix.deps }} @@ -50,10 +61,11 @@ jobs: - name: Build run: | - mkdir -p out/release - cd out/release - cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=YES ${{ matrix.cmake_args }} ../../ - ninja + cmake -S . -B out/release -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=YES \ + -DXSYSTEM35_SDL_VERSION=${{ matrix.sdl-version }} \ + ${{ matrix.cmake_args }} + cmake --build out/release - name: Test run: ctest --output-on-failure @@ -62,6 +74,9 @@ jobs: - name: Package run: | cp out/release/src/xsystem35.exe out/release/doc/*.html *.md COPYING xsys35rc.sample dist/ + ldd out/release/src/xsystem35.exe \ + | awk '$2 == "=>" && tolower($3) ~ /\.dll$/ && $3 !~ /WINDOWS/ { print $3 }' \ + | xargs -r cp -t dist/ - name: Upload uses: actions/upload-artifact@v7 diff --git a/README.md b/README.md index d79ce69..af16535 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# xsytem35-sdl2 +# xsystem35 for SDL2/SDL3 This is a multi-platform port of `xsystem35`, a free implementation of AliceSoft's System 3.x game engine. @@ -102,53 +102,95 @@ $ xsystem35 See [xsystem35 command manual](doc/xsystem35.6.adoc) for detailed usage. ## Building + +SDL2 is used by default on desktop platforms and Emscripten. Pass +`-DXSYSTEM35_SDL_VERSION=3` to CMake to select SDL3. Use a separate build +directory for each SDL version. + +The supported configurations are: + +| Platform | SDL2 | SDL3 | +| --- | --- | --- | +| Linux and macOS | Yes | Yes | +| Windows 64-bit | Yes | Yes | +| Windows 32-bit | Yes | No | +| Emscripten | Yes | Yes | +| Android | No | Yes | + +SDL2 builds require SDL 2.18 or later and SDL2_mixer. SDL3 builds require +SDL 3.4 or later and SDL3_mixer 3.2 or later. The remaining common +dependencies are FreeType, zlib, and optionally libwebp, PortMidi, and cJSON. + ### Linux (Debian / Ubuntu) ```bash -$ sudo apt install build-essential cmake libsdl2-dev libsdl2-mixer-dev libfreetype-dev libwebp-dev libportmidi-dev libcjson-dev asciidoctor -$ mkdir -p out/debug -$ cd out/debug -$ cmake -DCMAKE_BUILD_TYPE=Debug ../../ -$ make && make install +$ sudo apt install build-essential cmake libsdl2-dev libsdl2-mixer-dev \ + libfreetype-dev libwebp-dev libportmidi-dev libcjson-dev asciidoctor +$ cmake -S . -B out/sdl2 -DCMAKE_BUILD_TYPE=Debug \ + -DXSYSTEM35_SDL_VERSION=2 +$ cmake --build out/sdl2 +$ sudo cmake --install out/sdl2 ``` +For SDL3 on a distribution that provides SDL 3.4 or later (for example, +Ubuntu 26.04), install `libsdl3-dev libsdl3-mixer-dev` instead of the SDL2 +packages and configure `out/sdl3` with `-DXSYSTEM35_SDL_VERSION=3`. + ### MacOS [Homebrew](https://brew.sh/) is required. ```bash -$ brew install cmake pkg-config sdl2 sdl2_mixer freetype webp portmidi cjson asciidoctor -$ mkdir -p out/debug -$ cd out/debug -$ cmake -DCMAKE_BUILD_TYPE=Debug ../../ -$ make && make install +$ brew install cmake pkg-config sdl2 sdl2_mixer freetype webp portmidi \ + cjson asciidoctor +$ cmake -S . -B out/sdl2 -DCMAKE_BUILD_TYPE=Debug \ + -DXSYSTEM35_SDL_VERSION=2 +$ cmake --build out/sdl2 +$ sudo cmake --install out/sdl2 ``` +For SDL3, install `sdl3 sdl3_mixer` instead of `sdl2 sdl2_mixer` and +configure `out/sdl3` with `-DXSYSTEM35_SDL_VERSION=3`. + ### Windows [MSYS2](https://www.msys2.org) is required. ```bash -$ pacman -S cmake mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-SDL2 mingw-w64-ucrt-x86_64-freetype mingw-w64-ucrt-x86_64-SDL2_mixer mingw-w64-ucrt-x86_64-libwebp mingw-w64-ucrt-x86_64-portmidi mingw-w64-ucrt-x86_64-cjson -$ mkdir -p out/debug -$ cd out/debug -$ cmake -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug ../../ -$ make +$ pacman -S mingw-w64-ucrt-x86_64-gcc \ + mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-SDL2 \ + mingw-w64-ucrt-x86_64-SDL2_mixer mingw-w64-ucrt-x86_64-freetype \ + mingw-w64-ucrt-x86_64-libwebp mingw-w64-ucrt-x86_64-portmidi \ + mingw-w64-ucrt-x86_64-cjson +$ cmake -S . -B out/sdl2 -G"MSYS Makefiles" \ + -DCMAKE_BUILD_TYPE=Debug -DXSYSTEM35_SDL_VERSION=2 +$ cmake --build out/sdl2 ``` +For a 64-bit SDL3 build, install `mingw-w64-ucrt-x86_64-sdl3` and +`mingw-w64-ucrt-x86_64-sdl3-mixer` instead of the SDL2 packages, then +configure `out/sdl3` with `-DXSYSTEM35_SDL_VERSION=3`. The MSYS2 mingw32 +repository does not provide SDL3, so 32-bit Windows builds remain on SDL2. + ### Emscripten ```bash -$ mkdir -p out/wasm -$ cd out/wasm -$ emcmake cmake -DCMAKE_BUILD_TYPE=MinSizeRel ../../ -$ make +$ emcmake cmake -S . -B out/wasm-sdl2 -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DXSYSTEM35_SDL_VERSION=2 +$ cmake --build out/wasm-sdl2 ``` +For SDL3, use a different build directory and +`-DXSYSTEM35_SDL_VERSION=3`. Both versions use Emscripten's bundled SDL port; +SDL_mixer is not required. + To use the generated binary, check out -[Kichikuou on Web](https://github.com/kichikuou/web) and copy `out/xsystem35.*` -into its `docs` directory. +[Kichikuou on Web](https://github.com/kichikuou/web) and copy +`out/wasm-sdl2/src/xsystem35.*` into its `docs` directory. ### Android See [android/README.md](android/). + +Android uses SDL3 exclusively. The Gradle build downloads fixed official SDL3 +3.4.16 and SDL3_mixer 3.2.4 AARs and exposes them to CMake through Prefab. diff --git a/android/README.md b/android/README.md index 528ddfa..851c981 100644 --- a/android/README.md +++ b/android/README.md @@ -73,6 +73,11 @@ Note: This ZIP format is also compatible with ## Building from Source +Android builds use SDL3 exclusively. Gradle downloads the fixed official SDL3 +3.4.16 and SDL3_mixer 3.2.4 AARs, verifies their checksums, and supplies their +native libraries to CMake through Prefab. No separate SDL installation is +required. + ### Using Android Studio Open this directory as an Android Studio project.