cmd/v: remove clang-format (the generated code is pretty from the start)
parent
87c00a61da
commit
2006995020
|
@ -299,8 +299,6 @@ fn (gen_vc mut GenVC) generate() {
|
|||
gen_vc.assert_file_exists_and_is_not_too_short(c_file, err_msg_gen_c)
|
||||
// embed the latest v commit hash into the c file
|
||||
gen_vc.cmd_exec('sed -i \'1s/^/#define V_COMMIT_HASH "$last_commit_hash_v_short"\\n/\' $c_file')
|
||||
// run clang-format to make the c file more readable
|
||||
gen_vc.cmd_exec('clang-format -i $c_file')
|
||||
// move to vc repo
|
||||
gen_vc.cmd_exec('mv $c_file $git_repo_dir_vc/$c_file')
|
||||
// add new .c file to local vc repo
|
||||
|
|
|
@ -37,18 +37,6 @@ fn (v mut V) cc() {
|
|||
// for example: `v -o v.c compiler`
|
||||
ends_with_c := v.pref.out_name.ends_with('.c')
|
||||
ends_with_js := v.pref.out_name.ends_with('.js')
|
||||
|
||||
if v.pref.is_pretty_c && !ends_with_js {
|
||||
format_result := os.exec('clang-format -i -style=file "$v.out_name_c"') or {
|
||||
eprintln('clang-format not found')
|
||||
os.Result{exit_code:-1}
|
||||
}
|
||||
if format_result.exit_code > 0 {
|
||||
eprintln('clang-format failed to format $v.out_name_c')
|
||||
eprintln(format_result.output)
|
||||
}
|
||||
}
|
||||
|
||||
if ends_with_c || ends_with_js {
|
||||
// Translating V code to JS by launching vjs.
|
||||
// Using a separate process for V.js is for performance mostly,
|
||||
|
|
|
@ -42,10 +42,6 @@ fn parse_c_options(flag string, f mut flag.Instance, prefs mut pref.Preferences)
|
|||
'keep' {
|
||||
prefs.is_keep_c = true
|
||||
}
|
||||
'prettify' {
|
||||
prefs.is_keep_c = true
|
||||
prefs.is_pretty_c = true
|
||||
}
|
||||
'drop' {} //Default
|
||||
else {
|
||||
println('V error: Unknown argument for `-csource` (`$operation`).')
|
||||
|
|
|
@ -28,10 +28,8 @@ These build flags are enabled on `build` and `run` as long as the backend is set
|
|||
-compress
|
||||
Strip the compiled executable to compress it.
|
||||
|
||||
-csource <prettify|keep|drop>
|
||||
-csource <keep|drop>
|
||||
Specify how V deals with the intermediate C source code.
|
||||
* `prettify` - The C source code will be kept.
|
||||
`clang-format` is used to prettify the C source code before compiling it.
|
||||
* `keep` - The C source code will be kept as generated by V.
|
||||
* `drop` (default) - The C source code will be deleted after compiling the executable.
|
||||
|
||||
|
|
|
@ -1335,7 +1335,6 @@ To debug issues with the generated C code, you can pass these flags:
|
|||
|
||||
- `-cg` - produces a less optimized executable with more debug information in it.
|
||||
- `-keep_c` - keep the generated C file, so your debugger can also use it.
|
||||
- `-pretty_c` - run clang-format over the generated C file, so it looks nicer and is easier to read.
|
||||
- `-show_c_cmd` - prints the C command that is used to build the program.
|
||||
|
||||
For best debugging experience, you can pass all of them at the same time: `v -cg -keep_c -pretty_c -show_c_cmd yourprogram.v` , then just run your debugger (gdb/lldb) or IDE with the produced executable `yourprogram`.
|
||||
|
|
|
@ -51,7 +51,6 @@ pub mut:
|
|||
is_keep_c bool // -keep_c , tell v to leave the generated .tmp.c alone (since by default v will delete them after c backend finishes)
|
||||
// NB: passing -cg instead of -g will set is_vlines to false and is_g to true, thus making v generate cleaner C files,
|
||||
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
|
||||
is_pretty_c bool // -pretty_c , tell v to run clang-format -i over the produced C file, before it is compiled. Use with -keep_c or with -o x.c .
|
||||
is_cache bool // turns on v usage of the module cache to speed up compilation.
|
||||
is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run
|
||||
no_auto_free bool // `v -nofree` disable automatic `free()` insertion for better performance in some applications (e.g. compilers)
|
||||
|
|
Loading…
Reference in New Issue