From 2006995020181425a8b3476dd01b16059a7ab419 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 6 Apr 2020 17:11:01 +0200 Subject: [PATCH] cmd/v: remove clang-format (the generated code is pretty from the start) --- cmd/tools/gen_vc.v | 2 -- cmd/v/internal/compile/cc.v | 12 ------------ cmd/v/internal/compile/compile_c_options.v | 4 ---- cmd/v/internal/help/build-c.txt | 4 +--- doc/docs.md | 9 ++++----- vlib/v/pref/pref.v | 1 - 6 files changed, 5 insertions(+), 27 deletions(-) diff --git a/cmd/tools/gen_vc.v b/cmd/tools/gen_vc.v index 5aa744ccc8..f186c48870 100644 --- a/cmd/tools/gen_vc.v +++ b/cmd/tools/gen_vc.v @@ -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 diff --git a/cmd/v/internal/compile/cc.v b/cmd/v/internal/compile/cc.v index fd40288b88..25c46920ed 100644 --- a/cmd/v/internal/compile/cc.v +++ b/cmd/v/internal/compile/cc.v @@ -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, diff --git a/cmd/v/internal/compile/compile_c_options.v b/cmd/v/internal/compile/compile_c_options.v index 3fe74de9d0..0065838559 100644 --- a/cmd/v/internal/compile/compile_c_options.v +++ b/cmd/v/internal/compile/compile_c_options.v @@ -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`).') diff --git a/cmd/v/internal/help/build-c.txt b/cmd/v/internal/help/build-c.txt index ea7ea71559..de43ade784 100644 --- a/cmd/v/internal/help/build-c.txt +++ b/cmd/v/internal/help/build-c.txt @@ -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 + -csource 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. diff --git a/doc/docs.md b/doc/docs.md index d460449a94..b73c3c8fae 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -135,7 +135,7 @@ immutable by default. To be able to change the value of the variable, you have t Try compiling the program above after removing `mut` from the first line. -Please note the difference between `:=` and `=` +Please note the difference between `:=` and `=` `:=` is used for declaring and initializing, `=` is used for assigning. ```v @@ -1069,10 +1069,10 @@ fn test_hello() { All test functions have to be placed in `*_test.v` files and begin with `test_`. -You can also define a special test function: `testsuite_begin`, which will be +You can also define a special test function: `testsuite_begin`, which will be run *before* all other test functions in a `_test.v` file. -You can also define a special test function: `testsuite_end`, which will be +You can also define a special test function: `testsuite_end`, which will be run *after* all other test functions in a `_test.v` file. To run the tests do `v hello_test.v`. @@ -1295,7 +1295,7 @@ Module { ``` NB: @VROOT will be replaced by V with the *nearest parent folder, where there is a v.mod file*. Any .v file beside or below the folder where the v.mod file is, can use #flag @VROOT/abc to refer to this folder. -The @VROOT folder is also *prepended* to the module lookup path, so you can *import* other +The @VROOT folder is also *prepended* to the module lookup path, so you can *import* other modules under your @VROOT, by just naming them. The instructions above will make V look for an compiled .o file in your module folder/c/implementation.o . @@ -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`. diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index b0a511a1d4..60f1fe566a 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -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)