Skip to content
Draft
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
74 changes: 63 additions & 11 deletions .github/actions/build_macos_arm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,93 @@ runs:
shell: bash
run: |
brew update
brew install cunit sdl2_mixer confuse enet sdl2 libxmp libpng opusfile libepoxy miniupnpc libnatpmp
brew install confuse cunit enet libepoxy libnatpmp libxmp miniupnpc \
opusfile sdl2-compat sdl2_mixer sdl3
brew install coreutils create-dmg

- name: Generate Release
shell: bash
run: |
mkdir build-release && cd build-release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release/usr ..
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=. ..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before merging, I imagine you'll want to set the build type back to Release

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, or at least making a different run for the rec tests.

make -j $(getconf _NPROCESSORS_ONLN)
make -j $(getconf _NPROCESSORS_ONLN) install

- name: Verify openomf.app signature in ./openomf.app
shell: bash
run: |
cd build-release
cat ./openomf.app/Contents/Info.plist
codesign --display --verbose=4 ./openomf.app

- name: Get openomf assets
uses: ./.github/actions/assets

- name: Extract openomf assets
shell: bash
run: unzip -j openomf-assets.zip -d build-release/release/usr/share/games/openomf/resources
run: unzip -j openomf-assets.zip -d build-release/openomf.app/Contents/Resources

- name: Get openomf mods
uses: ./.github/actions/fetch_mods

- name: Extract openomf mods
shell: bash
run: |
mkdir -p build-release/release/usr/share/games/openomf/mods
unzip -o openomf-mods.zip -d build-release/release/usr/share/games/openomf/mods
mkdir -p build-release/openomf.app/Contents/mods
unzip -o openomf-mods.zip -d build-release/openomf.app/Contents/mods

- name: Create DMG package
shell: bash
run: |
create-dmg \
--volname "OpenOMF" \
--app-drop-link 300 150 \
--hide-extension "OpenOMF.app" \
"openomf_${{ env.OPENOMF_VERSION }}_macos26_arm.dmg" \
"build-release/openomf.app/"

- name: Mount DMG and Install OpenOMF to /Applications
shell: bash
run: |
hdiutil attach "openomf_${{ env.OPENOMF_VERSION }}_macos26_arm.dmg" \
-nobrowse -mountpoint ./mounted_openomf
cp -R ./mounted_openomf/openomf.app /Applications/
hdiutil detach ./mounted_openomf

- name: Generate ZIP package
- name: Verify openomf.app signature in /Applications
shell: bash
run: |
cd build-release/release
zip -r ${GITHUB_WORKSPACE}/openomf_${{ env.OPENOMF_VERSION }}_macos14_arm.zip .
cat /Applications/openomf.app/Contents/Info.plist
codesign --display --verbose=4 /Applications/openomf.app

- name: Check openomf --version works
shell: bash
run: |
set -o pipefail
ret=0
gtimeout 10 /Applications/openomf.app/Contents/MacOS/openomf \
--version 2>&1 | tee $RUNNER_TEMP/version || ret=$?
if [ "$ret" -ne 1 ]; then
echo "openomf --version exit value: $ret"
if [ "$ret" -eq 124 ]; then
echo "openomf --version timed out"
fi
exit 1
fi
if ! grep -q "$OPENOMF_VERSION" "$RUNNER_TEMP/version"; then
echo "$RUNNER_TEMP/version does not include $OPENOMF_VERSION"
exit 1
fi

- name: Run REC tests
shell: bash
env:
OPENOMF_RESOURCE_PATH: /Applications/openomf.app/Contents
run: ./run_rectests.sh build-release
Comment on lines +91 to +95

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not run the rec tests more times than we have to, as they take 6 minutes in CI.
They're run as part of the "Functional CI / Run rec tests and menu tests" action.


- name: Upload artifacts
- name: Upload DMG artifact
uses: actions/upload-artifact@v7
with:
name: openomf_${{ env.OPENOMF_VERSION }}_macos14_arm
path: openomf_${{ env.OPENOMF_VERSION }}_macos14_arm.zip
name: openomf_${{ env.OPENOMF_VERSION }}_macos26_arm
path: openomf_${{ env.OPENOMF_VERSION }}_macos26_arm.dmg
if-no-files-found: error
5 changes: 2 additions & 3 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ jobs:
# Build macos package, release artifact
# -----------------------------------------------------------------------------------------------
build_macos-arm:
needs: [unittest, windows_units]
name: Build macos-14
runs-on: macos-14
name: Build MacOS 26
runs-on: macos-26
steps:
- uses: actions/checkout@v6
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
uses: ./.github/actions/build_appimage

build_macos-arm:
name: Build macos-14
runs-on: macos-14
name: Build MacOS 26
runs-on: macos-26
steps:
- uses: actions/checkout@v6
with:
Expand Down
53 changes: 52 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ omf_target_precompile_headers(openomf_core PUBLIC
"<enet/enet.h>"
"<epoxy/gl.h>"
)
if(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang)$")
if(CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
set_source_files_properties("${CMAKE_SOURCE_DIR}/src/vendored/argtable/argtable3.c"
PROPERTIES COMPILE_OPTIONS "-Wno-format-nonliteral"
)
Expand Down Expand Up @@ -480,6 +480,16 @@ set(DOC_FILES
src/vendored/zip/LICENSE.zip
)

if(APPLE)
set_target_properties(openomf PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME "OpenOMF"
MACOSX_BUNDLE_GUI_IDENTIFIER "org.openomf.openomf"
MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_LABEL}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_LABEL}"
)
endif()

# Installation
if(WIN32)
# On windows, generate a flat directory structure under openomf/ subdir.
Expand All @@ -488,6 +498,14 @@ if(WIN32)
install(FILES resources/openomf.bk resources/gamecontrollerdb/gamecontrollerdb.txt DESTINATION openomf/resources/ COMPONENT Data)
install(DIRECTORY shaders/ DESTINATION openomf/shaders COMPONENT Data)
install(FILES ${DOC_FILES} DESTINATION openomf/ COMPONENT Data)
elseif(APPLE)
install(TARGETS openomf BUNDLE DESTINATION . RUNTIME DESTINATION bin COMPONENT Binaries)
install(FILES ${DOC_FILES} resources/openomf.bk resources/gamecontrollerdb/gamecontrollerdb.txt
resources/icons/openomf.png resources/flatpak/org.openomf.OpenOMF.desktop
DESTINATION openomf.app/Contents/Resources
COMPONENT Data
)
install(DIRECTORY shaders/ DESTINATION openomf.app/Contents/shaders COMPONENT Data)
else()
# On unixy systems, follow standard.
install(TARGETS openomf RUNTIME DESTINATION bin COMPONENT Binaries)
Expand All @@ -498,3 +516,36 @@ else()
)
install(DIRECTORY shaders/ DESTINATION share/games/openomf/shaders COMPONENT Data)
endif()

# Bundle in libSDL3.dylib since fixup_bundle() does not see the dependency.
if(APPLE)
find_package(SDL3 REQUIRED)
get_target_property(SDL3_LIBRARY_PATH SDL3::SDL3 LOCATION)
if(NOT SDL3_LIBRARY_PATH)
message(FATAL_ERROR "SDL3 not found")
endif()
message(STATUS "SDL3 is in ${SDL3_LIBRARY_PATH}")

set(SDL3_BUNDLE_SCRIPT "set(SDL3_LIBRARY_PATH [=[${SDL3_LIBRARY_PATH}]=])\n")

string(APPEND SDL3_BUNDLE_SCRIPT [[
include(BundleUtilities)

set(APP_PATH "${CMAKE_INSTALL_PREFIX}/openomf.app")
set(CONTENTS_DIR "${APP_PATH}/Contents")

fixup_bundle("${APP_PATH}" "" "/opt/homebrew/lib;/usr/local/lib")
file(INSTALL "${SDL3_LIBRARY_PATH}" DESTINATION "${CONTENTS_DIR}/Frameworks" RENAME "libSDL3.dylib")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file(INSTALL ... RENAME doesn't exist.
https://cmake.org/cmake/help/latest/command/file.html#install

Perhaps use file(COPY_FILE (new in cmake 3.21) or configure_file(<input> <output> COPYONLY) instead? file(INSTALL followed by a rename defeats some of INSTALL's features, anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we may run into trouble dlopen'ing SDL3 after using the bare filecopy, as fixup_bundle will not have tracked down the dylib dependencies of SDL3.

If this trouble does not occur, the manual file copy is good enough to stay-- considering an SDL3 port is inevitable, and will introduce a direct link dependency on SDL3, enabling fixup_bundle to grab SDL3 for us without any of this dancing around.

Dumb idea: What if we linked SDL3 into the openomf target on macos? I wouldn't expect symbol conflicts between sdl2-compat and SDL3, and if the dep survives the linker, we've just successfully told fixup_bundle to copy over the SDL3 that our sdl2-compat needs.


execute_process(
COMMAND codesign --force --sign - "${CONTENTS_DIR}/Frameworks/libSDL3.dylib"
COMMAND_ERROR_IS_FATAL ANY
)
execute_process(
COMMAND codesign --force --identifier "org.openomf.openomf" --sign - "${APP_PATH}"
COMMAND_ERROR_IS_FATAL ANY
)
]])

install(CODE "${SDL3_BUNDLE_SCRIPT}" COMPONENT Binaries)
endif()
2 changes: 2 additions & 0 deletions cmake-scripts/BuildLanguages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set(OPENOMF_LANGS DANISH)

if(WIN32)
set(LANGUAGE_INSTALL_PATH "openomf/resources/")
elseif(APPLE)
set(LANGUAGE_INSTALL_PATH "openomf.app/Contents/Resources/")
else()
set(LANGUAGE_INSTALL_PATH "share/games/openomf/resources/")
endif()
Expand Down
4 changes: 2 additions & 2 deletions run_rectests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ -z "$1" ]; then
fi

export BUILD_DIR="$1"
OPENOMF_BIN=$(find "$BUILD_DIR" -name openomf -type f -executable -print -quit)
OPENOMF_BIN=$(find "$BUILD_DIR" -name openomf -type f -exec test -x {} \; -print -quit)
if [ -z "$OPENOMF_BIN" ]; then
echo "Could not find openomf executable from $BUILD_DIR" >&2
exit 1
Expand Down Expand Up @@ -98,7 +98,7 @@ RUNDIR=$(pwd)

cd $BUILD_DIR

export OPENOMF_RESOURCE_PATH="."
export OPENOMF_RESOURCE_PATH="${OPENOMF_RESOURCE_PATH:-.}"
export LSAN_OPTIONS="suppressions=../lsan.supp"

output_file="$temp_dir/output_shouldfail.log"
Expand Down
Loading