mirror of
https://github.com/xemu-project/nxdk_pgraph_tests.git
synced 2024-12-04 00:20:53 +00:00
Prevents multiple objcopy passes from corrupting binary.
This commit is contained in:
parent
2431c96d73
commit
b8a198ac6e
@ -368,6 +368,10 @@ add_executable(
|
|||||||
src/tests/zero_stride_tests.h
|
src/tests/zero_stride_tests.h
|
||||||
${generated_vertex_shaders}
|
${generated_vertex_shaders}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Pull debug info out of the binary into a host-side linked binary.
|
||||||
|
split_debug("${TARGET}")
|
||||||
|
|
||||||
set(EXECUTABLE_BINARY "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.exe")
|
set(EXECUTABLE_BINARY "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.exe")
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
"${TARGET}"
|
"${TARGET}"
|
||||||
|
@ -28,31 +28,30 @@ function(_make_abs_paths list_name)
|
|||||||
set(${list_name} ${ret} PARENT_SCOPE)
|
set(${list_name} ${ret} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# split_debug(executable_file debug_file_variable)
|
# split_debug(executable_target)
|
||||||
#
|
#
|
||||||
# Splits debugging information from the given `executable_file`, generating a companion file ending in ".debug.exe"
|
# Splits debugging information from the given `executable_target`, generating a companion file ending in ".debug.exe".
|
||||||
# Sets `debug_file_variable` in the parent scope to the generated file.
|
|
||||||
function(split_debug)
|
function(split_debug)
|
||||||
if (${ARGC} LESS 1)
|
if (${ARGC} LESS 1)
|
||||||
message(FATAL_ERROR "Missing required 'executable_file' parameter.")
|
message(FATAL_ERROR "Missing required 'executable_target' parameter.")
|
||||||
elseif (${ARGC} LESS 2)
|
|
||||||
message(FATAL_ERROR "Missing required 'debug_file_variable_name' parameter.")
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(exe_file "${ARGV0}")
|
set(executable_target "${ARGV0}")
|
||||||
set(debug_file_variable "${ARGV1}")
|
set(exe_file "${CMAKE_BINARY_DIR}/${executable_target}.exe")
|
||||||
get_filename_component(exe_dirname "${exe_file}" DIRECTORY)
|
get_filename_component(exe_dirname "${CMAKE_BINARY_DIR}/${executable_target}" DIRECTORY)
|
||||||
get_filename_component(exe_basename "${exe_file}" NAME_WE)
|
get_filename_component(exe_basename "${executable_target}" NAME_WE)
|
||||||
set(output "${exe_dirname}/${exe_basename}.debug.exe")
|
set(output "${exe_dirname}/${exe_basename}.debug.exe")
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${output}"
|
TARGET "${executable_target}"
|
||||||
|
POST_BUILD
|
||||||
COMMAND "${CMAKE_COMMAND}" -E copy "${exe_file}" "${output}"
|
COMMAND "${CMAKE_COMMAND}" -E copy "${exe_file}" "${output}"
|
||||||
COMMAND "${CMAKE_OBJCOPY}" --strip-debug "${exe_file}"
|
COMMAND "${CMAKE_OBJCOPY}" --strip-debug "${exe_file}"
|
||||||
COMMAND "${CMAKE_OBJCOPY}" --add-gnu-debuglink="${output}" "${exe_file}"
|
COMMAND "${CMAKE_OBJCOPY}" "--add-gnu-debuglink=${output}" "${exe_file}"
|
||||||
DEPENDS "${exe_file}"
|
COMMENT Splitting debug information to reduce binary size...
|
||||||
|
VERBATIM
|
||||||
|
BYPRODUCTS "${output}"
|
||||||
)
|
)
|
||||||
set("${debug_file_variable}" "${output}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(add_xbe)
|
function(add_xbe)
|
||||||
@ -74,11 +73,6 @@ function(add_xbe)
|
|||||||
set(target "${ARGV0}")
|
set(target "${ARGV0}")
|
||||||
set(exe_file "${ARGV1}")
|
set(exe_file "${ARGV1}")
|
||||||
|
|
||||||
# exe_file will be updated to contain the stripped binary and
|
|
||||||
# exe_file_DEBUG will be created to track the generated debug artifact.
|
|
||||||
split_debug("${exe_file}" exe_file_DEBUG)
|
|
||||||
message("DEBUG FILE: ${exe_file} -> ${exe_file_DEBUG}")
|
|
||||||
|
|
||||||
if (NOT XBE_XBENAME)
|
if (NOT XBE_XBENAME)
|
||||||
set(XBE_XBENAME default.xbe)
|
set(XBE_XBENAME default.xbe)
|
||||||
endif ()
|
endif ()
|
||||||
@ -116,7 +110,7 @@ function(add_xbe)
|
|||||||
"-TITLE:${XBE_TITLE}"
|
"-TITLE:${XBE_TITLE}"
|
||||||
"-OUT:${XBE_OUTPUT_PATH}"
|
"-OUT:${XBE_OUTPUT_PATH}"
|
||||||
"${exe_file}"
|
"${exe_file}"
|
||||||
DEPENDS "${exe_file}" "${exe_file_DEBUG}"
|
DEPENDS "${exe_file}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Copy resources to the staging directory.
|
# Copy resources to the staging directory.
|
||||||
|
Loading…
Reference in New Issue
Block a user