-
-
Notifications
You must be signed in to change notification settings - Fork 646
Description
What's your question?
Currently, gmake2 escapes spaces in arguments to buildcommands. For an example, look at test_gmake2_file_rules.lua:
function suite.propertydefinitionSeparator()
rules { "TestRule" }
files { "test.rule", "test2.rule", "test3.rule", "test4.rule" }
filter "files:test.rule"
testRuleVars {
TestListProperty = { "testValue1", "testValue2" }
}
filter "files:test2.rule"
testRuleVars {
TestListPropertyWithSwitch = { "testValue1", "testValue2" }
}
...
prepare()
test.capture [[
# File Rules
# #############################################
test.obj: test.rule
@echo Rule-ing test.rule
$(SILENT) dorule testValue1\ testValue2 "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
$(SILENT) dorule -StestValue1\ -StestValue2 "test2.rule"
...
]]
endThis makes it so lists/strings, if contain spaces, are escaped, and -StestValue1\ -StestValue2 becomes a single argument: -S"testValue1 -StestValue2". Is this intended? Perhaps, it should not be like that? Or, shouldnt it be atleast customizable? So i.e. if you dont want it to be escaped, you just place a flag in the property definition.
Consider a case:
You have a property definition for compiler defines that needs to be split into individual arguments:
-D define1 value1 -D define2 value2
I would personally create a list of definitions, something like { "define1 value1", "define2 value2" },
but that would not work, because it would translate into something like -D define1\ value1\ -D define2\ value2.
Activity
nickclark2016 commentedon Sep 4, 2022
For defines specifically, we don't really support setting define values at the current time, just setting if the define exists or not. There is processing done on defines for each platform, as we'd need to format them correctly for gmake2, VS, etc. Supporting defines with values would definitely add a bit of complexity to that, and I'm not 100% convinced that "name value" would be the best approach at this time.
In the general, I think you raise a good point on if we need to do a
\on each space, or if that only makes sense in the cases where there is a space in the value list, etc. This is something that I'm just not 100% sure on.Is this behavior something that is causing you issues currently?
nickclark2016 commentedon Sep 4, 2022
For defines specifically, we don't really support setting define values at the current time, just setting if the define exists or not. There is processing done on defines for each platform, as we'd need to format them correctly for gmake2, VS, etc. Supporting defines with values would definitely add a bit of complexity to that, and I'm not 100% convinced that "name value" would be the best approach at this time.
In the general, I think you raise a good point on if we need to do a
\on each space, or if that only makes sense in the cases where there is a space in the value list, etc. This is something that I'm just not 100% sure on.Is this behavior something that is causing you issues currently?
artemking4 commentedon Sep 4, 2022
It did, but i solved this using something very hacky - just removing the backslashes in tokens.
nickclark2016 commentedon Sep 4, 2022
Which behavior did it solve? Defines?
artemking4 commentedon Sep 4, 2022
Yes
nickclark2016 commentedon Sep 4, 2022
Right now, that's not a use case we support. Let's narrow scope on this and figure out how to solve that specific use case for a feature request.
artemking4 commentedon Sep 4, 2022
I also encountered the same problem when trying to add indentation customization.
Here is some context:
I am using premake to generate makefiles for lua compilation using Reuh/candran, it has an indentation option that is defined by spaces. I.e.
--indentation " ". I could not use spaces in there, so i had to do another hack using(" "):rep(...)artemking4 commentedon Sep 4, 2022
Sure, its not that big of a deal anyways
nickclark2016 commentedon Sep 4, 2022
Okay, after some brain storming, I've come up with a few options:
Option 1:
No support of defines and setting their values (current)
Option 2:
In the GMake2 exporter, we'd get the following flags:
Thoughts?
artemking4 commentedon Sep 4, 2022
Hmm, this seems rather good
But here is another problem: what if you want to have different defines for different types of files? And how would you define in a rule that it does support defines? And how would you then use it in the buildcommands?
nickclark2016 commentedon Sep 6, 2022
Defines for different types of files are supported with filters (assuming the toolchain supports it). That said, I'm curious, does this work for defines currently?
Jarod42 commentedon Sep 6, 2022
For
defines, I already opened #1521 for space/quote/other special char (especially as behavior differ between premake4 and premake5).For
rulesandswitch, my testing project also has avoid space (whereas using space might make sense). So for me value should not be escaped, (can still be surrounded by quote).For list, it seems strange to escape space IMO.
And it should be coherent for all generators, not specific to gmake2 ;-)
nickclark2016 commentedon Sep 6, 2022
That issue is a throwback. I'll take a look through it, because I don't remember what we discussed there.