From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 3 Dec 2022 17:00:20 +0530 Subject: Adds most of the tools --- v_windows/v/old/cmd/tools/bench/wyhash.v | 56 + v_windows/v/old/cmd/tools/check_os_api_parity.v | 130 ++ v_windows/v/old/cmd/tools/fast/.gitignore | 5 + v_windows/v/old/cmd/tools/fast/fast.v | 178 ++ v_windows/v/old/cmd/tools/fast/fast_job.v | 43 + v_windows/v/old/cmd/tools/fast/fast_main.js | 67 + v_windows/v/old/cmd/tools/fast/footer.html | 4 + v_windows/v/old/cmd/tools/fast/header.html | 65 + v_windows/v/old/cmd/tools/fuzz/fuzz.sh | 18 + v_windows/v/old/cmd/tools/fuzz/map_fuzz.v | 144 ++ v_windows/v/old/cmd/tools/gen1m.v | 16 + v_windows/v/old/cmd/tools/gen_vc.v | 370 ++++ v_windows/v/old/cmd/tools/missdoc.v | 141 ++ .../v/old/cmd/tools/modules/scripting/scripting.v | 180 ++ v_windows/v/old/cmd/tools/modules/testing/common.v | 488 +++++ v_windows/v/old/cmd/tools/modules/vgit/vgit.v | 197 ++ v_windows/v/old/cmd/tools/modules/vhelp/vhelp.v | 14 + v_windows/v/old/cmd/tools/oldv.v | 176 ++ v_windows/v/old/cmd/tools/performance_compare.v | 215 ++ v_windows/v/old/cmd/tools/repeat.v | 374 ++++ .../v/old/cmd/tools/test_if_v_test_system_works.v | 74 + v_windows/v/old/cmd/tools/test_os_process.v | 82 + v_windows/v/old/cmd/tools/vast/cjson.v | 114 + v_windows/v/old/cmd/tools/vast/test/.gitignore | 1 + v_windows/v/old/cmd/tools/vast/test/demo.v | 121 ++ v_windows/v/old/cmd/tools/vast/vast.v | 2246 ++++++++++++++++++++ v_windows/v/old/cmd/tools/vbin2v.v | 146 ++ v_windows/v/old/cmd/tools/vbug.v | 208 ++ v_windows/v/old/cmd/tools/vbuild-examples.v | 15 + v_windows/v/old/cmd/tools/vbuild-tools.v | 71 + v_windows/v/old/cmd/tools/vbuild-vbinaries.v | 9 + v_windows/v/old/cmd/tools/vcheck-md.v | 540 +++++ v_windows/v/old/cmd/tools/vcomplete.v | 451 ++++ v_windows/v/old/cmd/tools/vcreate.v | 186 ++ v_windows/v/old/cmd/tools/vcreate_test.v | 79 + v_windows/v/old/cmd/tools/vdoc/html.v | 553 +++++ .../v/old/cmd/tools/vdoc/html_tag_escape_test.v | 6 + v_windows/v/old/cmd/tools/vdoc/markdown.v | 55 + v_windows/v/old/cmd/tools/vdoc/resources/arrow.svg | 1 + .../v/old/cmd/tools/vdoc/resources/dark-mode.js | 6 + v_windows/v/old/cmd/tools/vdoc/resources/dark.svg | 1 + v_windows/v/old/cmd/tools/vdoc/resources/doc.css | 725 +++++++ v_windows/v/old/cmd/tools/vdoc/resources/doc.js | 235 ++ .../resources/favicons/android-chrome-192x192.png | Bin 0 -> 6083 bytes .../resources/favicons/android-chrome-512x512.png | Bin 0 -> 18209 bytes .../vdoc/resources/favicons/apple-touch-icon.png | Bin 0 -> 5707 bytes .../vdoc/resources/favicons/browserconfig.xml | 9 + .../vdoc/resources/favicons/favicon-16x16.png | Bin 0 -> 853 bytes .../vdoc/resources/favicons/favicon-32x32.png | Bin 0 -> 1305 bytes .../cmd/tools/vdoc/resources/favicons/favicon.ico | Bin 0 -> 15086 bytes .../vdoc/resources/favicons/mstile-144x144.png | Bin 0 -> 4512 bytes .../vdoc/resources/favicons/mstile-150x150.png | Bin 0 -> 4360 bytes .../vdoc/resources/favicons/mstile-310x150.png | Bin 0 -> 4927 bytes .../vdoc/resources/favicons/mstile-310x310.png | Bin 0 -> 10195 bytes .../tools/vdoc/resources/favicons/mstile-70x70.png | Bin 0 -> 3093 bytes .../vdoc/resources/favicons/safari-pinned-tab.svg | 39 + .../tools/vdoc/resources/favicons/site.webmanifest | 19 + v_windows/v/old/cmd/tools/vdoc/resources/light.svg | 1 + v_windows/v/old/cmd/tools/vdoc/resources/link.svg | 1 + v_windows/v/old/cmd/tools/vdoc/resources/menu.svg | 1 + .../v/old/cmd/tools/vdoc/resources/normalize.css | 171 ++ .../tools/vdoc/tests/testdata/project1/main.out | 1 + .../cmd/tools/vdoc/tests/testdata/project1/main.v | 8 + .../v/old/cmd/tools/vdoc/tests/vdoc_file_test.v | 72 + v_windows/v/old/cmd/tools/vdoc/utils.v | 275 +++ v_windows/v/old/cmd/tools/vdoc/vdoc.v | 511 +++++ v_windows/v/old/cmd/tools/vdoctor.exe | Bin 0 -> 880128 bytes v_windows/v/old/cmd/tools/vdoctor.v | 264 +++ v_windows/v/old/cmd/tools/vfmt.v | 334 +++ v_windows/v/old/cmd/tools/vpm.exe | Bin 0 -> 962048 bytes v_windows/v/old/cmd/tools/vpm.v | 601 ++++++ v_windows/v/old/cmd/tools/vrepl.exe | Bin 0 -> 498688 bytes v_windows/v/old/cmd/tools/vrepl.v | 390 ++++ v_windows/v/old/cmd/tools/vself.exe | Bin 0 -> 432128 bytes v_windows/v/old/cmd/tools/vself.v | 89 + v_windows/v/old/cmd/tools/vsetup-freetype.v | 28 + v_windows/v/old/cmd/tools/vsymlink.v | 182 ++ v_windows/v/old/cmd/tools/vtest-all.v | 187 ++ v_windows/v/old/cmd/tools/vtest-cleancode.v | 102 + v_windows/v/old/cmd/tools/vtest-fmt.v | 43 + v_windows/v/old/cmd/tools/vtest-parser.v | 289 +++ v_windows/v/old/cmd/tools/vtest-self.v | 220 ++ v_windows/v/old/cmd/tools/vtest.v | 135 ++ v_windows/v/old/cmd/tools/vtracev.v | 17 + v_windows/v/old/cmd/tools/vup.exe | Bin 0 -> 1010176 bytes v_windows/v/old/cmd/tools/vup.v | 164 ++ .../cmd/tools/vvet/tests/array_init_one_val.out | 2 + .../old/cmd/tools/vvet/tests/array_init_one_val.vv | 5 + .../old/cmd/tools/vvet/tests/indent_with_space.out | 6 + .../old/cmd/tools/vvet/tests/indent_with_space.vv | 24 + .../old/cmd/tools/vvet/tests/module_file_test.out | 5 + .../v/old/cmd/tools/vvet/tests/module_file_test.vv | 55 + .../v/old/cmd/tools/vvet/tests/parens_space_a.out | 2 + .../v/old/cmd/tools/vvet/tests/parens_space_a.vv | 4 + .../v/old/cmd/tools/vvet/tests/parens_space_b.out | 2 + .../v/old/cmd/tools/vvet/tests/parens_space_b.vv | 4 + .../v/old/cmd/tools/vvet/tests/trailing_space.out | 7 + .../v/old/cmd/tools/vvet/tests/trailing_space.vv | 16 + v_windows/v/old/cmd/tools/vvet/vet_test.v | 72 + v_windows/v/old/cmd/tools/vvet/vvet.v | 256 +++ v_windows/v/old/cmd/tools/vwatch.exe | Bin 0 -> 560640 bytes v_windows/v/old/cmd/tools/vwatch.v | 381 ++++ v_windows/v/old/cmd/tools/vwipe-cache.v | 13 + v_windows/v/old/cmd/v/help/ast.txt | 12 + v_windows/v/old/cmd/v/help/bin2v.txt | 14 + v_windows/v/old/cmd/v/help/bug.txt | 8 + v_windows/v/old/cmd/v/help/build-c.txt | 240 +++ v_windows/v/old/cmd/v/help/build-js.txt | 22 + v_windows/v/old/cmd/v/help/build-native.txt | 17 + v_windows/v/old/cmd/v/help/build.txt | 157 ++ v_windows/v/old/cmd/v/help/check-md.txt | 22 + v_windows/v/old/cmd/v/help/default.txt | 60 + v_windows/v/old/cmd/v/help/doc.txt | 34 + v_windows/v/old/cmd/v/help/doctor.txt | 3 + v_windows/v/old/cmd/v/help/fmt.txt | 35 + v_windows/v/old/cmd/v/help/help.v | 47 + v_windows/v/old/cmd/v/help/help_test.v | 22 + v_windows/v/old/cmd/v/help/init.txt | 4 + v_windows/v/old/cmd/v/help/install.txt | 10 + v_windows/v/old/cmd/v/help/list.txt | 3 + v_windows/v/old/cmd/v/help/new.txt | 18 + v_windows/v/old/cmd/v/help/other.txt | 33 + v_windows/v/old/cmd/v/help/outdated.txt | 3 + v_windows/v/old/cmd/v/help/remove.txt | 9 + v_windows/v/old/cmd/v/help/repl.txt | 3 + v_windows/v/old/cmd/v/help/run.txt | 13 + v_windows/v/old/cmd/v/help/search.txt | 10 + v_windows/v/old/cmd/v/help/self.txt | 5 + v_windows/v/old/cmd/v/help/show.txt | 3 + v_windows/v/old/cmd/v/help/symlink.txt | 5 + v_windows/v/old/cmd/v/help/test.txt | 18 + v_windows/v/old/cmd/v/help/tracev.txt | 3 + v_windows/v/old/cmd/v/help/up.txt | 7 + v_windows/v/old/cmd/v/help/update.txt | 10 + v_windows/v/old/cmd/v/help/upgrade.txt | 7 + v_windows/v/old/cmd/v/help/version.txt | 3 + v_windows/v/old/cmd/v/help/vet.txt | 18 + v_windows/v/old/cmd/v/help/vpm.txt | 8 + v_windows/v/old/cmd/v/help/watch.txt | 28 + v_windows/v/old/cmd/v/v.v | 146 ++ 140 files changed, 14873 insertions(+) create mode 100644 v_windows/v/old/cmd/tools/bench/wyhash.v create mode 100644 v_windows/v/old/cmd/tools/check_os_api_parity.v create mode 100644 v_windows/v/old/cmd/tools/fast/.gitignore create mode 100644 v_windows/v/old/cmd/tools/fast/fast.v create mode 100644 v_windows/v/old/cmd/tools/fast/fast_job.v create mode 100644 v_windows/v/old/cmd/tools/fast/fast_main.js create mode 100644 v_windows/v/old/cmd/tools/fast/footer.html create mode 100644 v_windows/v/old/cmd/tools/fast/header.html create mode 100644 v_windows/v/old/cmd/tools/fuzz/fuzz.sh create mode 100644 v_windows/v/old/cmd/tools/fuzz/map_fuzz.v create mode 100644 v_windows/v/old/cmd/tools/gen1m.v create mode 100644 v_windows/v/old/cmd/tools/gen_vc.v create mode 100644 v_windows/v/old/cmd/tools/missdoc.v create mode 100644 v_windows/v/old/cmd/tools/modules/scripting/scripting.v create mode 100644 v_windows/v/old/cmd/tools/modules/testing/common.v create mode 100644 v_windows/v/old/cmd/tools/modules/vgit/vgit.v create mode 100644 v_windows/v/old/cmd/tools/modules/vhelp/vhelp.v create mode 100644 v_windows/v/old/cmd/tools/oldv.v create mode 100644 v_windows/v/old/cmd/tools/performance_compare.v create mode 100644 v_windows/v/old/cmd/tools/repeat.v create mode 100644 v_windows/v/old/cmd/tools/test_if_v_test_system_works.v create mode 100644 v_windows/v/old/cmd/tools/test_os_process.v create mode 100644 v_windows/v/old/cmd/tools/vast/cjson.v create mode 100644 v_windows/v/old/cmd/tools/vast/test/.gitignore create mode 100644 v_windows/v/old/cmd/tools/vast/test/demo.v create mode 100644 v_windows/v/old/cmd/tools/vast/vast.v create mode 100644 v_windows/v/old/cmd/tools/vbin2v.v create mode 100644 v_windows/v/old/cmd/tools/vbug.v create mode 100644 v_windows/v/old/cmd/tools/vbuild-examples.v create mode 100644 v_windows/v/old/cmd/tools/vbuild-tools.v create mode 100644 v_windows/v/old/cmd/tools/vbuild-vbinaries.v create mode 100644 v_windows/v/old/cmd/tools/vcheck-md.v create mode 100644 v_windows/v/old/cmd/tools/vcomplete.v create mode 100644 v_windows/v/old/cmd/tools/vcreate.v create mode 100644 v_windows/v/old/cmd/tools/vcreate_test.v create mode 100644 v_windows/v/old/cmd/tools/vdoc/html.v create mode 100644 v_windows/v/old/cmd/tools/vdoc/html_tag_escape_test.v create mode 100644 v_windows/v/old/cmd/tools/vdoc/markdown.v create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/arrow.svg create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/dark-mode.js create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/dark.svg create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/doc.css create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/doc.js create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/android-chrome-192x192.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/android-chrome-512x512.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/apple-touch-icon.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/browserconfig.xml create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/favicon-16x16.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/favicon-32x32.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/favicon.ico create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/mstile-144x144.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/mstile-150x150.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/mstile-310x150.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/mstile-310x310.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/mstile-70x70.png create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/safari-pinned-tab.svg create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/favicons/site.webmanifest create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/light.svg create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/link.svg create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/menu.svg create mode 100644 v_windows/v/old/cmd/tools/vdoc/resources/normalize.css create mode 100644 v_windows/v/old/cmd/tools/vdoc/tests/testdata/project1/main.out create mode 100644 v_windows/v/old/cmd/tools/vdoc/tests/testdata/project1/main.v create mode 100644 v_windows/v/old/cmd/tools/vdoc/tests/vdoc_file_test.v create mode 100644 v_windows/v/old/cmd/tools/vdoc/utils.v create mode 100644 v_windows/v/old/cmd/tools/vdoc/vdoc.v create mode 100644 v_windows/v/old/cmd/tools/vdoctor.exe create mode 100644 v_windows/v/old/cmd/tools/vdoctor.v create mode 100644 v_windows/v/old/cmd/tools/vfmt.v create mode 100644 v_windows/v/old/cmd/tools/vpm.exe create mode 100644 v_windows/v/old/cmd/tools/vpm.v create mode 100644 v_windows/v/old/cmd/tools/vrepl.exe create mode 100644 v_windows/v/old/cmd/tools/vrepl.v create mode 100644 v_windows/v/old/cmd/tools/vself.exe create mode 100644 v_windows/v/old/cmd/tools/vself.v create mode 100644 v_windows/v/old/cmd/tools/vsetup-freetype.v create mode 100644 v_windows/v/old/cmd/tools/vsymlink.v create mode 100644 v_windows/v/old/cmd/tools/vtest-all.v create mode 100644 v_windows/v/old/cmd/tools/vtest-cleancode.v create mode 100644 v_windows/v/old/cmd/tools/vtest-fmt.v create mode 100644 v_windows/v/old/cmd/tools/vtest-parser.v create mode 100644 v_windows/v/old/cmd/tools/vtest-self.v create mode 100644 v_windows/v/old/cmd/tools/vtest.v create mode 100644 v_windows/v/old/cmd/tools/vtracev.v create mode 100644 v_windows/v/old/cmd/tools/vup.exe create mode 100644 v_windows/v/old/cmd/tools/vup.v create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/array_init_one_val.out create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/array_init_one_val.vv create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/indent_with_space.out create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/indent_with_space.vv create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/module_file_test.out create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/module_file_test.vv create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/parens_space_a.out create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/parens_space_a.vv create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/parens_space_b.out create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/parens_space_b.vv create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/trailing_space.out create mode 100644 v_windows/v/old/cmd/tools/vvet/tests/trailing_space.vv create mode 100644 v_windows/v/old/cmd/tools/vvet/vet_test.v create mode 100644 v_windows/v/old/cmd/tools/vvet/vvet.v create mode 100644 v_windows/v/old/cmd/tools/vwatch.exe create mode 100644 v_windows/v/old/cmd/tools/vwatch.v create mode 100644 v_windows/v/old/cmd/tools/vwipe-cache.v create mode 100644 v_windows/v/old/cmd/v/help/ast.txt create mode 100644 v_windows/v/old/cmd/v/help/bin2v.txt create mode 100644 v_windows/v/old/cmd/v/help/bug.txt create mode 100644 v_windows/v/old/cmd/v/help/build-c.txt create mode 100644 v_windows/v/old/cmd/v/help/build-js.txt create mode 100644 v_windows/v/old/cmd/v/help/build-native.txt create mode 100644 v_windows/v/old/cmd/v/help/build.txt create mode 100644 v_windows/v/old/cmd/v/help/check-md.txt create mode 100644 v_windows/v/old/cmd/v/help/default.txt create mode 100644 v_windows/v/old/cmd/v/help/doc.txt create mode 100644 v_windows/v/old/cmd/v/help/doctor.txt create mode 100644 v_windows/v/old/cmd/v/help/fmt.txt create mode 100644 v_windows/v/old/cmd/v/help/help.v create mode 100644 v_windows/v/old/cmd/v/help/help_test.v create mode 100644 v_windows/v/old/cmd/v/help/init.txt create mode 100644 v_windows/v/old/cmd/v/help/install.txt create mode 100644 v_windows/v/old/cmd/v/help/list.txt create mode 100644 v_windows/v/old/cmd/v/help/new.txt create mode 100644 v_windows/v/old/cmd/v/help/other.txt create mode 100644 v_windows/v/old/cmd/v/help/outdated.txt create mode 100644 v_windows/v/old/cmd/v/help/remove.txt create mode 100644 v_windows/v/old/cmd/v/help/repl.txt create mode 100644 v_windows/v/old/cmd/v/help/run.txt create mode 100644 v_windows/v/old/cmd/v/help/search.txt create mode 100644 v_windows/v/old/cmd/v/help/self.txt create mode 100644 v_windows/v/old/cmd/v/help/show.txt create mode 100644 v_windows/v/old/cmd/v/help/symlink.txt create mode 100644 v_windows/v/old/cmd/v/help/test.txt create mode 100644 v_windows/v/old/cmd/v/help/tracev.txt create mode 100644 v_windows/v/old/cmd/v/help/up.txt create mode 100644 v_windows/v/old/cmd/v/help/update.txt create mode 100644 v_windows/v/old/cmd/v/help/upgrade.txt create mode 100644 v_windows/v/old/cmd/v/help/version.txt create mode 100644 v_windows/v/old/cmd/v/help/vet.txt create mode 100644 v_windows/v/old/cmd/v/help/vpm.txt create mode 100644 v_windows/v/old/cmd/v/help/watch.txt create mode 100644 v_windows/v/old/cmd/v/v.v (limited to 'v_windows/v/old/cmd') diff --git a/v_windows/v/old/cmd/tools/bench/wyhash.v b/v_windows/v/old/cmd/tools/bench/wyhash.v new file mode 100644 index 0000000..b760ad6 --- /dev/null +++ b/v_windows/v/old/cmd/tools/bench/wyhash.v @@ -0,0 +1,56 @@ +module main + +import hash.fnv1a +import hash as wyhash +import rand +import benchmark + +fn main() { + rand.seed([u32(42), 0]) + sample_size := 10000000 + min_str_len := 20 + max_str_len := 40 + println('Generating $sample_size strings between $min_str_len - $max_str_len chars long...') + mut checksum := u64(0) + mut start_pos := 0 + mut bgenerating := benchmark.start() + mut bytepile := []byte{} + for _ in 0 .. sample_size * max_str_len { + bytepile << byte(rand.int_in_range(40, 125)) + } + mut str_lens := []int{} + for _ in 0 .. sample_size { + str_lens << rand.int_in_range(min_str_len, max_str_len) + } + bgenerating.measure('generating strings') + println('Hashing each of the generated strings...') + // + mut bhashing_1 := benchmark.start() + start_pos = 0 + checksum = 0 + for len in str_lens { + end_pos := start_pos + len + checksum ^= wyhash.wyhash_c(unsafe { &byte(bytepile.data) + start_pos }, u64(len), + 1) + start_pos = end_pos + } + bhashing_1.measure('wyhash.wyhash_c | checksum: ${checksum:22}') + mut bhashing_2 := benchmark.start() + start_pos = 0 + checksum = 0 + for len in str_lens { + end_pos := start_pos + len + checksum ^= wyhash.sum64(bytepile[start_pos..end_pos], 1) + start_pos = end_pos + } + bhashing_2.measure('wyhash.sum64 | checksum: ${checksum:22}') + mut bhashing_3 := benchmark.start() + start_pos = 0 + checksum = 0 + for len in str_lens { + end_pos := start_pos + len + checksum ^= fnv1a.sum64(bytepile[start_pos..end_pos]) + start_pos = end_pos + } + bhashing_3.measure('fnv1a.sum64 | checksum: ${checksum:22}') +} diff --git a/v_windows/v/old/cmd/tools/check_os_api_parity.v b/v_windows/v/old/cmd/tools/check_os_api_parity.v new file mode 100644 index 0000000..d4b925c --- /dev/null +++ b/v_windows/v/old/cmd/tools/check_os_api_parity.v @@ -0,0 +1,130 @@ +module main + +import os +import v.util +import v.util.diff +import v.pref +import v.builder +import v.ast +import rand +import term + +const ( + base_os = 'linux' + os_names = ['linux', 'macos', 'windows'] + skip_modules = [ + 'builtin.bare', + 'builtin.linux_bare.old', + 'builtin.js', + 'strconv', + 'strconv.ftoa', + 'hash', + 'strings', + 'crypto.rand', + 'os.bare', + 'os2', + 'picohttpparser', + 'picoev', + 'szip', + 'v.eval', + ] +) + +struct App { + diff_cmd string + is_verbose bool + modules []string +mut: + api_differences map[string]int +} + +fn main() { + vexe := pref.vexe_path() + vroot := os.dir(vexe) + util.set_vroot_folder(vroot) + os.chdir(vroot) + cmd := diff.find_working_diff_command() or { '' } + mut app := App{ + diff_cmd: cmd + is_verbose: os.getenv('VERBOSE').len > 0 + modules: if os.args.len > 1 { os.args[1..] } else { all_vlib_modules() } + } + for mname in app.modules { + if !app.is_verbose { + eprintln('Checking module: $mname ...') + } + api_base := app.gen_api_for_module_in_os(mname, base_os) + for oname in os_names { + if oname == base_os { + continue + } + api_os := app.gen_api_for_module_in_os(mname, oname) + app.compare_api(api_base, api_os, mname, base_os, oname) + } + } + howmany := app.api_differences.len + if howmany > 0 { + eprintln(term.header('Found $howmany modules with different APIs', '=')) + for m in app.api_differences.keys() { + eprintln('Module: $m') + } + exit(1) + } +} + +fn all_vlib_modules() []string { + mut vlib_v_files := os.walk_ext('vlib', '.v') + mut vmodulesmap := map[string]int{} + for f in vlib_v_files { + if f.contains('/tests/') || f.ends_with('_test.v') { + continue + } + vmodulename := os.dir(f).replace('/', '.').replace('vlib.', '') + if vmodulename in skip_modules { + continue + } + vmodulesmap[vmodulename] = vmodulesmap[vmodulename] + 1 + } + mut modules := vmodulesmap.keys() + modules.sort() + return modules +} + +fn (app App) gen_api_for_module_in_os(mod_name string, os_name string) string { + if app.is_verbose { + eprintln('Checking module: ${mod_name:-30} for OS: ${os_name:-10} ...') + } + mpath := os.join_path('vlib', mod_name.replace('.', '/')) + tmpname := '/tmp/${mod_name}_${os_name}.c' + prefs, _ := pref.parse_args([], ['-os', os_name, '-o', tmpname, '-shared', mpath]) + mut b := builder.new_builder(prefs) + b.compile_c() + mut res := []string{} + for f in b.parsed_files { + for s in f.stmts { + if s is ast.FnDecl { + if s.is_pub { + fn_signature := s.stringify(b.table, mod_name, map[string]string{}) + fn_mod := s.modname() + if fn_mod == mod_name { + fline := '$fn_mod: $fn_signature' + res << fline + } + } + } + } + } + res.sort() + return res.join('\n') +} + +fn (mut app App) compare_api(api_base string, api_os string, mod_name string, os_base string, os_target string) { + res := diff.color_compare_strings(app.diff_cmd, rand.ulid(), api_base, api_os) + if res.len > 0 { + summary := 'Different APIs found for module: `$mod_name`, between OS base: `$os_base` and OS: `$os_target`' + eprintln(term.header(summary, '-')) + eprintln(res) + eprintln(term.h_divider('-')) + app.api_differences[mod_name] = 1 + } +} diff --git a/v_windows/v/old/cmd/tools/fast/.gitignore b/v_windows/v/old/cmd/tools/fast/.gitignore new file mode 100644 index 0000000..1efae28 --- /dev/null +++ b/v_windows/v/old/cmd/tools/fast/.gitignore @@ -0,0 +1,5 @@ +fast +index.html +table.html +v.c +v2 diff --git a/v_windows/v/old/cmd/tools/fast/fast.v b/v_windows/v/old/cmd/tools/fast/fast.v new file mode 100644 index 0000000..0b9f05a --- /dev/null +++ b/v_windows/v/old/cmd/tools/fast/fast.v @@ -0,0 +1,178 @@ +// Copyright (c) 2019-2021 Alexander Medvednikov. All rights reserved. +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file. +import os +import time + +// TODO -usecache +const voptions = ' -skip-unused -show-timings -stats ' + +const exe = os.executable() + +const fast_dir = os.dir(exe) + +const vdir = @VEXEROOT + +fn main() { + dump(fast_dir) + dump(vdir) + os.chdir(fast_dir) + if !os.exists('$vdir/v') && !os.is_dir('$vdir/vlib') { + println('fast.html generator needs to be located in `v/cmd/tools/fast`') + } + println('fast.html generator\n') + println('Fetching updates...') + ret := os.system('$vdir/v up') + if ret != 0 { + println('failed to update V') + return + } + // Fetch the last commit's hash + commit := exec('git rev-parse HEAD')[..8] + if !os.exists('table.html') { + os.create('table.html') ? + } + mut table := os.read_file('table.html') ? + if table.contains('>$commit<') { + println('nothing to benchmark') + exit(1) + return + } + // for i, commit in commits { + message := exec('git log --pretty=format:"%s" -n1 $commit') + // println('\n${i + 1}/$commits.len Benchmarking commit $commit "$message"') + println('\nBenchmarking commit $commit "$message"') + // Build an optimized V + // println('Checking out ${commit}...') + // exec('git checkout $commit') + println(' Building vprod...') + os.chdir(vdir) + exec('./v -o vprod -prod -prealloc cmd/v') + // println('cur vdir="$vdir"') + // exec('v -o vprod cmd/v') // for faster debugging + // cache vlib modules + exec('$vdir/v wipe-cache') + exec('$vdir/v -o v2 -prod cmd/v') + // measure + diff1 := measure('$vdir/vprod $voptions -o v.c cmd/v', 'v.c') + mut tcc_path := 'tcc' + $if freebsd { + tcc_path = '/usr/local/bin/tcc' + } + diff2 := measure('$vdir/vprod $voptions -cc $tcc_path -o v2 cmd/v', 'v2') + diff3 := 0 // measure('$vdir/vprod -native $vdir/cmd/tools/1mil.v', 'native 1mil') + diff4 := measure('$vdir/vprod -usecache $voptions -cc clang examples/hello_world.v', + 'hello.v') + vc_size := os.file_size('v.c') / 1000 + // scan/parse/check/cgen + scan, parse, check, cgen, vlines := measure_steps(vdir) + // println('Building V took ${diff}ms') + commit_date := exec('git log -n1 --pretty="format:%at" $commit') + date := time.unix(commit_date.int()) + // + os.chdir(fast_dir) + mut out := os.create('table.html') ? + // Place the new row on top + html_message := message.replace_each(['<', '<', '>', '>']) + table = + '