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

v.pref: fix v build file.v

This commit is contained in:
Delyan Angelov
2020-07-21 19:36:58 +03:00
parent 6dd1494008
commit 14fd7d93ca
3 changed files with 17 additions and 2 deletions

View File

@ -310,6 +310,13 @@ pub fn parse_args(args []string) (&Preferences, string) {
}
if command.ends_with('.v') || os.exists(command) {
res.path = command
} else if command == 'build' {
if command_pos + 2 != args.len {
eprintln('`v build` requires exactly one argument - either a single .v file, or a single folder/ containing several .v files')
exit(1)
}
res.path = args[command_pos + 1]
must_exist(res.path)
} else if command == 'run' {
res.is_run = true
if command_pos + 2 > args.len {
@ -318,6 +325,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
}
res.path = args[command_pos + 1]
res.run_args = args[command_pos + 2..]
must_exist(res.path)
}
if command == 'build-module' {
res.build_mode = .build_module
@ -327,6 +335,13 @@ pub fn parse_args(args []string) (&Preferences, string) {
return res, command
}
fn must_exist(path string) {
if !os.exists(path) {
eprintln('v expects that `$path` exists, but it does not')
exit(1)
}
}
pub fn backend_from_string(s string) ?Backend {
match s {
'c' { return .c }