ast: fix bug in parsing `-Isomething -Danother` from #flag and #pkgconfig directives
parent
65f12f3217
commit
2b981b011e
|
@ -18,7 +18,7 @@ fn (t &Table) has_cflag(flag cflag.CFlag) bool {
|
|||
// parse the flags to (ast.cflags) []CFlag
|
||||
// Note: clean up big time (joe-c)
|
||||
pub fn (mut t Table) parse_cflag(cflg string, mod string, ctimedefines []string) ?bool {
|
||||
allowed_flags := ['framework', 'library', 'Wa', 'Wl', 'Wp', 'I', 'l', 'L']
|
||||
allowed_flags := ['framework', 'library', 'Wa', 'Wl', 'Wp', 'I', 'l', 'L', 'D']
|
||||
flag_orig := cflg.trim_space()
|
||||
mut flag := flag_orig
|
||||
if flag == '' {
|
||||
|
|
|
@ -20,6 +20,10 @@ fn test_parse_valid_cflags() {
|
|||
make_flag('windows', '-l', 'gdi32'),
|
||||
make_flag(no_os, '-l', 'mysqlclient'),
|
||||
make_flag(no_os, no_name, '-test'),
|
||||
make_flag('linux', '-I', '/usr/include/SDL2'),
|
||||
make_flag('linux', '-D', '_REENTRANT'),
|
||||
make_flag('linux', '-L', '/usr/lib/x86_64-linux-gnu'),
|
||||
make_flag('linux', '-l', 'SDL2'),
|
||||
]
|
||||
parse_valid_flag(mut t, '-lmysqlclient')
|
||||
parse_valid_flag(mut t, '-test')
|
||||
|
@ -29,6 +33,7 @@ fn test_parse_valid_cflags() {
|
|||
parse_valid_flag(mut t, 'mingw -mwindows')
|
||||
parse_valid_flag(mut t, 'solaris -L/opt/local/lib')
|
||||
parse_valid_flag(mut t, 'windows -lgdi32')
|
||||
parse_valid_flag(mut t, 'linux -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib/x86_64-linux-gnu -lSDL2')
|
||||
assert t.cflags.len == expected_flags.len
|
||||
for f in expected_flags {
|
||||
assert t.has_cflag(f)
|
||||
|
|
Loading…
Reference in New Issue