Fix a bug with using spaces in add_defines values#3
Fix a bug with using spaces in add_defines values#3daviwil wants to merge 2 commits intoxmake-io:masterfrom
add_defines values#3Conversation
e754f7d to
25b9563
Compare
|
It will break on ci. |
25b9563 to
7ec101e
Compare
Check if it is |
|
Yep, I'll try that. I'm now dealing with another issue where one of the changes I made is breaking how other values are read out of the target map. Looking for a solution now. |
|
@waruqi OK, I have solution that works now. Let me know if you think there are any possible issues with how I'm "escaping" the spaces in the define string. I'm using a sentinel value of |
38a4992 to
912340f
Compare
|
That particular system configuration must not like the space in the |
|
I tested it, it does not work for my xmake/tbox. git clone https://github.com/tboox/tbox
./configure
make
make: *** Waiting for unfinished jobs....
src/tbox/utils/dump.c:39:5: error: use of undeclared identifier 'tbox'
tb_trace_i("");
^ |
|
Thanks! I'll adjust it and use your repo to verify. |
|
OK, I'm not sure how to proceed here, let me see if I can explain the factors at play:
In my opinion, the default behavior (always escaping quotes) might be surprising to users who want to pass a string containing spaces to a My recommendation would be to remove auto-escaping and for It's certainly uglier and slightly inconvenient, but at least it enables the Do you think there's a reasonable way to solve this problem? How does the Lua version of If you're willing to remove auto-escaping of |
For xmake, it does not splice arguments to generate a string command, but passes all the argument items directly into execv as a table list so, string escaping can be avoided. |
|
xmake.sh is a lightweight version of the xmake implementation, it is not used to handle complex things. Calling string_replace on each defines entry is very slow, as it calls the so we need only use It works for me. I have improved it. |
|
OK, I'm fine with using I just tried it out in my project and |
I ran into an issue with xmake.sh while trying to add a more complex define in my
xmake.shscript, here's an example:The goal is to have the flag
-DIMGUI_IMPL_API="extern \"C\" "added to all compiler invocations, but the current code inmasterfor theconfigurescript ends up splitting theadd_definesvalue based on spaces so thecflagsend up looking like this:After my changes, they now look like this:
This is still not right, however! The quotation marks are escaped when they shouldn't be in this case. The C compiler can't cope with them when
IMGUI_IMPL_APIgets used in source files.I noticed that in
_get_abstract_flag_for_gcc_clangall quotation marks are explicitly escaped fordefinesusingstring_replace "${value}" '"' '\\\"'; value="${_ret}". Is there a way to disable this behavior in cases when the quotation marks should be written out literally?