1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/cmd/tools/vself.v
2020-02-28 13:02:56 +01:00

37 lines
501 B
V

module main
import (
os
filepath
v.pref
)
fn main() {
println('V Self Compiling...')
vroot := filepath.dir(pref.vexe_path())
os.chdir(vroot)
s2 := os.exec('v -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')
}
}