From 65e715e19ad19f9e80297e2de16f8b002b60d1e0 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Sat, 28 Dec 2024 18:42:55 -0500 Subject: [PATCH] debug: Use CMAKE_CONFIGURATION_TYPES to set debug build type --- .github/workflows/reassemble.yml | 4 ++-- src/CMakeLists.txt | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/reassemble.yml b/.github/workflows/reassemble.yml index bbcdcbf..1c54ba2 100644 --- a/.github/workflows/reassemble.yml +++ b/.github/workflows/reassemble.yml @@ -41,7 +41,7 @@ jobs: - name: Build bw1-decomp project run: | - cmake -Ssrc -Bbuild -G Ninja -DCMAKE_LINKER="${{ github.workspace }}/llvm/bin/lld${{ runner.os == 'Windows' && '.exe' || '' }}" -DCMAKE_ASM_COMPILER="${{ github.workspace }}/llvm/bin/clang${{ runner.os == 'Windows' && '.exe' || '' }}" + cmake -Ssrc -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_LINKER="${{ github.workspace }}/llvm/bin/lld${{ runner.os == 'Windows' && '.exe' || '' }}" -DCMAKE_ASM_COMPILER="${{ github.workspace }}/llvm/bin/clang${{ runner.os == 'Windows' && '.exe' || '' }}" cmake --build build - name: Verify MD5 sum of resulting binary @@ -66,7 +66,7 @@ jobs: - name: Build bw1-decomp project (Debug) run: | - cmake -Ssrc -Bbuild_debug -G Ninja -DCMAKE_LINKER="${{ github.workspace }}/llvm/bin/lld${{ runner.os == 'Windows' && '.exe' || '' }}" -DCMAKE_ASM_COMPILER="${{ github.workspace }}/llvm/bin/clang${{ runner.os == 'Windows' && '.exe' || '' }}" -DBW1_DECOMP_DEBUG=ON -DBW1_DECOMP_FORCE_WINDOWED=ON + cmake -Ssrc -Bbuild_debug -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_LINKER="${{ github.workspace }}/llvm/bin/lld${{ runner.os == 'Windows' && '.exe' || '' }}" -DCMAKE_ASM_COMPILER="${{ github.workspace }}/llvm/bin/clang${{ runner.os == 'Windows' && '.exe' || '' }}" cmake --build build_debug - name: Upload debug version diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a999d4..25c5e43 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.30) project(bw1-decomp ASM) +set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release" CACHE STRING "Available build configurations" FORCE) + # WARNING This cmake script assumes that it's configured with CMAKE_ASM_COMPILER as a PATCHED clang and CMAKE_LINKER as llvm's lld. # If the wrong assembler is used, then there won't be the correct object code generated (e.g. register displacements might be of different sizes or opcodes may vary) and # some of the `.s` custom language extensions will not assemble. @@ -11,6 +13,12 @@ project(bw1-decomp ASM) set(CMAKE_ASM_LINK_EXECUTABLE " /out: ") set(CMAKE_ASM_USE_RESPONSE_FILE_FOR_OBJECTS 1) +set(CMAKE_ASM_FLAGS_DEBUG "") +set(CMAKE_ASM_FLAGS_MINSIZEREL "") +set(CMAKE_ASM_FLAGS_RELWITHDEBINFO "") +set(CMAKE_ASM_FLAGS_RELEASE "") +set(CMAKE_DEPFILE_FLAGS_ASM "") + set(SOURCES asm/unprocessed/runblack.reassemble.0000.00401000-00401140.asm asm/unprocessed/runblack.reassemble.0002.00401140-004011d0.asm @@ -374,10 +382,8 @@ target_compile_options(runblack-reassembled -target i686-pc-windows-gnu -m32 + $<$,$>:-g> ) -if (BW1_DECOMP_DEBUG) - target_compile_options(runblack-reassembled PRIVATE "-g") -endif () target_link_options(runblack-reassembled PRIVATE "-flavor" @@ -392,14 +398,9 @@ target_link_options(runblack-reassembled "/filealign:0x1000" "/entry:jmp_addr_0x007ca49f" "/safeseh:no" + "$<$,$>:/pdb:$.pdb>" + "$<$,$>:/debug>" ) -if (BW1_DECOMP_DEBUG) - target_link_options(runblack-reassembled - PRIVATE - "/pdb:$.pdb" - "/debug" - ) -endif() find_program(STRIP strip) add_custom_command( @@ -413,7 +414,7 @@ find_package(Python3 REQUIRED) add_custom_command( TARGET runblack-reassembled POST_BUILD - COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/post_assemble_patch.py --input "$" --output "$" $<$:"--debug"> $<$:"--turn-off-fullscreen"> + COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/post_assemble_patch.py --input "$" --output "$" $<$,$>:"--debug"> $<$,$>:"--turn-off-fullscreen"> COMMENT "Patching PE header to match vanilla" )