-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
@LDong-Arm, thank you for your changes. |
Both compilers tested with macros like this? I recall there were issues alike macros but that could be other older issue we fixed. |
I will give netsocket/mesh a try later. If they work, we can run CI to test the change more rigorously. |
e539009
to
9241e86
Compare
# 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>'>" |
There was a problem hiding this comment.
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!
9241e86
to
8c736c1
Compare
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified with #15029
We need to address today license check, I'll continue investigating with the test team |
Please rebase to the latest master to get github workflow update to fix basic checks. I'll restart tests and this will go in. |
We put macros in a response file compile_time_defs.txt and pass it to the compiler. Adding a pair of single quotes around each -D flag ensures macro values are quoted correctly. For example, * String * target_compile_definitions(): either FOO="BAR" or FOO=\"BAR\" * response file: '-DFOO="BAR"' * actual definition: #define FOO "BAR" * Array of integers * target_compile_definitions(): FOO={1, 2, 3} * response file: '-DFOO={1, 2, 3}' * actual definition: #define FOO {1, 2, 3}
8c736c1
to
d4ee3bd
Compare
Pull request has been modified.
Rebased |
CI restarted |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
We put macros in a response file compile_time_defs.txt and pass it to the compiler. Adding a pair of single quotes around each -D flag ensures macro values are quoted correctly.
For example,
target_compile_definitions()
: eitherFOO="BAR"
orFOO=\"BAR\"
'-DFOO="BAR"'
#define FOO "BAR"
target_compile_definitions()
:FOO={1, 2, 3}
'-DFOO={1, 2, 3}'
#define FOO {1, 2, 3}
Impact of changes
Migration actions required
Documentation
None
Pull request type
Test results
Reviewers