2020-02-28 15:02:56 +03:00
|
|
|
module main
|
|
|
|
|
|
|
|
import (
|
|
|
|
os
|
|
|
|
v.pref
|
|
|
|
)
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
println('V Self Compiling...')
|
2020-02-28 18:04:22 +03:00
|
|
|
vexe := pref.vexe_path()
|
2020-03-08 00:26:26 +03:00
|
|
|
vroot := os.dir(vexe)
|
2020-02-28 15:02:56 +03:00
|
|
|
os.chdir(vroot)
|
2020-02-28 18:04:22 +03:00
|
|
|
s2 := os.exec('$vexe -o v2 cmd/v') or {
|
2020-02-28 15:02:56 +03:00
|
|
|
panic(err)
|
|
|
|
}
|
2020-02-28 18:04:22 +03:00
|
|
|
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)
|
2020-02-28 15:02:56 +03:00
|
|
|
}
|
2020-02-28 18:04:22 +03:00
|
|
|
os.mv(v_file, bak_file)
|
|
|
|
os.mv(v2_file, v_file)
|
2020-02-28 15:02:56 +03:00
|
|
|
}
|