-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
923 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Full Compile Check | ||
|
||
on: [workflow_dispatch, push] | ||
|
||
jobs: | ||
full-compile-check: | ||
name: ${{ matrix.platform.name }} | ||
runs-on: ${{ matrix.platform.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- { name: Linux/GCC (ancient), os: ubuntu-18.04, extraflags: "--system-sdl" } | ||
- { name: Linux/GCC, os: ubuntu-latest, extraflags: "--system-sdl" } | ||
- { name: Linux/Clang, os: ubuntu-latest, extraflags: "--system-sdl" } | ||
- { name: Windows/VS2022, os: windows-2022, extraflags: "-G 'Visual Studio 17 2022'" } | ||
- { name: Windows/VS2019, os: windows-2019, extraflags: "-G 'Visual Studio 16 2019'" } | ||
- { name: Mac, os: macos-11 } | ||
|
||
steps: | ||
- name: Install Linux build dependencies | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt update | ||
sudo apt install libsdl2-dev | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
|
||
- run: python3 build.py --dependencies --configure --build ${{ matrix.platform.extraflags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Make Release Builds | ||
|
||
on: [workflow_dispatch] | ||
|
||
jobs: | ||
build-linux-appimage: | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v2 # Checks out repository under $GITHUB_WORKSPACE so the job can access it | ||
with: | ||
submodules: 'recursive' | ||
- name: Get artifact name | ||
run: | | ||
echo "GAME_ARTIFACT=$(python3 build.py --print-artifact-name)" >> $GITHUB_ENV | ||
echo $GAME_ARTIFACT | ||
- 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 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 | ||
- 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 | ||
with: | ||
name: ${{ env.GAME_ARTIFACT }} | ||
path: dist/${{ env.GAME_ARTIFACT }} | ||
|
||
build-windows: | ||
runs-on: windows-2022 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
- name: Get artifact name | ||
run: | | ||
echo ("GAME_ARTIFACT=" + (python3 build.py --print-artifact-name)) >> $env:GITHUB_ENV | ||
echo $env:GAME_ARTIFACT | ||
- 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 | ||
with: | ||
name: ${{ env.GAME_ARTIFACT }} | ||
path: dist/${{ env.GAME_ARTIFACT }} | ||
|
||
build-macos: | ||
runs-on: macos-11 | ||
env: | ||
CODE_SIGN_IDENTITY: ${{ secrets.APPLE_CODE_SIGN_IDENTITY }} | ||
steps: | ||
- uses: apple-actions/import-codesign-certs@v1 | ||
with: | ||
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} | ||
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} | ||
- name: Install gon for notarization | ||
run: | | ||
brew tap mitchellh/gon | ||
brew install mitchellh/gon/gon | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
- name: Get artifact name | ||
run: | | ||
echo "GAME_ARTIFACT=$(python3 build.py --print-artifact-name)" >> $GITHUB_ENV | ||
echo $GAME_ARTIFACT | ||
- run: python3 build.py --dependencies | ||
- run: python3 build.py --configure | ||
- run: python3 build.py --build | ||
- run: python3 build.py --package | ||
- name: Notarize | ||
run: gon packaging/gon-config.json | ||
env: | ||
AC_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }} | ||
AC_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }} | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.GAME_ARTIFACT }} | ||
path: dist/${{ env.GAME_ARTIFACT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
cmake-build-* | ||
|
||
build-*/ | ||
cache/ | ||
cmake-build-*/ | ||
dist/ | ||
extern/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,235 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(CandyCrisis) | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(GAME_TARGET "CandyCrisis") | ||
set(GAME_VERSION "3.0.0") | ||
set(GAME_MAC_ICNS "packaging/${GAME_TARGET}.icns") | ||
set(GAME_MAC_COPYRIGHT "https://github.com/jorio/candycrisis") | ||
set(GAME_MAC_BUNDLE_ID "io.jor.candycrisis") | ||
|
||
find_package(SDL2 REQUIRED) | ||
include_directories(${SDL2_INCLUDE_DIRS}) | ||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") | ||
set(CMAKE_C_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
file(GLOB_RECURSE GAME_SOURCES CONFIGURE_DEPENDS src/*.cpp src/*.c src/*.h) | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "Minimum OS X deployment version") | ||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Target macOS architectures") | ||
|
||
add_executable(CandyCrisis ${GAME_SOURCES}) | ||
project(${GAME_TARGET} | ||
VERSION ${GAME_VERSION} | ||
LANGUAGES C CXX | ||
) | ||
|
||
target_link_libraries(CandyCrisis ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} SDL2) | ||
#------------------------------------------------------------------------------ | ||
# GLOBAL OPTIONS (BEFORE ADDING SUBDIRECTORIES) | ||
#------------------------------------------------------------------------------ | ||
|
||
if(MSVC) | ||
add_compile_definitions(UNICODE _UNICODE) | ||
|
||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${GAME_TARGET}) | ||
endif() | ||
|
||
#------------------------------------------------------------------------------ | ||
# DEPENDENCIES | ||
#------------------------------------------------------------------------------ | ||
|
||
find_package(SDL2 REQUIRED COMPONENTS main) | ||
|
||
#------------------------------------------------------------------------------ | ||
# GAME SOURCES | ||
#------------------------------------------------------------------------------ | ||
|
||
set(GAME_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
|
||
# Write header file containing version info | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.h.in ${GAME_SRCDIR}/version.h) | ||
|
||
file(GLOB_RECURSE GAME_SOURCES CONFIGURE_DEPENDS ${GAME_SRCDIR}/*.c ${GAME_SRCDIR}/*.cpp) | ||
|
||
file(GLOB_RECURSE GAME_HEADERS CONFIGURE_DEPENDS ${GAME_SRCDIR}/*.h) | ||
|
||
set(GAME_ALL_SOURCES | ||
${GAME_SOURCES} | ||
${GAME_HEADERS} | ||
) | ||
|
||
#------------------------------------------------------------------------------ | ||
# SOURCE GROUPS | ||
#------------------------------------------------------------------------------ | ||
|
||
source_group(TREE ${GAME_SRCDIR} PREFIX "" FILES ${GAME_ALL_SOURCES}) | ||
|
||
#------------------------------------------------------------------------------ | ||
# EXECUTABLE TARGET | ||
#------------------------------------------------------------------------------ | ||
|
||
set(GAME_LIBRARIES ${SDL2_LIBRARIES}) | ||
|
||
if(WIN32) | ||
# "WIN32" here is equivalent to /SUBSYSTEM:WINDOWS for MSVC | ||
add_executable(${GAME_TARGET} WIN32 | ||
${GAME_ALL_SOURCES} | ||
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/${GAME_TARGET}.exe.rc" | ||
) | ||
elseif(APPLE) | ||
add_executable(${GAME_TARGET} MACOSX_BUNDLE | ||
${GAME_ALL_SOURCES} | ||
${GAME_MAC_ICNS} | ||
${SDL2_LIBRARIES} | ||
) | ||
else() | ||
# Math lib, explicitly required on some Linux systems | ||
list(APPEND GAME_LIBRARIES m) | ||
|
||
add_executable(${GAME_TARGET} ${GAME_ALL_SOURCES}) | ||
endif() | ||
|
||
target_include_directories(${GAME_TARGET} PRIVATE | ||
${SDL2_INCLUDE_DIRS} | ||
${GAME_SRCDIR} | ||
) | ||
|
||
target_link_libraries(${GAME_TARGET} ${GAME_LIBRARIES}) | ||
|
||
#------------------------------------------------------------------------------ | ||
# DEFINES | ||
#------------------------------------------------------------------------------ | ||
|
||
add_compile_definitions( | ||
"$<$<CONFIG:DEBUG>:_DEBUG>" | ||
) | ||
|
||
if(WIN32) | ||
target_compile_definitions(${GAME_TARGET} PRIVATE | ||
WIN32_LEAN_AND_MEAN | ||
_CRT_SECURE_NO_WARNINGS # quit whining about snprintf_s | ||
) | ||
endif() | ||
|
||
#------------------------------------------------------------------------------ | ||
# COMPILER OPTIONS | ||
#------------------------------------------------------------------------------ | ||
|
||
if(NOT MSVC) | ||
target_compile_options(${GAME_TARGET} PRIVATE | ||
-Wall | ||
#-Wextra # TODO | ||
#-Wshadow # TODO | ||
-Wno-sign-compare # TODO | ||
-Wno-multichar | ||
-Wno-unknown-pragmas | ||
-Werror=return-type | ||
) | ||
else() | ||
# By default, MSVC may add /EHsc to CMAKE_CXX_FLAGS, which we don't want (we use /EHs below) | ||
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
|
||
# By default, MSVC may add /W3 to CMAKE_CXX_FLAGS, which we don't want (we use /W4 below) | ||
# Note that this is not required with "cmake_minimum_required(VERSION 3.15)" or later | ||
string(REPLACE "/W3" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
string(REPLACE "/W3" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) | ||
|
||
target_compile_options(${GAME_TARGET} PRIVATE | ||
/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 | ||
/wd5105 # see https://developercommunity.visualstudio.com/t/1249671 | ||
) | ||
endif() | ||
|
||
#------------------------------------------------------------------------------ | ||
# PLATFORM-SPECIFIC PACKAGING | ||
#------------------------------------------------------------------------------ | ||
|
||
set_target_properties(${GAME_TARGET} PROPERTIES | ||
#-------------------------------------------------------------------------- | ||
# MSVC/WIN32 | ||
#-------------------------------------------------------------------------- | ||
|
||
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" | ||
VS_DPI_AWARE "PerMonitor" | ||
|
||
#-------------------------------------------------------------------------- | ||
# APPLE | ||
#-------------------------------------------------------------------------- | ||
|
||
# Set framework search path to (App bundle)/Contents/Frameworks so the game can use its embedded SDL2.framework | ||
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks" | ||
|
||
# Explicitly turn off code signing, otherwise downloaded app will be quarantined forever | ||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" | ||
|
||
# Set up Info.plist values | ||
MACOSX_BUNDLE_ICON_FILE "${GAME_TARGET}.icns" # CFBundleIconFile | ||
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_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 | ||
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER ${GAME_MAC_BUNDLE_ID} | ||
|
||
# Don't bother with universal builds when we're working on the debug version | ||
XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] "YES" | ||
|
||
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_ENABLE_HARDENED_RUNTIME "YES" # required for notarization to pass | ||
) | ||
|
||
if(APPLE) | ||
# If we have a code signing identity (CODE_SIGN_IDENTITY environment variable), | ||
# set up the release build for proper code signing | ||
if(NOT "$ENV{CODE_SIGN_IDENTITY}" STREQUAL "") | ||
set_target_properties(${GAME_TARGET} PROPERTIES | ||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY[variant=Release] "$ENV{CODE_SIGN_IDENTITY}" | ||
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM[variant=Release] "$ENV{CODE_SIGN_IDENTITY}" | ||
|
||
# The following is to pass notarization requirements | ||
XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS[variant=Release] "NO" | ||
XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS[variant=Release] "--options=runtime --timestamp" | ||
) | ||
message("Release build will be code signed!") | ||
endif() | ||
|
||
# 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}/CandyCrisisResources ${BUNDLE_CONTENTS_DIR}/Resources | ||
|
||
# High-DPI support in Info.plist | ||
# plutil -replace NSHighResolutionCapable -bool true ${BUNDLE_CONTENTS_DIR}/Info.plist | ||
) | ||
else() | ||
set(APP_PARENT_DIR "$<TARGET_FILE_DIR:${GAME_TARGET}>") | ||
|
||
# Copy assets besides executable | ||
add_custom_command(TARGET ${GAME_TARGET} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/CandyCrisisResources ${APP_PARENT_DIR}/CandyCrisisResources) | ||
endif() | ||
|
||
# Windows-specific libraries | ||
if(WIN32) | ||
# Copy SDL2 DLLs to output folder on Windows for convenience | ||
foreach(DLL ${SDL2_DLLS}) | ||
add_custom_command(TARGET ${GAME_TARGET} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DLL} ${APP_PARENT_DIR}) | ||
endforeach() | ||
|
||
# When installing (cmake --install), copy Visual Studio redistributable DLLs to install location | ||
include(InstallRequiredSystemLibraries) | ||
endif() | ||
|
||
# Copy documentation to output folder | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packaging/ReadMe.txt.in ${CMAKE_CURRENT_BINARY_DIR}/ReadMe.txt) |
Oops, something went wrong.