From e15abb3de0526239c17902f9ef4e515d0a31be45 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 1 Nov 2019 12:14:59 +0200 Subject: [PATCH] compiler: move `v up` implementation to tools/vup.v --- .gitignore | 4 ++++ tools/vup.v | 21 +++++++++++++++++++++ v.v | 2 +- vlib/compiler/main.v | 28 ---------------------------- 4 files changed, 26 insertions(+), 29 deletions(-) create mode 100644 tools/vup.v diff --git a/.gitignore b/.gitignore index b7fb1d2d09..f25d582782 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,7 @@ vjs ._* .vrepl_temp.v a.out +tools/vrepl +tools/vtest +tools/vup +examples/sqlite diff --git a/tools/vup.v b/tools/vup.v new file mode 100644 index 0000000000..78ceadeef5 --- /dev/null +++ b/tools/vup.v @@ -0,0 +1,21 @@ +import os + +fn main() { + println('Updating V...') + vroot := os.dir(os.args[1]) + os.chdir(vroot) + s := os.exec('git -C "$vroot" pull --rebase origin master') or { panic(err) } + println(s.output) + $if windows { + v_backup_file := '$vroot/v_old.exe' + if os.file_exists( v_backup_file ) { + os.rm( v_backup_file ) + } + os.mv('$vroot/v.exe', v_backup_file) + s2 := os.exec('"$vroot/make.bat"') or { panic(err) } + println(s2.output) + } $else { + s2 := os.exec('make -C "$vroot"') or { panic(err) } + println(s2.output) + } +} diff --git a/v.v b/v.v index 4a638a5d42..52fce2fb81 100755 --- a/v.v +++ b/v.v @@ -33,7 +33,7 @@ fn main() { return } else if 'up' in commands { - compiler.update_v() + compiler.launch_tool('vup') return } else if 'get' in commands { diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index 32f2d54909..2659370df1 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -978,34 +978,6 @@ pub fn env_vflags_and_os_args() []string { return args } -pub fn update_v() { - println('Updating V...') - vroot := os.dir(vexe_path()) - s := os.exec('git -C "$vroot" pull --rebase origin master') or { - verror(err) - return - } - println(s.output) - $if windows { - v_backup_file := '$vroot/v_old.exe' - if os.file_exists( v_backup_file ) { - os.rm( v_backup_file ) - } - os.mv('$vroot/v.exe', v_backup_file) - s2 := os.exec('"$vroot/make.bat"') or { - verror(err) - return - } - println(s2.output) - } $else { - s2 := os.exec('make -C "$vroot"') or { - verror(err) - return - } - println(s2.output) - } -} - pub fn vfmt(args[]string) { file := args.last() if !os.file_exists(file) {