1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
project('ninja special characters' ,'c')
python = import('python3').find_python()
# Without newlines, this should appear directly in build.ninja.
gen = custom_target('gen',
command : [
python,
files('check_quoting.py'),
'dollar=$',
'colon=:',
'space= ',
'''multi1= ::$$ ::$$''',
'@OUTPUT@'],
output : 'result',
install : true,
install_dir : get_option('datadir'))
# With newlines, this should go through the exe wrapper.
gen2 = custom_target('gen2',
command : [
python,
files('check_quoting.py'),
'''newline=
''',
'dollar=$',
'colon=:',
'space= ',
'''multi2= ::$$
::$$''',
'@OUTPUT@'],
output : 'result2',
install : true,
install_dir : get_option('datadir'))
# Test that we can pass these special characters in compiler arguments
#
# (this part of the test is crafted so we don't try to use these special
# characters in filenames or target names)
#
# TODO: similar tests needed for languages other than C
# TODO: add similar test for quote, doublequote, and hash, carefully
# Re hash, see
# https://docs.microsoft.com/en-us/cpp/build/reference/d-preprocessor-definitions
special = [
['amp', '&'],
['at', '@'],
['backslash', '\\'],
['dollar', '$'],
['gt', '>'],
['lt', '<'],
['slash', '/'],
]
cc = meson.get_compiler('c')
foreach s : special
args = '-DCHAR="@0@"'.format(s[1])
e = executable('arg-string-' + s[0], 'arg-string-test.c', c_args: args)
test('arg-string-' + s[0], e, args: s[1])
args = '-DCHAR=@0@'.format(s[1])
e = executable('arg-unquoted-' + s[0], 'arg-unquoted-test.c', c_args: args)
test('arg-unquoted-' + s[0], e, args: s[1])
endforeach
foreach s : special
args = '-DCHAR=\'@0@\''.format(s[1])
e = executable('arg-char-' + s[0], 'arg-char-test.c', c_args: args)
test('arg-char-' + s[0], e, args: s[1])
endforeach
|