Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Fix escaping of quotes in response file #15032

Merged
merged 1 commit into from
Sep 1, 2021
Merged
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
12 changes: 2 additions & 10 deletions tools/cmake/mbed_toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@ function(mbed_generate_options_for_linker target output_response_file_path)
"$<TARGET_PROPERTY:${target},INTERFACE_COMPILE_DEFINITIONS>"
)

# Remove macro definitions that contain spaces as the lack of escape sequences and quotation marks
# in the macro when retrieved using generator expressions causes linker errors.
# This includes string macros, array macros, and macros with operations.
# TODO CMake: Add escape sequences and quotation marks where necessary instead of removing these macros.
# Append -D to all macros and quote them as we pass these as response file to cxx compiler
set(_compile_definitions
"$<FILTER:${_compile_definitions},EXCLUDE, +>"
)

# Append -D to all macros as we pass these as response file to cxx compiler
set(_compile_definitions
"$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions}, -D>>"
"$<$<BOOL:${_compile_definitions}>:'-D$<JOIN:${_compile_definitions},' '-D>'>"
Comment on lines -10 to +12
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xc0170 I've tested it with sockets and mesh, both worked fine with both GCC_ARM and ARM compilers. And this also solves problems with macros with spaces inside (e.g. '-DMBED_CONF_LORA_APPLICATION_EUI={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}'), so I removed the previous workaround.

Hopefully it's a permanent fix, let's run CI to test it on more examples!

)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n")
set(${output_response_file_path} @${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE)
Expand Down