Skip to content

Commit

Permalink
win: add sentry crash reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Jul 12, 2022
1 parent 0c7fba5 commit 3471ec7
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 63 deletions.
75 changes: 57 additions & 18 deletions .github/workflows/release.yml
Expand Up @@ -26,7 +26,7 @@ on:
default: false

jobs:
check_date:
check-date:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
Expand All @@ -40,7 +40,7 @@ jobs:
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="1 week" ${{ github.sha }}) && echo "::set-output name=should_run::false"

create_tag:
create-tag:
runs-on: ubuntu-latest
outputs:
release_tag_name: ${{ steps.make-vars.outputs.release_tag_name }}
Expand Down Expand Up @@ -77,11 +77,19 @@ jobs:
echo "::set-output name=release_name::Nightly ${{ steps.current-time.outputs.formattedTime }}"
fi
- name: Setup Sentry CLI
uses: mathieu-bour/setup-sentry-cli@1.2.0
with:
token: ${{ secrets.SENTRY_TOKEN }}
organization: zeldaclassic
project: zelda-classic
- run: sentry-cli releases new ${{ steps.make-vars.outputs.release_tag_name }}

release-win:
needs:
- check_date
- create_tag
if: ${{ needs.check_date.outputs.should_run != 'false' }}
- check-date
- create-tag
if: ${{ needs.check-date.outputs.should_run != 'false' }}

runs-on: windows-2022
strategy:
Expand All @@ -104,29 +112,39 @@ jobs:
uses: crazy-max/ghaction-chocolatey@v1
with:
args: install .github/dependencies.config -y
- name: Setup Sentry CLI
uses: mathieu-bour/setup-sentry-cli@1.2.0
with:
token: ${{ secrets.SENTRY_TOKEN }}
organization: zeldaclassic
project: zelda-classic

- run: bash .github/workflows/configure-signatures.sh win ${{ inputs.versiontype }} ${{ inputs.full_release }} ${{ inputs.number }}
- run: cmake . -A ${{ matrix.arrays.arch }}
- run: cmake --build . --config Release
- run: cmake . -A ${{ matrix.arrays.arch }} -DWANT_SENTRY=ON -DSENTRY_RELEASE_TAG=${{ needs.create-tag.outputs.release_tag_name }}
- run: cmake --build . --config RelWithDebInfo
- run: mv RelWithDebInfo Release
- run: echo y | ./buildpack.bat
working-directory: output/_auto
- run: mv output/_auto/buildpack.zip "output/_auto/${{ needs.create_tag.outputs.release_tag_name }}-${{ matrix.arrays.name }}.zip"
- run: mv output/_auto/buildpack.zip "output/_auto/${{ needs.create-tag.outputs.release_tag_name }}-${{ matrix.arrays.name }}.zip"

- name: Upload debugging symbols
run: sentry-cli upload-dif ${{ needs.create-tag.outputs.release_tag_name }} --include-sources --wait Release

- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.create_tag.outputs.release_name }}
tag_name: ${{ needs.create_tag.outputs.release_tag_name }}
files: "output/_auto/${{ needs.create_tag.outputs.release_tag_name }}-${{ matrix.arrays.name }}.zip"
name: ${{ needs.create-tag.outputs.release_name }}
tag_name: ${{ needs.create-tag.outputs.release_tag_name }}
files: "output/_auto/${{ needs.create-tag.outputs.release_tag_name }}-${{ matrix.arrays.name }}.zip"
prerelease: ${{ !inputs.full_release }}
fail_on_unmatched_files: true
generate_release_notes: true

release-mac:
needs:
- check_date
- create_tag
if: ${{ needs.check_date.outputs.should_run != 'false' }}
- check-date
- create-tag
if: ${{ needs.check-date.outputs.should_run != 'false' }}

runs-on: macos-12

Expand All @@ -150,14 +168,35 @@ jobs:

- run: ./buildpack_osx.sh
working-directory: output/_auto
- run: mv output/_auto/ZeldaClassic.dmg "output/_auto/${{ needs.create_tag.outputs.release_tag_name }}-mac.dmg"
- run: mv output/_auto/ZeldaClassic.dmg "output/_auto/${{ needs.create-tag.outputs.release_tag_name }}-mac.dmg"

- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.create_tag.outputs.release_name }}
tag_name: ${{ needs.create_tag.outputs.release_tag_name }}
files: "output/_auto/${{ needs.create_tag.outputs.release_tag_name }}-mac.dmg"
name: ${{ needs.create-tag.outputs.release_name }}
tag_name: ${{ needs.create-tag.outputs.release_tag_name }}
files: "output/_auto/${{ needs.create-tag.outputs.release_tag_name }}-mac.dmg"
prerelease: ${{ !inputs.full_release }}
fail_on_unmatched_files: true
generate_release_notes: true

finalize:
needs:
- create-tag
- release-win
- release-mac
runs-on: ubuntu-latest

steps:
- name: git clone
uses: actions/checkout@v2
- name: Setup Sentry CLI
uses: mathieu-bour/setup-sentry-cli@1.2.0
with:
token: ${{ secrets.SENTRY_TOKEN }}
organization: zeldaclassic
project: zelda-classic
- name: Finalize sentry
run: |
sentry-cli releases set-commits ${{ needs.create-tag.outputs.release_tag_name }} --auto
sentry-cli releases finalize ${{ needs.create-tag.outputs.release_tag_name }}
77 changes: 50 additions & 27 deletions CMakeLists.txt
@@ -1,9 +1,11 @@
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE)
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo CACHE STRING INTERNAL FORCE)
project (ZeldaClassic)

set(USE_PCH FALSE CACHE BOOL "Use precompiled headers")
set(UNITY_BUILD FALSE CACHE BOOL "Unity build")
set(WANT_SENTRY FALSE CACHE BOOL "Include Sentry for crash dump handling")
set(SENTRY_RELEASE_TAG "" CACHE STRING "Release tag for sentry")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -37,7 +39,7 @@ function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
FILE(APPEND ${unit_build_file} "#include \"${CMAKE_SOURCE_DIR}/src/precompiled.h\"\n")
# Add include statement for each translation unit
foreach(source_file ${files} )
FILE( APPEND ${unit_build_file} "#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n")
FILE( APPEND ${unit_build_file} "#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n")
endforeach(source_file)
# Complement list of translation units with the name of ub
set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE)
Expand Down Expand Up @@ -76,7 +78,7 @@ if(NOT allegro5_POPULATED)
add_subdirectory(${allegro5_SOURCE_DIR} ${allegro5_BINARY_DIR} EXCLUDE_FROM_ALL)
# Allegro 5 CMakeLists sets CMAKE_CONFIGURATION_TYPES in a way that doesn't work for us,
# so set it back to our value.
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE)
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo CACHE STRING INTERNAL FORCE)
endif()

# These include files are typically copied into the correct places via allegro's install
Expand Down Expand Up @@ -120,7 +122,7 @@ include_directories(./include/zlib123)
include_directories(./src)

if(MSVC)
include_directories(./src/msvcCompat)
# include_directories(./src/msvcCompat)
endif()

set(ZCSOUNDSOURCES
Expand Down Expand Up @@ -441,16 +443,16 @@ endif()

add_executable(zelda ${ZELDA_CORE_SOURCES} ${ZELDA_GUI_SOURCES} ${ZELDA_SPRITE_SOURCES} ${ZELDA_SUBSCREEN_SOURCES} ${ZELDA_SCRIPTING_SOURCES} ${ZELDAEXTRASOURCES} ${ZELDA_MODULES})
target_compile_definitions(zelda PRIVATE IS_PLAYER)
target_link_libraries(zelda allegro_with_legacy)
target_link_libraries(zelda PRIVATE allegro_with_legacy)

if(WIN32)
target_link_libraries(zelda zconsolelogger zcsound winmm ${IMAGELIBS} ${ZELDALIBSEXTRA})
target_link_libraries(zelda PRIVATE zconsolelogger zcsound winmm ${IMAGELIBS} ${ZELDALIBSEXTRA})
elseif(LINUX)
target_link_libraries(zelda zconsolelogger zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA})
target_link_libraries(zelda PRIVATE zconsolelogger zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA})
elseif(APPLE)
target_link_libraries(zelda zconsolelogger zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA})
target_link_libraries(zelda PRIVATE zconsolelogger zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA})
endif()
target_link_libraries(zelda allegro_with_legacy)
target_link_libraries(zelda PRIVATE allegro_with_legacy)

if(MSVC AND USE_PCH)
set_target_properties(zelda PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h /Fp\"${ZCPrecompiledBinary}\"" OBJECT_DEPENDS "${ZCPrecompiledBinary}")
Expand Down Expand Up @@ -484,7 +486,7 @@ find_package(Boost 1.74.0)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_definitions(-DHAS_BOOST)
add_executable(zquest ${ZQUEST_CORE_SOURCES} ${ZQUEST_GUI_SOURCES} ${ZQUEST_MISC_SOURCES} ${ZQUESTEXTRASOURCES} ${ZQUEST_MODULES})
add_executable(zquest ${ZQUEST_CORE_SOURCES} ${ZQUEST_GUI_SOURCES} ${ZQUEST_MISC_SOURCES} ${ZQUESTEXTRASOURCES} ${ZQUEST_MODULES})

target_link_libraries(zquest PUBLIC allegro_with_legacy zconsolelogger zcsound ${IMAGELIBS} ${ZQUESTLIBSEXTRA})

Expand Down Expand Up @@ -532,7 +534,7 @@ elseif(LINUX)
endif()

add_executable(zlauncher ${LAUNCHER_SOURCES} ${LAUNCHER_GUI_SOURCES} ${LAUNCHEREXTRASOURCES})
target_link_libraries(zlauncher allegro_with_legacy zconsolelogger ${LAUNCHERLIBSEXTRA})
target_link_libraries(zlauncher PRIVATE allegro_with_legacy zconsolelogger ${LAUNCHERLIBSEXTRA})
target_compile_definitions(zlauncher PRIVATE IS_LAUNCHER)

#############################################################
Expand All @@ -542,31 +544,36 @@ target_compile_definitions(zlauncher PRIVATE IS_LAUNCHER)
add_executable(al5_example EXCLUDE_FROM_ALL src/al5_example_main.c)
target_include_directories(al5_example PUBLIC ${allegro5_SOURCE_DIR}/include)
target_include_directories(al5_example PUBLIC ${allegro5_BINARY_DIR}/include)
target_link_libraries(al5_example PUBLIC allegro_with_legacy allegro_font allegro_primitives)

#############################################################
# Visual Studio
#############################################################

set(zc_targets zquest zelda zlauncher zcsound zscript zconsolelogger)

if (WIN32)
set_property(TARGET ${zc_targets} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "$(ProjectDir)$(Configuration)")

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_target_properties(zcsound gme dumb aldmb almp3 alogg PROPERTIES FOLDER Sound)
set_target_properties(allegro allegro_audio allegro_image allegro_font allegro_main allegro_primitives allegro_dialog allegro-legacy al5img algif5 al5_example PROPERTIES FOLDER Allegro)
set_target_properties(zconsole zconsolelogger PROPERTIES FOLDER ZConsole)
endif()
target_link_libraries(al5_example PRIVATE allegro_with_legacy allegro_font allegro_primitives)

#############################################################
# Misc.
#############################################################

set(zc_targets zquest zelda zlauncher zcsound zscript zconsolelogger)
set(zc_apps zquest zelda zlauncher)
set(zc_warnings
-Werror=format
)

foreach(target IN LISTS zc_apps)
target_compile_definitions(${target} PRIVATE ZC_APP_NAME="${target}")
endforeach()

if(WANT_SENTRY)
set(SENTRY_VERSION 0.4.18)
set(SENTRY_BACKEND crashpad)
set(SENTRY_BUILD_SHARED_LIBS OFF)
FetchContent_Declare(sentry URL https://github.com/getsentry/sentry-native/releases/download/${SENTRY_VERSION}/sentry-native.zip)
FetchContent_MakeAvailable(sentry)

foreach(target IN LISTS zc_apps)
target_link_libraries(${target} PRIVATE sentry)
target_compile_definitions(${target} PRIVATE HAS_SENTRY)
target_compile_definitions(${target} PRIVATE SENTRY_RELEASE_TAG="${SENTRY_RELEASE_TAG}")
endforeach()
endif()

if (WIN32)
list(APPEND zc_targets zconsole)
endif()
Expand All @@ -583,3 +590,19 @@ foreach(target IN LISTS zc_targets)
target_compile_options(${target} PRIVATE ${zc_warnings})
endif()
endforeach()

#############################################################
# Visual Studio
#############################################################

if (WIN32)
set_property(TARGET ${zc_targets} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "$(ProjectDir)$(Configuration)")

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_target_properties(zcsound gme dumb aldmb almp3 alogg PROPERTIES FOLDER Sound)
set_target_properties(allegro allegro_audio allegro_image allegro_font allegro_main allegro_primitives allegro_dialog allegro-legacy al5img algif5 al5_example PROPERTIES FOLDER Allegro)
set_target_properties(zconsole zconsolelogger PROPERTIES FOLDER ZConsole)
if(WANT_SENTRY)
set_target_properties(crashpad_client crashpad_compat crashpad_getopt crashpad_handler crashpad_handler_lib crashpad_minidump crashpad_snapshot crashpad_tools crashpad_util crashpad_zlib mini_chromium sentry PROPERTIES FOLDER Sentry)
endif()
endif()
1 change: 1 addition & 0 deletions output/_auto/buildpack.bat
Expand Up @@ -31,6 +31,7 @@ copy /y "%rel%\zquest.exe" "%nb%\zquest.exe" >>%log%
copy /y "%rel%\zscript.exe" "%nb%\zscript.exe" >>%log%
copy /y "%rel%\zlauncher.exe" "%nb%\zlauncher.exe" >>%log%
copy /y "%rel%\zconsole.exe" "%nb%\zconsole.exe" >>%log%
copy /y "%rel%\crashpad_handler.exe" "%nb%\crashpad_handler.exe" >>%log%
copy /y "%rel%\*.dll" "%nb%" >>%log%

echo Copying 'changelog.txt'...
Expand Down

0 comments on commit 3471ec7

Please sign in to comment.