Skip to content

Commit e4c7f91

Browse files
mahavirjclaude
andcommitted
fix(thorvg): expand response files in compiler flags for meson
ESP-IDF's latest version uses response files (arguments starting with @) to handle long compiler flag lists. These response file references are embedded in CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS. When passed directly to meson's cross-file, these references fail because: 1. The response files may not exist when meson runs 2. Meson cannot access these files from its build context 3. The paths may be invalid from meson's working directory This commit adds a function to expand response file references before passing flags to meson. If a response file exists, its contents are read and expanded inline. If it doesn't exist, it's skipped (assuming essential flags are provided directly). Fixes the build failure: ERROR: Compiler cannot compile programs. riscv32-esp-elf-g++: error: @"...toolchain/cxxflags": linker input file not found: No such file or directory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 5e6e9ee commit e4c7f91

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

thorvg/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,41 @@ set(compiler_args ${CMAKE_CXX_FLAGS})
5959
separate_arguments(compiler_args)
6060
list(FILTER compiler_args EXCLUDE REGEX "^$")
6161

62+
# Expand response files (arguments starting with @"filename")
63+
# ESP-IDF's latest version uses response files for compiler flags
64+
# These need to be expanded because meson cannot read them from its build context
65+
function(expand_response_files arg_list output_var)
66+
set(expanded_args)
67+
foreach(arg IN LISTS arg_list)
68+
# Check if argument is a response file reference: @"filename" or @filename
69+
if(arg MATCHES "^@\"?(.+)\"?$")
70+
set(response_file "${CMAKE_MATCH_1}")
71+
# Remove quotes if present
72+
string(REGEX REPLACE "^\"(.+)\"$" "\\1" response_file "${response_file}")
73+
# Check if file exists and read its contents
74+
if(EXISTS "${response_file}")
75+
file(READ "${response_file}" file_contents)
76+
# Split file contents into individual arguments
77+
string(REGEX REPLACE "[\r\n]+" ";" file_args "${file_contents}")
78+
separate_arguments(file_args)
79+
list(FILTER file_args EXCLUDE REGEX "^$")
80+
list(APPEND expanded_args ${file_args})
81+
message(STATUS "Expanded response file ${response_file} with ${CMAKE_MATCH_0} arguments")
82+
else()
83+
# Response file doesn't exist yet (created at build time)
84+
# Skip it - essential flags should be provided directly
85+
message(STATUS "Skipping non-existent response file: ${response_file}")
86+
endif()
87+
else()
88+
list(APPEND expanded_args "${arg}")
89+
endif()
90+
endforeach()
91+
set(${output_var} ${expanded_args} PARENT_SCOPE)
92+
endfunction()
93+
94+
expand_response_files("${compiler_args}" compiler_args)
95+
expand_response_files("${linker_args}" linker_args)
96+
6297
message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${linker_args}")
6398
message(STATUS "CMAKE_CXX_FLAGS: ${compiler_args}")
6499

0 commit comments

Comments
 (0)