Skip to content

Commit

Permalink
Add SDL2 building to CMake as default
Browse files Browse the repository at this point in the history
Let homebrew platforms still use SDL1.2
Fix CI workflows
  • Loading branch information
carstene1ns committed Oct 24, 2023
1 parent 112afc8 commit cee7b53
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defaults:

jobs:
linux-gcc:
name: Build (Ubuntu 20.04 LTS x86_64, GCC)
name: Build (Ubuntu 20.04 LTS x86_64, GCC, SDL1.2)
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
Expand All @@ -30,30 +30,30 @@ jobs:
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz (normal)
run: |
make
ls -l OpenJazz
linux-clang:
name: Build (Ubuntu 20.04 LTS x86_64, Clang)
name: Build (Ubuntu 20.04 LTS x86_64, Clang, SDL2)
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
run: |
sudo apt-get update -yqq
sudo apt-get install -yqq build-essential cmake ninja-build clang-10 \
libsdl1.2-dev asciidoctor w3m
libsdl2-dev asciidoctor w3m
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz (slim)
run: |
Expand Down Expand Up @@ -90,26 +90,25 @@ jobs:
install: |
base-devel dos2unix w3m
pacboy: |
toolchain:p cmake:p ninja:p SDL:p asciidoctor:p
toolchain:p cmake:p ninja:p SDL2:p asciidoctor:p
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
export LDFLAGS="-static"
export PKG_CONFIG="pkg-config --static"
cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Prepare artifact
run: |
cmake --install build --prefix $PWD
cp /mingw64/bin/SDL2.dll dist/
asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc
w3m -dump -cols 2147483647 -s OpenJazzManual.html > dist/Manual.txt
cp README.md dist/README.txt
Expand Down Expand Up @@ -140,7 +139,7 @@ jobs:
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
Expand Down Expand Up @@ -181,7 +180,7 @@ jobs:
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
Expand Down Expand Up @@ -231,7 +230,7 @@ jobs:
../autobuilder/build -v libsdl1.2debian # todo: cache?
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
Expand Down Expand Up @@ -267,7 +266,7 @@ jobs:
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
Expand Down
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED OFF)
include(Platform-Helpers)

# Endianess check

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
include(TestBigEndian)
test_big_endian(PLATFORM_BIGENDIAN)
if(PLATFORM_BIGENDIAN)
add_compile_definitions(WORDS_BIGENDIAN=1)
endif()
include(TestBigEndian)
test_big_endian(PLATFORM_BIGENDIAN)
if(PLATFORM_BIGENDIAN)
add_compile_definitions(WORDS_BIGENDIAN=1)
endif()

# OpenJazz
Expand Down Expand Up @@ -130,7 +127,7 @@ target_include_directories(OpenJazz PUBLIC src)
option(SCALE "Allow scaling" ${OJ_SCALE})
if(SCALE)
target_compile_definitions(OpenJazz PRIVATE SCALE)
set(OJ_SCALE_LIBS scale2x)
set(OJ_LIBS_SCALE scale2x)
endif()

# path to game data
Expand All @@ -142,8 +139,17 @@ endif()

# libraries

find_package(SDL REQUIRED)
target_include_directories(OpenJazz PRIVATE ${SDL_INCLUDE_DIR})
if(LEGACY_SDL)
find_package(SDL REQUIRED)
target_include_directories(OpenJazz PRIVATE ${SDL_INCLUDE_DIR})
set(OJ_LIBS_SDL ${SDL_LIBRARY})
set(OJ_SDL "SDL1.2 (legacy)")
else()
find_package(SDL2 REQUIRED)
target_include_directories(OpenJazz PRIVATE ${SDL2_INCLUDE_DIRS})
set(OJ_LIBS_SDL ${SDL2_LIBRARIES})
set(OJ_SDL "SDL2")
endif()

# bundled libraries

Expand Down Expand Up @@ -176,7 +182,7 @@ if(NETWORK)
endif()

target_link_libraries(OpenJazz
argparse miniz psmplug ${OJ_SCALE_LIBS} ${SDL_LIBRARY} ${OJ_LIBS_NET} ${OJ_LIBS_HOST})
argparse miniz psmplug ${OJ_LIBS_SCALE} ${OJ_LIBS_SDL} ${OJ_LIBS_NET} ${OJ_LIBS_HOST})

# platform stuff

Expand Down Expand Up @@ -332,6 +338,7 @@ message(STATUS "")
message(STATUS "OpenJazz")
message(STATUS "========")
message(STATUS "Target system: ${OJ_HOST}")
message(STATUS "Platform abstraction: ${OJ_SDL}")
if(ROMFS)
message(STATUS "RomFS: Embedding directory \"${ROMFS_PATH}\"")
endif()
Expand Down
10 changes: 8 additions & 2 deletions builds/cmake/Platform-Helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ option(GP2X "Build for GP2X" OFF) # arm-open2x-linux
option(DINGOO "Build for Dingoo" OFF) # mipsel-linux*
option(GAMESHELL "Build for GameShell" OFF) # armv7l-unknown-linux-gnueabihf
option(RISCOS "Build for RISC OS" OFF) # arm-unknown-riscos
# "Official" Toolchain files define these

# Official/Homebrew Toolchain files define these
if(NINTENDO_3DS)
set(3DS ON)
set(OJ_HOST "3DS")
list(APPEND PLATFORM_LIST ${OJ_HOST})
set(OJ_SCALE OFF)
option(ROMFS "Embedd a directory in the executable" OFF)
option(ROMFS "Embed a directory in the executable" OFF)
set(ROMFS_PATH "romfs" CACHE PATH "Directory to include in executable as romfs:/ path")
set(ROMFS_ARG "NO_ROMFS_IGNORE_ME")
if(ROMFS)
Expand Down Expand Up @@ -111,4 +112,9 @@ endif()

if(${OJ_HOST} STREQUAL "Unknown")
set(OJ_HOST ${CMAKE_SYSTEM_NAME})
set(OJ_ALLOW_NEW_SDL TRUE)
endif()

# choose SDL library for Linux/Windows/Mac/etc., but not homebrew platforms
include(CMakeDependentOption)
cmake_dependent_option(LEGACY_SDL "Build for SDL 1.2" OFF "OJ_ALLOW_NEW_SDL" ON)

0 comments on commit cee7b53

Please sign in to comment.