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

builder: add a verror, when the output folder is not existing and writable (#5966)

This commit is contained in:
dils2k
2020-08-03 20:19:36 +05:00
committed by GitHub
parent 3e4df7f140
commit 8dede3b535
4 changed files with 52 additions and 18 deletions

View File

@ -27,6 +27,18 @@ fn get_vtmp_filename(base_file_name, postfix string) string {
}
pub fn compile(command string, pref &pref.Preferences) {
odir := os.base_dir(pref.out_name)
// When pref.out_name is just the name of an executable, i.e. `./v -o executable main.v`
// without a folder component, just use the current folder instead:
mut output_folder := odir
if odir.len == pref.out_name.len {
output_folder = os.getwd()
}
os.is_writable_folder(output_folder) or {
// An early error here, is better than an unclear C error later:
verror(err)
exit(1)
}
// Construct the V object from command line arguments
mut b := new_builder(pref)
if pref.is_verbose {