diff options
author | Alex Langford <alangford@apple.com> | 2023-01-26 17:33:33 -0800 |
---|---|---|
committer | Alex Langford <alangford@apple.com> | 2023-02-16 11:18:04 -0800 |
commit | 662548c82683bd8657a3179afee693c4965a3dfd (patch) | |
tree | f1d6df4e4ed17672c186e0d5df551bc5916e8d10 /lldb/cmake | |
parent | 23d43e6977576ed318a9c81cec256d75f5d49ded (diff) | |
download | llvm-662548c82683bd8657a3179afee693c4965a3dfd.tar.gz |
[lldb] Replace SB swig interfaces with API headers
Instead of maintaining separate swig interface files, we can use the API
headers directly. They implement the exact same C++ APIs and we can
conditionally include the python extensions as needed. To remove the
swig extensions from the API headers when building the LLDB
framework, we can use the unifdef tool when it is available. Otherwise
we just copy them as-is.
Differential Revision: https://reviews.llvm.org/D142926
Diffstat (limited to 'lldb/cmake')
-rw-r--r-- | lldb/cmake/modules/LLDBFramework.cmake | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index 2e82f4978667..81fc596ef424 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -75,6 +75,8 @@ file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h) file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h) list(REMOVE_ITEM root_public_headers ${root_private_headers}) +find_program(unifdef_EXECUTABLE unifdef) + set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders) foreach(header ${public_headers} @@ -83,10 +85,19 @@ foreach(header get_filename_component(basename ${header} NAME) set(staged_header ${lldb_header_staging}/${basename}) + if(unifdef_EXECUTABLE) + # unifdef returns 0 when the file is unchanged and 1 if something was changed. + # That means if we successfully remove SWIG code, the build system believes + # that the command has failed and stops. This is undesirable. + set(copy_command ${unifdef_EXECUTABLE} -USWIG -o ${staged_header} ${header} || (exit 0)) + else() + set(copy_command ${CMAKE_COMMAND} -E copy ${header} ${staged_header}) + endif() + add_custom_command( DEPENDS ${header} OUTPUT ${staged_header} - COMMAND ${CMAKE_COMMAND} -E copy ${header} ${staged_header} - COMMENT "LLDB.framework: collect framework header") + COMMAND ${copy_command} + COMMENT "LLDB.framework: collect framework header and remove SWIG macros") list(APPEND lldb_staged_headers ${staged_header}) endforeach() |