Skip to content

Commit

Permalink
debug: Use CMAKE_CONFIGURATION_TYPES to set debug build type
Browse files Browse the repository at this point in the history
  • Loading branch information
bwrsandman committed Jan 17, 2025
1 parent 48a8216 commit 65e715e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/reassemble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 12 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -11,6 +13,12 @@ project(bw1-decomp ASM)
set(CMAKE_ASM_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> <CMAKE_ASM_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> /out:<TARGET> <LINK_LIBRARIES>")
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
Expand Down Expand Up @@ -374,10 +382,8 @@ target_compile_options(runblack-reassembled
-target
i686-pc-windows-gnu
-m32
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-g>
)
if (BW1_DECOMP_DEBUG)
target_compile_options(runblack-reassembled PRIVATE "-g")
endif ()
target_link_options(runblack-reassembled
PRIVATE
"-flavor"
Expand All @@ -392,14 +398,9 @@ target_link_options(runblack-reassembled
"/filealign:0x1000"
"/entry:jmp_addr_0x007ca49f"
"/safeseh:no"
"$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:/pdb:$<TARGET_FILE:runblack-reassembled>.pdb>"
"$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:/debug>"
)
if (BW1_DECOMP_DEBUG)
target_link_options(runblack-reassembled
PRIVATE
"/pdb:$<TARGET_FILE:runblack-reassembled>.pdb"
"/debug"
)
endif()

find_program(STRIP strip)
add_custom_command(
Expand All @@ -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 "$<TARGET_FILE:runblack-reassembled>" --output "$<TARGET_FILE:runblack-reassembled>" $<$<BOOL:${BW1_DECOMP_DEBUG}>:"--debug"> $<$<BOOL:${BW1_DECOMP_FORCE_WINDOWED}>:"--turn-off-fullscreen">
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/post_assemble_patch.py --input "$<TARGET_FILE:runblack-reassembled>" --output "$<TARGET_FILE:runblack-reassembled>" $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:"--debug"> $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:"--turn-off-fullscreen">
COMMENT "Patching PE header to match vanilla"
)

Expand Down

0 comments on commit 65e715e

Please sign in to comment.