https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/148736
>From 577cc56f48f8cbaba3c1af4a153cbd3be2216246 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova <chelsea_cassan...@apple.com> Date: Mon, 14 Jul 2025 16:58:23 -0500 Subject: [PATCH] [lldb][framework] Glob headers from source for framework When gathering the headers to fix up and place in LLDB.framework, we were previously globbing the header files from a location in the build directory. This commit changes this to glob from the source directory instead, as we were globbing from the build directory without ensuring that the necessary files were actually in that location before globbing.f --- lldb/cmake/modules/LLDBFramework.cmake | 49 +++++++++----------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index bbd717a982cf3..b2d490313582c 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -70,33 +70,6 @@ endif() find_program(unifdef_EXECUTABLE unifdef) -# All necessary header files will be staged in the include directory in the build directory, -# so just copy the files from there into the framework's staging directory. -set(lldb_build_dir_header_staging "${CMAKE_BINARY_DIR}/include/lldb") -set(lldb_framework_header_staging "${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders") -file(GLOB lldb_build_dir_header_staging_list ${lldb_build_dir_header_staging}/*) -foreach(header ${lldb_build_dir_header_staging_list}) - - get_filename_component(basename ${header} NAME) - set(staged_header ${lldb_framework_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 ${copy_command} - COMMENT "LLDB.framework: collect framework header and remove SWIG macros") - - list(APPEND lldb_staged_headers ${staged_header}) -endforeach() - # Wrap output in a target, so lldb-framework can depend on it. add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums ${lldb_staged_headers}) set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "LLDB/Resources") @@ -105,18 +78,30 @@ set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "LLDB/Resources add_dependencies(liblldb-resource-headers liblldb-header-staging) add_dependencies(liblldb liblldb-resource-headers) +# Glob all necessary header files from source and place them into a list. +file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) +set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h) +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}) +set(lldb_framework_header_list ${public_headers} ${generated_public_headers} ${root_public_headers}) + +add_custom_target(lldb-fixup-all-headers) +add_dependencies(liblldb lldb-fixup-all-headers) + # Take the headers from the staging directory and fix up their includes for the framework. -# Then write them to the output directory. +# Then write them to the framework itself. # Also, run unifdef to remove any specified guards from the header files. -file(GLOB lldb_framework_header_staging_list ${lldb_framework_header_staging}/*) -foreach(header ${lldb_framework_header_staging_list}) +foreach(header ${lldb_framework_header_list}) set(input_header ${header}) - get_filename_component(header_basename ${input_header} NAME) + get_filename_component(header_basename ${header} NAME) + add_custom_target(lldb-framework-fixup-header-${header_basename} DEPENDS ${header}) + add_dependencies(lldb-fixup-all-headers lldb-framework-fixup-header-${header_basename}) set(output_header $<TARGET_FILE_DIR:liblldb>/Headers/${header_basename}) add_custom_command(TARGET liblldb POST_BUILD - COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i ${input_header} -o ${output_header} -p ${unifdef_EXECUTABLE} USWIG + COMMAND "${Python3_EXECUTABLE}" ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i ${input_header} -o ${output_header} -p ${unifdef_EXECUTABLE} USWIG COMMENT "LLDB.framework: Fix up and copy framework headers" ) endforeach() _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits