compiler: first step to validate cmd flags
parent
80e79a3966
commit
d501dc4c11
38
v.v
38
v.v
|
@ -12,35 +12,35 @@ import (
|
|||
fn main() {
|
||||
// There's no `flags` module yet, so args have to be parsed manually
|
||||
args := compiler.env_vflags_and_os_args()
|
||||
//options := args.filter(it.starts_with('-'))
|
||||
|
||||
options := args.filter(it.starts_with('-'))
|
||||
commands := args.filter(!it.starts_with('-'))
|
||||
// Print the version and exit.
|
||||
if '-v' in args || '--version' in args || 'version' in args {
|
||||
if '-v' in options || '--version' in options || 'version' in commands {
|
||||
version_hash := compiler.vhash()
|
||||
println('V $compiler.Version $version_hash')
|
||||
return
|
||||
}
|
||||
if '-h' in args || '--help' in args || 'help' in args {
|
||||
println(compiler.HelpText)
|
||||
else if '-h' in options || '--help' in options || 'help' in commands {
|
||||
println(compiler.help_text)
|
||||
return
|
||||
}
|
||||
if 'translate' in args {
|
||||
else if 'translate' in commands {
|
||||
println('Translating C to V will be available in V 0.3')
|
||||
return
|
||||
}
|
||||
if 'up' in args {
|
||||
else if 'up' in commands {
|
||||
compiler.update_v()
|
||||
return
|
||||
}
|
||||
if 'get' in args {
|
||||
else if 'get' in commands {
|
||||
println('use `v install` to install modules from vpm.vlang.io ')
|
||||
return
|
||||
}
|
||||
if 'symlink' in args {
|
||||
else if 'symlink' in commands {
|
||||
compiler.create_symlink()
|
||||
return
|
||||
}
|
||||
if 'install' in args {
|
||||
else if 'install' in commands {
|
||||
compiler.install_v(args)
|
||||
return
|
||||
}
|
||||
|
@ -49,24 +49,28 @@ fn main() {
|
|||
// If there's no tmp path with current version yet, the user must be using a pre-built package
|
||||
//
|
||||
// Just fmt and exit
|
||||
if 'fmt' in args {
|
||||
else if 'fmt' in commands {
|
||||
compiler.vfmt(args)
|
||||
return
|
||||
}
|
||||
if 'test' in args {
|
||||
else if 'test' in commands {
|
||||
compiler.test_v()
|
||||
return
|
||||
}
|
||||
// Generate the docs and exit
|
||||
else if 'doc' in commands {
|
||||
// v.gen_doc_html_for_module(args.last())
|
||||
exit(0)
|
||||
} else {
|
||||
//println('unknown command/argument\n')
|
||||
//println(compiler.help_text)
|
||||
}
|
||||
|
||||
// Construct the V object from command line arguments
|
||||
mut v := compiler.new_v(args)
|
||||
if v.pref.is_verbose {
|
||||
println(args)
|
||||
}
|
||||
// Generate the docs and exit
|
||||
if 'doc' in args {
|
||||
// v.gen_doc_html_for_module(args.last())
|
||||
exit(0)
|
||||
}
|
||||
|
||||
if 'run' in args {
|
||||
// always recompile for now, too error prone to skip recompilation otherwise
|
||||
|
|
|
@ -2133,9 +2133,6 @@ fn (p mut Parser) dot(str_typ_ string, method_ph int) string {
|
|||
p.cgen.set_placeholder(method_ph,'\n$str_typ $tmp = new_array(0, $a .len,sizeof($val_type));\n')
|
||||
p.genln('for (int i = 0; i < ${a}.len; i++) {')
|
||||
p.genln('$val_type it = (($val_type*)${a}.data)[i];')
|
||||
if val_type == 'string'{
|
||||
p.genln('println(it);')
|
||||
}
|
||||
p.gen('if (')
|
||||
p.bool_expression()
|
||||
p.genln(') array_push(&$tmp, &it);')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module compiler
|
||||
|
||||
const (
|
||||
HelpText = 'Usage: v [options/commands] [file.v | directory]
|
||||
help_text = 'Usage: v [options/commands] [file.v | directory]
|
||||
|
||||
When V is run without any arguments, it is run in REPL mode.
|
||||
|
||||
|
@ -42,7 +42,7 @@ Options/commands:
|
|||
-shared Build a shared library.
|
||||
-stats Show additional stats when compiling/running tests. Try `v -stats test .`
|
||||
|
||||
-cache Turn on usage of the precompiled module cache.
|
||||
-cache Turn on usage of the precompiled module cache.
|
||||
It very significantly speeds up secondary compilations.
|
||||
|
||||
-obf Obfuscate the resulting binary.
|
||||
|
@ -51,7 +51,7 @@ Options/commands:
|
|||
Options for debugging/troubleshooting v programs:
|
||||
-g Generate debugging information in the backtraces. Add *V* line numbers to the generated executable.
|
||||
-cg Same as -g, but add *C* line numbers to the generated executable instead of *V* line numbers.
|
||||
-keep_c Do NOT remove the generated .tmp.c files after compilation.
|
||||
-keep_c Do NOT remove the generated .tmp.c files after compilation.
|
||||
It is useful when using debuggers like gdb/visual studio, when given after -g / -cg .
|
||||
-show_c_cmd Print the full C compilation command and how much time it took.
|
||||
-cc <ccompiler> Specify which C compiler you want to use as a C backend.
|
||||
|
|
Loading…
Reference in New Issue