2019-09-11 12:35:03 +02:00
|
|
|
module main
|
|
|
|
|
|
|
|
const (
|
|
|
|
HelpText = 'Usage: v [options/subcommands] [file.v | directory]
|
|
|
|
|
|
|
|
When V is run without any arguments, it is a shorthand for `v runrepl`.
|
|
|
|
|
|
|
|
When given a .v file, it will be compiled. The output executable will have the same name as the input .v file.
|
|
|
|
You can use -o to specify a different output name.
|
|
|
|
|
2019-09-13 15:19:41 +02:00
|
|
|
When given a directory, all the .v files contained in it, will be compiled as part of a single main module.
|
2019-09-11 12:35:03 +02:00
|
|
|
By default the executable will be named a.out.
|
|
|
|
|
2019-09-13 15:19:41 +02:00
|
|
|
Any file ending in _test.v, will be treated as a test.
|
2019-09-11 12:35:03 +02:00
|
|
|
It will be compiled and run, evaluating the assert statements in every function named test_xxx.
|
|
|
|
|
2019-09-13 15:19:41 +02:00
|
|
|
You can put common options inside an environment variable named VFLAGS, so that you do not repeat them.
|
2019-09-11 12:35:03 +02:00
|
|
|
You can set it like this: `export VFLAGS="-cc clang -debug"` on unix, `set VFLAGS=-os msvc` on windows.
|
2019-09-13 15:19:41 +02:00
|
|
|
|
|
|
|
Options:
|
|
|
|
- Shorthand for `v runrepl`.
|
|
|
|
-h, --help Display this information.
|
2019-09-11 12:35:03 +02:00
|
|
|
-live Enable hot code reloading (required by functions marked with [live]).
|
2019-09-13 15:19:41 +02:00
|
|
|
-os <OS> Produce an executable for the selected OS.
|
2019-09-11 12:35:03 +02:00
|
|
|
OS can be linux, mac, windows, msvc, etc...
|
|
|
|
-os msvc is useful, if you want to use the MSVC compiler on Windows.
|
|
|
|
-prod Build an optimized executable.
|
2019-09-13 15:19:41 +02:00
|
|
|
-v, --version Display compiler version and git hash of the compiler source.
|
|
|
|
|
2019-09-11 12:35:03 +02:00
|
|
|
Debugging options:
|
2019-09-13 15:19:41 +02:00
|
|
|
-cc <ccompiler> Specify which C compiler you want to use as a C backend.
|
2019-09-11 12:35:03 +02:00
|
|
|
The C backend compiler should be able to handle C99 compatible C code.
|
2019-09-13 15:19:41 +02:00
|
|
|
Common C compilers are gcc, clang, tcc, icc, cl...
|
|
|
|
-cflags <flags> Pass additional C flags to the C backend compiler.
|
2019-09-11 12:35:03 +02:00
|
|
|
Example: -cflags `sdl2-config --cflags`
|
2019-09-13 15:19:41 +02:00
|
|
|
|
2019-09-11 21:24:22 +02:00
|
|
|
-debug Keep the generated C file for debugging in program.tmp.c even after compilation.
|
2019-09-13 15:19:41 +02:00
|
|
|
-g Show v line numbers in backtraces. Implies -debug.
|
2019-09-11 12:35:03 +02:00
|
|
|
-o <file> Place output into <file>. If file has a .c suffix, produce C source, and do not compile it further.
|
|
|
|
-obf Obfuscate the resulting binary.
|
|
|
|
-show_c_cmd Print the full C compilation command and how much time it took.
|
2019-09-13 15:19:41 +02:00
|
|
|
|
2019-09-11 12:35:03 +02:00
|
|
|
|
|
|
|
Subcommands:
|
|
|
|
up Update V. Run `v up` at least once per day, since V development is rapid and features/bugfixes are added constantly.
|
2019-09-13 15:19:41 +02:00
|
|
|
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.
|
2019-09-11 21:24:22 +02:00
|
|
|
runrepl Run the V REPL. If V is running in a tty terminal, the REPL is interactive, otherwise it just reads from stdin.
|
2019-09-11 12:35:03 +02:00
|
|
|
symlink Useful on unix systems. Symlinks the current V executable to /usr/local/bin/v, so that V is globally available.
|
2019-09-13 15:19:41 +02:00
|
|
|
install <module> Install a user module from https://vpm.vlang.io/.
|
2019-09-11 12:35:03 +02:00
|
|
|
test v Run all V test files, and compile all V examples.
|
|
|
|
|
|
|
|
fmt Run vfmt to format the source code. [wip]
|
2019-09-11 21:24:22 +02:00
|
|
|
doc Run vdoc over the source code and produce documentation. [wip]
|
2019-09-13 15:19:41 +02:00
|
|
|
translate Translates C to V. [wip, will be available in V 0.3]
|
|
|
|
version Display compiler version and git hash of the compiler source.
|
2019-09-11 12:35:03 +02:00
|
|
|
'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
- To disable automatic formatting:
|
|
|
|
v -nofmt file.v
|
|
|
|
|
|
|
|
- To build a program with an embedded vlib (use this if you do not have prebuilt vlib libraries or if you
|
|
|
|
are working on vlib)
|
|
|
|
v -embed_vlib file.v
|
|
|
|
*/
|