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

make and vself: cleanup make based on the new 'v self'

This commit is contained in:
Delyan Angelov
2020-02-28 17:04:22 +02:00
committed by GitHub
parent ccf4f61521
commit 10e15e5de7
4 changed files with 47 additions and 39 deletions

View File

@@ -8,29 +8,24 @@ import (
fn main() {
println('V Self Compiling...')
vroot := filepath.dir(pref.vexe_path())
vexe := pref.vexe_path()
vroot := filepath.dir(vexe)
os.chdir(vroot)
s2 := os.exec('v -o v2 cmd/v') or {
s2 := os.exec('$vexe -o v2 cmd/v') or {
panic(err)
}
println(s2.output)
$if windows {
bak_file := 'v_old.exe'
if os.exists(bak_file) {
os.rm(bak_file)
}
os.mv('v.exe', bak_file)
os.mv('v2.exe', 'v.exe')
} $else {
bak_file := 'v_old'
if os.exists(bak_file) {
os.rm(bak_file)
}
os.mv('v', bak_file)
os.mv('v2', 'v')
if s2.output.len > 0 {
println(s2.output)
}
if s2.exit_code != 0 {
exit(1)
}
v_file := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
v2_file := if os.user_os() == 'windows' { 'v2.exe' } else { 'v2' }
bak_file := if os.user_os() == 'windows' { 'v_old.exe' } else { 'v_old' }
if os.exists(bak_file) {
os.rm(bak_file)
}
os.mv(v_file, bak_file)
os.mv(v2_file, v_file)
}