Skip to content

Commit

Permalink
CI/packaging refresh with updates from Nanosaur 2
Browse files Browse the repository at this point in the history
- SDL 2.26.1
- aarch64 build job
- mainmenu.nib without Cmd+Q/Cmd+W shortcuts
- macOS Hi-DPI support in info.plist
- upload-artifact@v3
  • Loading branch information
jorio committed Nov 22, 2022
1 parent 94d2bad commit 457a6e9
Show file tree
Hide file tree
Showing 9 changed files with 471 additions and 255 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/FullCompileCheck.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
name: Full Compile Check

on: [push, workflow_dispatch]
on: [workflow_dispatch]

jobs:
full-compile-check-aarch64:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- uses: uraimo/run-on-arch-action@v2
with:
arch: aarch64
distro: ubuntu20.04
githubToken: ${{ github.token }}
install: |
apt update -y
apt install -y build-essential libsdl2-dev cmake
run: |
python3 build.py --dependencies --configure --build --system-sdl
full-compile-check:
name: ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}
Expand All @@ -25,7 +43,7 @@ jobs:
sudo apt update
sudo apt install libsdl2-dev
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: 'recursive'

Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/ReleaseBuilds-aarch64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Make Release Builds (linux/aarch64)

on: [workflow_dispatch]

jobs:
build-linux-appimage-aarch64:
runs-on: ubuntu-20.04
timeout-minutes: 100 # this job may take up to an hour

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

# Create shared directory ON HOST. (If it's done within qemu, it'll be created with root permissions)
- name: Create artifacts directory shared with docker
run: |
mkdir -p "artifacts"
# QEMU can't run appimagetool-aarch64, so we have to build the AppImage on x86_64
- name: Download appimagetool
run : |
pushd artifacts
wget -q https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage
wget -q https://github.com/AppImage/AppImageKit/releases/download/13/runtime-aarch64
chmod +x appimagetool-x86_64.AppImage
chmod +x runtime-aarch64
popd
- uses: uraimo/run-on-arch-action@v2
name: Build game via QEMU
id: buildgame
with:
arch: aarch64

# Distro must be kept in sync with `runs-on` above.
# We can't use 18.04 because it ships with cmake 3.10 (too ancient).
# See: https://github.com/uraimo/run-on-arch-action#supported-platforms
distro: ubuntu20.04

# (Optional) Speeds up builds by storing container images in a GitHub package registry.
githubToken: ${{ github.token }}

# Mount the artifacts directory as /artifacts in the container
dockerRunArgs: |
--volume "${PWD}/artifacts:/artifacts"
# Install build tools for the game and SDL build dependencies.
# See: https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md (last updated for SDL 2.26.0)
install: |
apt update -y
apt install -y build-essential cmake
#apt install -y libsdl2-dev #----- for quick testing
apt install -y libasound2-dev libpulse-dev \
libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
# Build the aarch64 version under dist/, then tar it up and move it to /artifacts.
# (We're not building directly in /artifacts as this would cause permission issues when moving back to the x86_64 host)
run: |
#python3 build.py --system-sdl --no-appimage #----- for quick testing
python3 build.py --no-appimage
cd dist
tar cvf /artifacts/aarch64-dist.tar ./*.AppDir
# QEMU can't run appimagetool-aarch64, so we have to build the AppImage on x86_64
- name: Create AppImage on x86_64 host
run: |
cd artifacts
tar xvf aarch64-dist.tar
APPIMAGE_INPUT=$(ls -d --indicator-style=none *.AppDir)
APPIMAGE_OUTPUT=${APPIMAGE_INPUT%.AppDir}.AppImage
echo "APPIMAGE_OUTPUT=$APPIMAGE_OUTPUT" >> $GITHUB_ENV
./appimagetool-x86_64.AppImage -v --runtime-file runtime-aarch64 --no-appstream $APPIMAGE_INPUT $APPIMAGE_OUTPUT
- uses: actions/upload-artifact@v3
with:
name: ${{ env.APPIMAGE_OUTPUT }}
path: artifacts/${{ env.APPIMAGE_OUTPUT }}
18 changes: 11 additions & 7 deletions .github/workflows/ReleaseBuilds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ jobs:
runs-on: ubuntu-18.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v2 # Checks out repository under $GITHUB_WORKSPACE so the job can access it
- uses: actions/checkout@v3 # Checks out repository under $GITHUB_WORKSPACE so the job can access it
with:
submodules: 'recursive'
- name: Get build dependencies for SDL from APT # cf. https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md
run: |
sudo apt update
sudo apt install libasound2-dev libpulse-dev libaudio-dev libjack-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev libgl1-mesa-dev libdbus-1-dev libudev-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev fcitx-libs-dev libsamplerate0-dev libsndio-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev
sudo apt install -y libasound2-dev libpulse-dev \
libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
- run: python3 build.py --dependencies
- run: python3 build.py --configure
- run: python3 build.py --build
- run: python3 build.py --package
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: linux-build
path: dist/
Expand All @@ -27,14 +31,14 @@ jobs:
runs-on: windows-2022
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- run: python3 build.py --dependencies
- run: python3 build.py --configure -G 'Visual Studio 17 2022'
- run: python3 build.py --build
- run: python3 build.py --package
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: windows-build
path: dist/
Expand All @@ -53,7 +57,7 @@ jobs:
run: |
brew tap mitchellh/gon
brew install mitchellh/gon/gon
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- run: python3 build.py --dependencies
Expand All @@ -65,7 +69,7 @@ jobs:
env:
AC_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
AC_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: mac-build
path: dist/
35 changes: 22 additions & 13 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
# How to build Bugdom

## TL;DR: Automated build script
## The easy way: build.py (automated build script)

Clone the repo **recursively**, then run `python3 build.py` to execute the build steps described in this document and package up the game.
`build.py` can produce a game executable from a fresh clone of the repo in a single command. It will work on macOS, Windows and Linux, provided that your system has Python 3, CMake, and an adequate C++ compiler.

build.py is the script that is used by the CI setup to produce builds. If you want to build the game manually instead, read on.
```
git clone --recurse-submodules https://github.com/jorio/Bugdom
cd Bugdom
python3 build.py
```

## How to build the game on macOS
If you want to build the game **manually** instead, the rest of this document describes how to do just that on each of the big 3 desktop OSes.

## How to build the game manually on macOS

1. Install the prerequisites:
- Xcode 12+
- [CMake](https://formulae.brew.sh/formula/cmake) 3.16+
- [CMake](https://formulae.brew.sh/formula/cmake) 3.16+ (installing via Homebrew is recommended)
1. Clone the repo **recursively**:
```
git clone --recurse-submodules https://github.com/jorio/Bugdom
cd Bugdom
```
1. Download [SDL2-2.24.0.dmg](https://libsdl.org/release/SDL2-2.24.0.dmg), open it, and copy **SDL2.framework** to the **extern** folder
1. Download [SDL2-2.26.1.dmg](https://libsdl.org/release/SDL2-2.26.1.dmg), open it, and copy **SDL2.framework** to the **extern** folder
1. Prep the Xcode project:
```
cmake -G Xcode -S . -B build
```
1. Now you can open `build/Bugdom.xcodeproj` in Xcode, or you can just go ahead and build the game:
```
cmake --build build --config Release
cmake --build build --config RelWithDebInfo
```
1. The game gets built in `build/Release/Bugdom.app`. Enjoy!
1. The game gets built in `build/RelWithDebInfo/Bugdom.app`. Enjoy!
## How to build the game on Windows
## How to build the game manually on Windows
1. Install the prerequisites:
- Visual Studio 2022 with the C++ toolchain
- [CMake](https://cmake.org/download/) 3.16+
1. Clone the repo **recursively**:
```
git clone --recurse-submodules https://github.com/jorio/Bugdom
cd Bugdom
```
1. Download [SDL2-devel-2.24.0-VC.zip](https://libsdl.org/release/SDL2-devel-2.24.0-VC.zip) and extract the contents into the **extern** folder
1. Download [SDL2-devel-2.26.1-VC.zip](https://libsdl.org/release/SDL2-devel-2.26.1-VC.zip), extract it, and copy **SDL2-2.26.1** to the **extern** folder
1. Prep the Visual Studio solution:
```
cmake -G "Visual Studio 17 2022" -A x64 -S . -B build
Expand All @@ -46,7 +54,7 @@ build.py is the script that is used by the CI setup to produce builds. If you wa
```
1. The game gets built in `build/Release/Bugdom.exe`. Enjoy!
## How to build the game on Linux et al.
## How to build the game manually on Linux et al.
1. Install the prerequisites from your package manager:
- Any C++20 compiler
Expand All @@ -56,12 +64,13 @@ build.py is the script that is used by the CI setup to produce builds. If you wa
1. Clone the repo **recursively**:
```
git clone --recurse-submodules https://github.com/jorio/Bugdom
cd Bugdom
```
1. Build the game:
```
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
```
If you'd like to enable runtime sanitizers, append `-DSANITIZE=1` to the **first** `cmake` call above.
1. The game gets built in `build/Release/Bugdom`. Enjoy!
1. The game gets built in `build/Bugdom`. Enjoy!
24 changes: 19 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ cmake_minimum_required(VERSION 3.16)

set(GAME_TARGET "Bugdom")
set(GAME_VERSION "1.3.2")

set(GAME_MAC_ICNS "packaging/${GAME_TARGET}.icns")
set(GAME_MAC_COPYRIGHT "© 1999 Pangea Software, Inc.\n© 2022 Iliyas Jorio.")
set(GAME_MAC_BUNDLE_ID "io.jor.bugdom")
set(GAME_MAC_BUNDLE_NAME "Bugdom")

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

Expand Down Expand Up @@ -52,6 +54,7 @@ endif()
set(POMME_NO_VIDEO true)
set(POMME_NO_INPUT true)
set(POMME_NO_GRAPHICS true)
set(POMME_NO_MP3 true)

#------------------------------------------------------------------------------
# DEPENDENCIES
Expand Down Expand Up @@ -123,6 +126,7 @@ target_include_directories(${GAME_TARGET} PRIVATE
${GAME_SRCDIR}/Headers
)


#------------------------------------------------------------------------------
# COMPILER/LINKER OPTIONS
#------------------------------------------------------------------------------
Expand All @@ -131,6 +135,9 @@ add_compile_definitions(
"$<$<CONFIG:DEBUG>:_DEBUG>"
)

target_compile_definitions(${GAME_TARGET} PRIVATE
GL_SILENCE_DEPRECATION)

if(NOT MSVC)
target_compile_options(${GAME_TARGET} PRIVATE
-fexceptions
Expand All @@ -143,12 +150,14 @@ if(NOT MSVC)
-Wstrict-aliasing=2
)

# Build with sanitizers -- When using a debugger, you should export LSAN_OPTIONS=detect_leaks=0
if (SANITIZE)
# Sanitizers in debug mode (Linux only)
# When using a debugger, you should export LSAN_OPTIONS=detect_leaks=0
if(SANITIZE)
list(INSERT GAME_LIBRARIES 0 asan ubsan)
target_compile_options(${GAME_TARGET} PRIVATE
-fsanitize=alignment
-fsanitize=address
-fsanitize=leak
-fsanitize=undefined
-fno-omit-frame-pointer
)
Expand All @@ -167,6 +176,7 @@ else()
/EHs # synchronous exceptions; also, extern "C" functions may throw exceptions
/W4
/wd4068 # ignore unrecognized pragmas
/wd4100 # unreferenced formal parameters
/wd4201 # nonstandard extension (nameless struct)
/wd4244 # conversion from double to float
/wd4305 # truncation from double to float
Expand Down Expand Up @@ -212,7 +222,7 @@ set_target_properties(${GAME_TARGET} PROPERTIES
MACOSX_BUNDLE_EXECUTABLE_NAME ${GAME_TARGET} # CFBundleExecutable - executable name inside the bundle
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION} # CFBundleShortVersionString
MACOSX_BUNDLE_COPYRIGHT ${GAME_MAC_COPYRIGHT} # NSHumanReadableCopyright (supersedes CFBundleGetInfoString (MACOSX_BUNDLE_INFO_STRING))
MACOSX_BUNDLE_BUNDLE_NAME ${GAME_TARGET} # CFBundleName - user-visible (where??) short name for the bundle, up to 15 characters
MACOSX_BUNDLE_BUNDLE_NAME ${GAME_MAC_BUNDLE_NAME} # CFBundleName - user-visible short name for the bundle, up to 15 characters
MACOSX_BUNDLE_GUI_IDENTIFIER ${GAME_MAC_BUNDLE_ID} # CFBundleIdentifier - unique bundle ID in reverse-DNS format

# Bundle ID required for code signing - must match CFBundleIdentifier otherwise xcode will complain
Expand All @@ -224,6 +234,7 @@ set_target_properties(${GAME_TARGET} PROPERTIES
XCODE_EMBED_FRAMEWORKS "${SDL2_LIBRARIES}"
XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY "YES" # frameworks must be signed by the same developer as the binary
XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY "YES" # not strictly necessary, but that's cleaner
XCODE_ATTRIBUTE_COPY_PHASE_STRIP[variant=Debug] "NO" # avoid "skipping copy phase strip" warning while working on Debug config
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES" # required for notarization to pass
)

Expand All @@ -248,17 +259,20 @@ if(APPLE)

# Copy stuff to app bundle contents
set_source_files_properties(${GAME_MAC_ICNS} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
#set_source_files_properties(${SDL2_LIBRARIES} PROPERTIES MACOSX_PACKAGE_LOCATION "Frameworks")

set(BUNDLE_CONTENTS_DIR "$<TARGET_FILE_DIR:${PROJECT_NAME}>/..")
set(APP_PARENT_DIR "${BUNDLE_CONTENTS_DIR}/../..")

add_custom_command(TARGET ${GAME_TARGET} POST_BUILD
# Copy assets to app bundle
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Data ${BUNDLE_CONTENTS_DIR}/Resources
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/packaging/mainmenu.nib ${BUNDLE_CONTENTS_DIR}/Resources/mainmenu.nib

# High-DPI support in Info.plist
# plutil -replace NSHighResolutionCapable -bool true ${BUNDLE_CONTENTS_DIR}/Info.plist
COMMAND plutil -replace NSHighResolutionCapable -bool true ${BUNDLE_CONTENTS_DIR}/Info.plist

# Make it honor mainmenu.nib (use -replace instead of -insert so it doesn't fail on subsequent builds)
COMMAND plutil -replace NSMainNibFile -string "mainmenu" ${BUNDLE_CONTENTS_DIR}/Info.plist
)
else()
set(APP_PARENT_DIR "$<TARGET_FILE_DIR:${GAME_TARGET}>")
Expand Down
Loading

0 comments on commit 457a6e9

Please sign in to comment.