2019-10-13 16:37:43 +03:00
|
|
|
module compiler
|
2019-09-11 13:35:03 +03:00
|
|
|
|
2019-10-24 12:36:57 +03:00
|
|
|
pub const (
|
2019-10-18 07:48:46 +03:00
|
|
|
help_text = 'Usage: v [options/commands] [file.v | directory]
|
2019-09-11 13:35:03 +03:00
|
|
|
|
2019-09-15 14:08:40 +03:00
|
|
|
When V is run without any arguments, it is run in REPL mode.
|
2019-09-11 13:35:03 +03:00
|
|
|
|
2019-09-15 14:08:40 +03:00
|
|
|
When given a .v file, it will be compiled. The executable will have the
|
|
|
|
same name as the input .v file: `v foo.v` produces `./foo` on *nix systems,
|
|
|
|
`foo.exe` on Windows.
|
2019-09-11 13:35:03 +03:00
|
|
|
|
2019-09-15 14:15:31 +03:00
|
|
|
You can use -o to specify a different output executable\'s name.
|
2019-09-15 14:08:40 +03:00
|
|
|
|
|
|
|
When given a directory, all .v files contained in it will be compiled as
|
|
|
|
part of a single main module.
|
|
|
|
|
|
|
|
By default the executable will have the same name as the directory.
|
|
|
|
|
|
|
|
To compile all V files in current directory, run `v .`
|
2019-09-11 13:35:03 +03:00
|
|
|
|
2019-09-13 16:19:41 +03:00
|
|
|
Any file ending in _test.v, will be treated as a test.
|
2019-09-15 14:08:40 +03:00
|
|
|
It will be compiled and run, evaluating the assert statements in every
|
|
|
|
function named test_xxx.
|
2019-09-11 13:35:03 +03:00
|
|
|
|
2019-09-15 14:08:40 +03:00
|
|
|
You can put common options inside an environment variable named VFLAGS, so that
|
|
|
|
you don\'t have to repeat them.
|
2019-09-13 16:19:41 +03:00
|
|
|
|
2019-09-15 14:08:40 +03:00
|
|
|
You can set it like this: `export VFLAGS="-cc clang -debug"` on *nix,
|
2019-10-14 08:41:46 +03:00
|
|
|
`set VFLAGS=-cc msvc` on Windows.
|
2019-09-15 14:08:40 +03:00
|
|
|
|
2019-11-17 06:45:20 +03:00
|
|
|
V respects the TMPDIR environment variable, and will put .tmp.c files in TMPDIR/v/ .
|
|
|
|
If you have not set it, a suitable platform specific folder (like /tmp) will be used.
|
|
|
|
|
2019-09-15 14:08:40 +03:00
|
|
|
Options/commands:
|
|
|
|
-h, help Display this information.
|
|
|
|
-o <file> Write output to <file>.
|
|
|
|
-o <file>.c Produce C source without compiling it.
|
|
|
|
-o <file>.js Produce JavaScript source.
|
|
|
|
-prod Build an optimized executable.
|
|
|
|
-v, version Display compiler version and git hash of the compiler source.
|
2019-12-28 11:41:21 +03:00
|
|
|
-verbose Produce a verbose log about what the compiler is doing, where it seeks for files and so on.
|
2019-09-11 13:35:03 +03:00
|
|
|
-live Enable hot code reloading (required by functions marked with [live]).
|
2019-09-13 16:19:41 +03:00
|
|
|
-os <OS> Produce an executable for the selected OS.
|
2019-09-15 14:08:40 +03:00
|
|
|
OS can be linux, mac, windows, msvc.
|
|
|
|
Use msvc if you want to use the MSVC compiler on Windows.
|
2019-10-12 13:54:01 +03:00
|
|
|
-shared Build a shared library.
|
|
|
|
-stats Show additional stats when compiling/running tests. Try `v -stats test .`
|
|
|
|
|
2019-10-18 07:48:46 +03:00
|
|
|
-cache Turn on usage of the precompiled module cache.
|
2019-10-12 13:54:01 +03:00
|
|
|
It very significantly speeds up secondary compilations.
|
|
|
|
|
|
|
|
-obf Obfuscate the resulting binary.
|
2019-11-17 15:35:01 +03:00
|
|
|
-compress Compress the resulting binary.
|
2020-01-17 16:09:26 +03:00
|
|
|
- Shorthand for `v repl`.
|
2019-10-12 13:54:01 +03:00
|
|
|
|
|
|
|
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.
|
2019-10-18 07:48:46 +03:00
|
|
|
-keep_c Do NOT remove the generated .tmp.c files after compilation.
|
2019-12-28 11:41:21 +03:00
|
|
|
It is useful when using debuggers like gdb/visual studio, when given after `-g` / `-cg`.
|
2020-02-01 08:37:22 +03:00
|
|
|
-pretty_c Run clang-format over the generated C file, so that it looks nicer. Requires you to have clang-format.
|
2019-12-28 11:41:21 +03:00
|
|
|
-show_c_cmd Print the full C compilation command and how much time it took. See also `-verbose`.
|
2019-09-13 16:19:41 +03:00
|
|
|
-cc <ccompiler> Specify which C compiler you want to use as a C backend.
|
2019-09-11 13:35:03 +03:00
|
|
|
The C backend compiler should be able to handle C99 compatible C code.
|
2019-09-13 16:19:41 +03:00
|
|
|
Common C compilers are gcc, clang, tcc, icc, cl...
|
|
|
|
-cflags <flags> Pass additional C flags to the C backend compiler.
|
2019-09-11 13:35:03 +03:00
|
|
|
Example: -cflags `sdl2-config --cflags`
|
2019-09-13 16:19:41 +03:00
|
|
|
|
2019-10-12 13:54:01 +03:00
|
|
|
Commands:
|
2019-09-11 13:35:03 +03:00
|
|
|
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 16:19:41 +03: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.
|
2020-01-17 16:09:26 +03:00
|
|
|
repl Run the V REPL. If V is running in a tty terminal, the REPL is interactive, otherwise it just reads from stdin.
|
2019-10-31 13:08:01 +03:00
|
|
|
symlink Useful on Unix systems. Symlinks the current V executable to /usr/local/bin/v, so that V is globally available.
|
2020-01-21 20:48:32 +03:00
|
|
|
test-compiler Run all V test files, and compile all V examples.
|
2019-10-09 06:01:43 +03:00
|
|
|
test folder/ Run all V test files located in the folder and its subfolders. You can also pass individual _test.v files too.
|
2019-09-11 13:35:03 +03:00
|
|
|
fmt Run vfmt to format the source code. [wip]
|
2019-10-31 13:08:01 +03:00
|
|
|
doc Run vdoc over the source code and produce documentation.
|
2019-09-13 16:19:41 +03:00
|
|
|
translate Translates C to V. [wip, will be available in V 0.3]
|
2019-11-11 00:48:56 +03:00
|
|
|
create Create a new v project interactively. Answer the questions, and run it with `v run projectname`
|
tools/vget => tools/v , search, install, etc
* compiler: rename vget to tools/vpm, implement draft support for v vpm search, v vpm update, v vpm install, v vpm remove, v vpm help .
* compiler: use "v pm" instead of "v vpm" to reduce the redundancy of typing, as suggested by slapden
* Use 'v install modulename', 'v search keywords', 'v update modulename', 'v remove modulename' instead of the longer 'v pm install modulename' etc.
2019-11-01 15:19:04 +03:00
|
|
|
|
|
|
|
V package management commands:
|
|
|
|
search keywords Search the https://vpm.vlang.io/ module repository for matching modules and shows their details.
|
|
|
|
install <module> Install a user module from https://vpm.vlang.io/.
|
|
|
|
update [module] Updates an already installed module, or ALL installed modules at once, when no module name is given.
|
|
|
|
remove [module] Removes an installed module, or ALL installed modules at once, when no module name is given.
|
2019-09-11 13:35:03 +03:00
|
|
|
'
|
|
|
|
)
|
|
|
|
/*
|
|
|
|
- To disable automatic formatting:
|
|
|
|
v -nofmt file.v
|
|
|
|
*/
|
2019-12-20 00:29:37 +03:00
|
|
|
|