Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ include(cmake/AugmentExclusions.cmake)
include(cmake/AugmentCodegen.cmake)
include(cmake/AugmentManifest.cmake)

# Generates the exclusions header required by augment itself when building
# standalone. Consumers generate their own exclusions independently
# through augment_manifest().
augment_generate_exclusions(TARGET augment)

# == Examples ==
if(AUGMENT_BUILD_EXAMPLES)
add_subdirectory(examples)
Expand Down
7 changes: 1 addition & 6 deletions cmake/AugmentExclusions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function(augment_generate_exclusions)
message(FATAL_ERROR "[augment_generate_exclusions] TARGET is required")
endif()

set(_out_dir "${CMAKE_BINARY_DIR}/augment_generated")
set(_out_dir "${CMAKE_CURRENT_BINARY_DIR}/augment_generated")
set(_out_header "${_out_dir}/augment_exclusions.hpp")

set(_prefix_file "${CMAKE_CURRENT_BINARY_DIR}/_augment_prefix_excl.txt")
Expand Down Expand Up @@ -134,9 +134,4 @@ function(augment_generate_exclusions)
set_target_properties(${AGE_TARGET} PROPERTIES
AUGMENT_EXCLUSIONS_HEADER "${_out_header}"
)

if(TARGET augment)
target_include_directories(augment PRIVATE "${_out_dir}")
add_dependencies(augment ${AGE_TARGET}_augment_exclusions)
endif()
endfunction()
43 changes: 32 additions & 11 deletions cmake/AugmentManifest.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
if(NOT DEFINED AUGMENT_EXTRACT_SCRIPT)
set(AUGMENT_EXTRACT_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/tools/extractor/extract.py"
set(AUGMENT_EXTRACT_SCRIPT
"${CMAKE_CURRENT_LIST_DIR}/../tools/extractor/extract.py"
CACHE FILEPATH "Path to extract.py")
endif()

function(augment_manifest)
cmake_parse_arguments(AM "SEPARATE_TARGET;REGENERATE_AST"
"TARGET;OUTPUT;COMPILE_COMMANDS;PROJECT_ROOT;REGISTRY_OUT;PCH_OUT;AST_MANIFEST_HINT_DIR"
"TARGET;OUTPUT;BINARY;BINARY_STAMP;COMPILE_COMMANDS;PROJECT_ROOT;REGISTRY_OUT;PCH_OUT;AST_MANIFEST_HINT_DIR"
"EXCLUDE;EXCLUDE_PREFIX;EXCLUDE_PATH"
${ARGN})
find_package(Python3 REQUIRED COMPONENTS Interpreter)
Expand Down Expand Up @@ -41,22 +42,36 @@ function(augment_manifest)
endforeach()
endif()

set(_target_bin $<TARGET_FILE:${AM_TARGET}>)
if(AM_BINARY)
set(_target_bin "${AM_BINARY}")
else()
set(_target_bin $<TARGET_FILE:${AM_TARGET}>)
endif()

if(WIN32 AND MSVC)
target_compile_options(${AM_TARGET} PRIVATE
$<$<NOT:$<OR:$<CONFIG:RelWithDebInfo>,$<CONFIG:Debug>>>:/Zi>
)
set(_extract_src "$<TARGET_PDB_FILE:${AM_TARGET}>")
set(_fmt_arg "--debug-format" "pdb")
else()
target_compile_options(${AM_TARGET} PRIVATE
$<$<NOT:$<OR:$<CONFIG:RelWithDebInfo>,$<CONFIG:Debug>>>:-g>
)
set(_extract_src "${_target_bin}")
set(_fmt_arg "--debug-format" "dwarf")
endif()

if(TARGET ${AM_TARGET})
get_target_property(_target_imported ${AM_TARGET} IMPORTED)

if(NOT _target_imported)
if(WIN32 AND MSVC)
target_compile_options(${AM_TARGET} PRIVATE
$<$<NOT:$<OR:$<CONFIG:RelWithDebInfo>,$<CONFIG:Debug>>>:/Zi>
)
else()
target_compile_options(${AM_TARGET} PRIVATE
$<$<NOT:$<OR:$<CONFIG:RelWithDebInfo>,$<CONFIG:Debug>>>:-g>
)
endif()
endif()
endif()

cmake_path(GET AUGMENT_EXTRACT_SCRIPT PARENT_PATH _extract_script_dir)
cmake_path(GET _extract_script_dir PARENT_PATH _extract_tools_dir)
set(_py_env
Expand Down Expand Up @@ -167,13 +182,19 @@ function(augment_manifest)
list(APPEND _phase2_cmd ${_excl_flags})
endif()

if(AM_BINARY_STAMP)
set(_binary_dep "${AM_BINARY_STAMP}")
elseif(NOT AM_BINARY)
set(_binary_dep "${_target_bin}")
endif()

if(APPLE)
set(_dbg "${_target_bin}.dSYM")
add_custom_command(
OUTPUT "${_agmf_out}" "${_json_out}"
COMMAND dsymutil "${_target_bin}" -o "${_dbg}"
COMMAND ${_phase2_cmd} "--binary" "${_dbg}"
DEPENDS "${_target_bin}"
DEPENDS "${_binary_dep}"
COMMENT "augment: phase2 RVA extraction + pack for ${AM_TARGET}"
USES_TERMINAL
VERBATIM
Expand All @@ -188,7 +209,7 @@ function(augment_manifest)
OUTPUT "${_agmf_out}" "${_json_out}"
COMMAND ${_phase2_cmd}
${_strip_cmd}
DEPENDS "${_target_bin}"
DEPENDS "${_binary_dep}"
COMMENT "augment: phase2 RVA extraction + pack for ${AM_TARGET}"
USES_TERMINAL
VERBATIM
Expand Down
Loading