tools: distinguish complier args and tool args
parent
38e5f0d1cf
commit
2a98cacecd
8
v.v
8
v.v
|
@ -31,7 +31,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
// external tool
|
// external tool
|
||||||
if command in simple_tools {
|
if command in simple_tools {
|
||||||
compiler.launch_tool('v' + command)
|
compiler.launch_tool('v' + command, command)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// v run, v doc, etc
|
// v run, v doc, etc
|
||||||
|
@ -50,7 +50,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
// No args? REPL
|
// No args? REPL
|
||||||
else if command == '' || (args.len == 2 && args[1] == '-') {
|
else if command == '' || (args.len == 2 && args[1] == '-') {
|
||||||
compiler.launch_tool('vrepl')
|
compiler.launch_tool('vrepl', '')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Construct the V object from command line arguments
|
// Construct the V object from command line arguments
|
||||||
|
@ -100,7 +100,7 @@ fn v_command(command string, args []string) {
|
||||||
println('Translating C to V will be available in V 0.3 (January)')
|
println('Translating C to V will be available in V 0.3 (January)')
|
||||||
}
|
}
|
||||||
'search', 'install', 'update', 'remove' {
|
'search', 'install', 'update', 'remove' {
|
||||||
compiler.launch_tool('vpm')
|
compiler.launch_tool('vpm', command)
|
||||||
}
|
}
|
||||||
'get' {
|
'get' {
|
||||||
println('use `v install` to install modules from vpm.vlang.io ')
|
println('use `v install` to install modules from vpm.vlang.io ')
|
||||||
|
@ -109,7 +109,7 @@ fn v_command(command string, args []string) {
|
||||||
compiler.create_symlink()
|
compiler.create_symlink()
|
||||||
}
|
}
|
||||||
'runrepl' {
|
'runrepl' {
|
||||||
compiler.launch_tool('vrepl')
|
compiler.launch_tool('vrepl', 'runrepl')
|
||||||
}
|
}
|
||||||
'doc' {
|
'doc' {
|
||||||
vexe := os.executable()
|
vexe := os.executable()
|
||||||
|
|
|
@ -5,11 +5,16 @@ import (
|
||||||
filepath
|
filepath
|
||||||
)
|
)
|
||||||
|
|
||||||
pub fn launch_tool(tname string) {
|
pub fn launch_tool(tname string, cmdname string) {
|
||||||
is_verbose := '-verbose' in os.args || '--verbose' in os.args
|
is_verbose := '-verbose' in os.args || '--verbose' in os.args
|
||||||
vexe := vexe_path()
|
vexe := vexe_path()
|
||||||
vroot := filepath.dir(vexe)
|
vroot := filepath.dir(vexe)
|
||||||
set_vroot_folder( vroot ) // needed by tools to find back v
|
set_vroot_folder( vroot ) // needed by tools to find back v
|
||||||
|
mut tname_index := os.args.index(cmdname)
|
||||||
|
if tname_index == -1 {
|
||||||
|
tname_index = os.args.len
|
||||||
|
}
|
||||||
|
mut compilation_options := os.args[1..tname_index].clone()
|
||||||
tool_args := os.args[1..].join(' ')
|
tool_args := os.args[1..].join(' ')
|
||||||
tool_exe := os.realpath('$vroot/tools/$tname')
|
tool_exe := os.realpath('$vroot/tools/$tname')
|
||||||
tool_source := os.realpath('$vroot/tools/${tname}.v')
|
tool_source := os.realpath('$vroot/tools/${tname}.v')
|
||||||
|
@ -41,9 +46,9 @@ pub fn launch_tool(tname string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if tool_should_be_recompiled {
|
if tool_should_be_recompiled {
|
||||||
mut compilation_options := ''
|
if tname == 'vfmt' { compilation_options << ['-d', 'vfmt'] }
|
||||||
if tname == 'vfmt' { compilation_options = '-d vfmt' }
|
compilation_args := compilation_options.join(' ')
|
||||||
compilation_command := '"$vexe" $compilation_options "$tool_source"'
|
compilation_command := '"$vexe" $compilation_args "$tool_source"'
|
||||||
if is_verbose {
|
if is_verbose {
|
||||||
eprintln('Compiling $tname with: "$compilation_command"')
|
eprintln('Compiling $tname with: "$compilation_command"')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue