diff --git a/compiler/main.v b/compiler/main.v index fc8484aeb3..c4cfc04c64 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -84,6 +84,7 @@ mut: out_name string // "program.exe" is_prod bool // use "-O2" and skip printlns (TODO I don't thik many people want printlns to disappear in prod buidls) is_repl bool + vroot string } fn main() { @@ -825,6 +826,7 @@ fn new_v(args[]string) *V { build_mode: build_mode is_run: args.contains('run') is_repl: args.contains('-repl') + vroot: lang_dir } } diff --git a/compiler/parser.v b/compiler/parser.v index 5fe7a9d867..88f8941930 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -70,6 +70,7 @@ mut: calling_c bool cur_fn *Fn returns bool + vroot string } const ( @@ -99,6 +100,7 @@ fn (c mut V) new_parser(path string, run Pass) Parser { build_mode: c.build_mode is_repl: c.is_repl run: run + vroot: c.vroot } p.next() // p.scanner.debug_tokens() @@ -2605,7 +2607,7 @@ fn (p mut Parser) chash() { pos := flag.index(' ') flag = flag.right(pos) } - flag = flag.trim_space() + flag = flag.trim_space().replace('@VROOT', p.vroot) if p.table.flags.contains(flag) { return } diff --git a/gl/gl.v b/gl/gl.v index 2bfc74ca68..213f24cc3e 100644 --- a/gl/gl.v +++ b/gl/gl.v @@ -14,8 +14,8 @@ import const ( ) // TODO: windows support -#flag linux -I$HOME/code/v/thirdparty/glad -#flag darwin -I$HOME/code/v/thirdparty/glad +#flag linux -I @VROOT/thirdparty/glad +#flag darwin -I @VROOT/thirdparty/glad #include "glad.h" #include "glad.c" diff --git a/json/json_primitives.v b/json/json_primitives.v index 1f5f8aca45..48006abd87 100644 --- a/json/json_primitives.v +++ b/json/json_primitives.v @@ -5,8 +5,9 @@ module json // TODO: windows support -#flag linux -I$HOME/code/v/thirdparty/cJSON -#flag darwin -I$HOME/code/v/thirdparty/cJSON + +#flag linux -I @VROOT/thirdparty/cJSON +#flag darwin -I @VROOT/thirdparty/cJSON // #include "cJSON.c" #include "cJSON.h" diff --git a/stbi/stbi.v b/stbi/stbi.v index 88344ec437..a8b66fdbf6 100644 --- a/stbi/stbi.v +++ b/stbi/stbi.v @@ -6,8 +6,8 @@ module stbi import gl -#flag linux -I$HOME/code/v/thirdparty/stb_image -#flag darwin -I$HOME/code/v/thirdparty/stb_image +#flag linux -I @VROOT/thirdparty/stb_image +#flag darwin -I @VROOT/thirdparty/stb_image #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h"