What steps will reproduce the problem?
Try to use gyp+ninja with a copies rule to copy Foo$Bar.class or an action to
rm Foo$Bar.class.
What is the expected output? What do you see instead?
The copies rule produces an AssertionError at gyp time. The rm action fails at
build time as it tries to remove Foo.class.
What version of the product are you using? On what operating system?
gyp revision 1525, Ubuntu 12.04 x86_64
# The following gyp file demonstrates the two errors described above and
several failed workarounds.
{
'targets': [
{
'target_name': 'All',
'type': 'none',
# This fails at gyp time with an AssertionError.
#'copies': [
# {
# 'destination': 'dst_dir',
# 'files': ['Foo$Bar.class'],
# },
#],
'actions': [
# This generates the ninja command 'touch "Foo$Bar.class"' where $Bar is
# treated as a ninja variable and replaced with the empty string. Thus,
# this touches Foo.class.
{
'action_name': 'touch1',
'inputs': [],
'outputs': ['dummy'],
'action': ['touch', 'Foo$Bar.class'],
},
# This generates the ninja command 'touch "Foo$$Bar.class"' where $Bar is
# treated as a ninja variable and replaced with the empty string. The
# resulting shell command is 'touch "Foo$Bar.class"' which, assuming Bar
# is not a shell variable, touches Foo.class.
{
'action_name': 'touch2',
'inputs': [],
'outputs': ['dummy'],
'action': ['touch', 'Foo$$Bar.class'],
},
# This generates the ninja command 'touch "Foo\\$$Bar.class"' where $Bar is
# treated as a ninja variable and replaced with the empty string. The
# resulting shell command is 'touch "Foo\\$Bar.class"' which, assuming Bar
# is not a shell variable, touches Foo\.class.
{
'action_name': 'touch3',
'inputs': [],
'outputs': ['dummy'],
'action': ['touch', 'Foo\$$Bar.class'],
},
],
},
],
}
First bug:
The ninja generator should escape literal dollar sign characters in ninja
files, i.e. '$' -> '$$'
Second bug:
Gyp should provide a means of preventing shell variable expansion on
action/rule/etc arguments. In the action "touch2" above, for example, the
ninja command is written as [touch "Foo$$Bar.class"], ninja treats $$ as a
literal $, shell variable expansion occurs on $Bar and Foo.class is touched.
One solution is to use strong single-quoting instead of weak double-quoting,
e.g. [touch 'Foo$$Bar.class']. The possible downside here is that one can no
longer easily refer to shell variables within gyp variables. This doesn't seem
like a big downside to me (in fact it seems like a good thing), but it might
break existing scripts?
Original issue reported on code.google.com by newt@chromium.org on 8 Nov 2012 at 2:15
Original issue reported on code.google.com by
newt@chromium.org
on 8 Nov 2012 at 2:15