From 22c7438795c81f04236389dfdf3210c0960f7c48 Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Sat, 19 Oct 2019 08:18:08 +1100 Subject: [PATCH] compiler: cflag error - closes #2406 (#2417) * merge master * fix blank ident & add cflag error * undo cflag changes * add missing brace * undo change to comptime * improve error message * update --- vlib/compiler/cflags.v | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vlib/compiler/cflags.v b/vlib/compiler/cflags.v index 5e658b1042..d20fe4abe4 100644 --- a/vlib/compiler/cflags.v +++ b/vlib/compiler/cflags.v @@ -70,15 +70,16 @@ fn (table &Table) has_cflag(cflag CFlag) bool { // parse the flags to (table.cflags) []CFlag // Note: clean up big time (joe-c) -fn (table mut Table) parse_cflag(cflag string, mod string) { +fn (table mut Table) parse_cflag(cflag string, mod string) ?bool { allowed_flags := [ 'framework', 'library', 'I', 'l', 'L', ] - mut flag := cflag.trim_space() + flag_orig := cflag.trim_space() + mut flag := flag_orig if flag == '' { - return + return true } mut fos := '' mut name := '' @@ -124,6 +125,13 @@ fn (table mut Table) parse_cflag(cflag string, mod string) { value = flag.trim_space() index = -1 } + if (name in ['-I', '-l', '-L']) && value == '' { + if name == '-I' || name == '-L' { + return error('bad #flag `$flag_orig`: missing path after `-I`') + } else if name == '-l' { + return error('bad #flag `$flag_orig`: missing library name after `-l`') + } + } cf := CFlag{ mod: mod, os: fos, @@ -137,7 +145,7 @@ fn (table mut Table) parse_cflag(cflag string, mod string) { break } } - return + return true } //TODO: implement msvc specific c_options_before_target and c_options_after_target ...