1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v: support VFLAGS, fix 'v run source.v arg after source'

This commit is contained in:
Delyan Angelov
2020-04-11 10:18:59 +03:00
parent 75c6545857
commit 95709811e0
3 changed files with 26 additions and 28 deletions

View File

@@ -48,7 +48,7 @@ fn main() {
//}
toolexe := os.executable()
util.set_vroot_folder(os.dir(os.dir(os.dir(toolexe))))
args := join_flags_and_argument()
args := util.join_env_vflags_and_os_args()
foptions := FormatOptions{
is_c: '-c' in args
is_l: '-l' in args
@@ -326,31 +326,6 @@ fn get_compile_name_of_potential_v_project(file string) string {
return pfolder
}
//TODO Move join_flags_and_argument() and non_empty() into `cmd/internal` when v.mod work correctly
//to prevent code duplication with `cmd/v` (cmd/v/flag.v)
fn join_flags_and_argument() []string {
vosargs := os.getenv('VOSARGS')
if vosargs != '' {
return non_empty(vosargs.split(' '))
}
mut args := []string
vflags := os.getenv('VFLAGS')
if vflags != '' {
args << os.args[0]
args << vflags.split(' ')
if os.args.len > 1 {
args << os.args[1..]
}
return non_empty(args)
}
return non_empty(os.args)
}
fn non_empty(arg []string) []string {
return arg.filter(it != '')
}
fn verror(s string){
util.verror('vfmt error', s)
}