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

v.exe: clone the repo on first launch

This commit is contained in:
Alexander Medvednikov 2019-06-25 20:41:46 +02:00
parent 0c8afdfe13
commit 688bbcff9c
2 changed files with 13 additions and 1 deletions

View File

@ -782,7 +782,15 @@ fn new_v(args[]string) *V {
println('Setting VROOT to "$lang_dir".')
os.write_file(TmpPath + '/VROOT', lang_dir)
} else {
println('Please do it from "v/compiler" directory.')
println('V repo not found. Cloning...')
os.mv('v', 'v.bin')
os.system('git clone https://github.com/vlang/v')
if !os.dir_exists('v') {
println('failed to clone github.com/vlang/v')
exit(1)
}
os.mv('v.bin', 'v/compiler/v')
println('Re-launch V from v/compiler')
exit(1)
}
}

View File

@ -84,6 +84,10 @@ pub fn file_size(path string) int {
return 0
}
pub fn mv(old, new string) {
C.rename(old.cstr(), new.cstr())
}
pub fn file_last_mod_unix(path string) int {
# struct stat attr;
# stat(path.str, &attr);