From bca3ee0c6440d17ea0af8318cc5ac821a4137f1a Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova 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 | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index bbd717a982cf3..adc50e493bc48 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -70,15 +70,21 @@ 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}) +# Glob all necessary header files from source and place them into a list. +# These headers will then be collected for the framework and placed in the +# FrameworkHeaders staging directory. +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_staging_list ${public_headers} ${generated_public_headers} ${root_public_headers}) + +set(lldb_framework_header_staging_dir ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders) +foreach(header ${lldb_framework_header_staging_list}) get_filename_component(basename ${header} NAME) - set(staged_header ${lldb_framework_header_staging}/${basename}) + set(staged_header ${lldb_framework_header_staging_dir}/${basename}) if(unifdef_EXECUTABLE) # unifdef returns 0 when the file is unchanged and 1 if something was changed. @@ -106,9 +112,9 @@ add_dependencies(liblldb-resource-headers liblldb-header-staging) add_dependencies(liblldb liblldb-resource-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}/*) +file(GLOB lldb_framework_staged_headers ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/*.h) foreach(header ${lldb_framework_header_staging_list}) set(input_header ${header}) @@ -116,7 +122,7 @@ foreach(header ${lldb_framework_header_staging_list}) set(output_header $/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()