tools: v self compiler

pull/3871/head
yuyi 2020-02-28 20:02:56 +08:00 committed by GitHub
parent f5fdbfd004
commit 8c43644301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 1 deletions

36
cmd/tools/vself.v 100644
View File

@ -0,0 +1,36 @@
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')
}
}

View File

@ -20,6 +20,7 @@ The commands are:
symlink create a symbolic link for V
translate translate C code to V (coming soon in 0.3)
up run the V self-updater
self run the V self-compiler
version prints the version text and exits
install installs a module from VPM
@ -110,6 +111,7 @@ Commands:
up Update V. Run `v up` at least once per day, since V development is rapid and features/bugfixes are added constantly.
run <file.v> Build and execute the V program in file.v. You can add arguments for the V program *after* the file name.
build <module> Compile a module into an object file.
self Self-compile V from local source files.
repl Run the V REPL. If V is running in a tty terminal, the REPL is interactive, otherwise it just reads from stdin.
symlink Useful on Unix systems. Symlinks the current V executable to /usr/local/bin/v, so that V is globally available.
test-compiler Run all V test files, and compile all V examples.

View File

@ -13,7 +13,7 @@ import (
const (
simple_cmd = ['fmt',
'up',
'up', 'self',
'create',
'test', 'test-fmt', 'test-compiler',
'bin2v',