Compare commits
323 Commits
12ec3b9d53
...
9a0f499506
Author | SHA1 | Date |
---|---|---|
Jef Roosens | 9a0f499506 | |
Jef Roosens | b21fa77baf | |
Delyan Angelov | da42f0d42b | |
Delyan Angelov | 3fc4459485 | |
yuyi | 020845f6c3 | |
yuyi | d7b1e57186 | |
yuyi | 60e817ff32 | |
yuyi | d6aa85d059 | |
playX | 7c6eaa8204 | |
Delyan Angelov | 78ab3296c9 | |
WoodyAtHome | 02c8a6057c | |
Alexander Medvednikov | d10f83ce15 | |
playX | bc397bb0e1 | |
Delyan Angelov | 32dd801201 | |
Delyan Angelov | 9cb8bb2968 | |
yuyi | c624de8523 | |
Delyan Angelov | e5c7fe3006 | |
Delyan Angelov | 39874ae168 | |
yuyi | d59f4e9479 | |
Larpon | ef6225c542 | |
yuyi | 0ab4133128 | |
spaceface | 36bec823c2 | |
WoodyAtHome | c2b763655d | |
Delyan Angelov | 1cf683d482 | |
Delyan Angelov | b4c529066a | |
Ben | cbb24d34c9 | |
yuyi | 7fe3ef9a6e | |
Larpon | 5068b8b293 | |
Jah-On | 02e026e298 | |
WoodyAtHome | eeff02a8ee | |
spaceface | c01a8a1737 | |
Delyan Angelov | c2bc9f4960 | |
crthpl | e4065bd57b | |
David 'Epper' Marshall | c28051020a | |
Delyan Angelov | b50f7fdc71 | |
Delyan Angelov | c70e18ea8f | |
Delyan Angelov | 3a09ccc80a | |
Larpon | dd6629e932 | |
David 'Epper' Marshall | 8d141878ce | |
Delyan Angelov | 67963e0ff2 | |
Delyan Angelov | 1225a865a3 | |
yuyi | fe9f97074b | |
Alexander Medvednikov | 3adad32355 | |
Alexander Medvednikov | b42c824cdb | |
Daniel Däschle | f0d46413d9 | |
JalonSolov | b3e80a3100 | |
j. redhead | 441637eeb4 | |
Delyan Angelov | cee7856c0f | |
Delyan Angelov | 714ce4e7fc | |
Delyan Angelov | c1bafe7a5a | |
playX | 6ec4185017 | |
Daniel Däschle | d407a6449d | |
Delyan Angelov | ed12a5c84c | |
yuyi | 3c95504a35 | |
Daniel Däschle | d679146a80 | |
Delyan Angelov | df029da942 | |
Daniel Däschle | 0972e67f72 | |
Delyan Angelov | 8ef9dc6247 | |
Delyan Angelov | 668d1b04d2 | |
Hunam | 20139ad756 | |
playX | 4952967366 | |
yuyi | f48f7014f0 | |
penguindark | e93a8766e5 | |
Delyan Angelov | b7ca4c1668 | |
yuyi | 8830af5c89 | |
yuyi | 5bc4fea9e0 | |
CC | 901b8f0c24 | |
spaceface | 49382f1f43 | |
Emily Hudson | c19b037880 | |
yuyi | cd4fa041ff | |
Larpon | 34a252ef84 | |
David 'Epper' Marshall | 26b81d68b5 | |
Larpon | 0ec1c8d9f0 | |
yuyi | 3afc7c4c6d | |
Delyan Angelov | cf536b848b | |
yuyi | 8f765ed5f1 | |
yuyi | 5697d4375b | |
yuyi | 606d8cfaca | |
Isaiah | 9e09b709e3 | |
yuyi | 940c78bdfd | |
Subhomoy Haldar | 79f8a3c796 | |
StunxFS | d24dce8eb3 | |
Dialga | 4400f9891e | |
yuyi | 8519996201 | |
Merlin Diavova | 106487d62f | |
David 'Epper' Marshall | 650fb493bd | |
Delyan Angelov | 084f2867b6 | |
WoodyAtHome | a0a3499bdc | |
Alexander Medvednikov | 0526499d5f | |
Merlin Diavova | f8747d05dc | |
StunxFS | d5e70552eb | |
David 'Epper' Marshall | aef95721a4 | |
yuyi | b04d46770b | |
yuyi | 724e7f037a | |
David 'Epper' Marshall | a91226c376 | |
Delyan Angelov | b53b1cc7cb | |
Delyan Angelov | 7ecd65221e | |
Delyan Angelov | 56cf0b0a2e | |
Delyan Angelov | 7f974a275a | |
Delyan Angelov | f956acd2f6 | |
Delyan Angelov | 9e8e364493 | |
Alexander Medvednikov | ca42ace367 | |
Alexander Medvednikov | 35cfa0da7c | |
playX | 6a6c005dc0 | |
Alexander Medvednikov | 9fb8de14dd | |
Alexander Medvednikov | 89c1e7f980 | |
yuyi | 70184ad1f8 | |
Alexander Medvednikov | 14f06ead1b | |
yuyi | 621574c12a | |
Hunam | 0699f324b5 | |
Lathanao | ce99a306c0 | |
StunxFS | 87de6df0e6 | |
Ekopalypse | 2027a1969b | |
Daniel Däschle | 76cdf75299 | |
yuyi | 45fe87c9e3 | |
yuyi | 3091f31019 | |
Claudio Cesar de Sá | 634796ae42 | |
Andréas Livet | 9fde5b067b | |
Daniel Däschle | 89fe82b732 | |
yuyi | b6058bfd6e | |
playX | 8afdb1c3ef | |
StunxFS | 7499506cf8 | |
Delyan Angelov | 785e9af8f1 | |
Delyan Angelov | 7170a09382 | |
Delyan Angelov | 01c1892995 | |
Delyan Angelov | a6b3e5d6a5 | |
Ned | 76a7354506 | |
yuyi | 4242e7610f | |
yuyi | e2aa5c9b3f | |
Ikko Ashimine | 223b96a59a | |
Delyan Angelov | 1a4d9017e2 | |
Alexander Medvednikov | af8be14639 | |
yuyi | ac90a2b53d | |
playX | 3bd6455178 | |
Alexander Medvednikov | 3d4b8dffdf | |
yuyi | f321422964 | |
Alexander Medvednikov | 1e9156fd71 | |
yuyi | 3732db2bcc | |
playX | 146051b231 | |
Delyan Angelov | 04a77c731e | |
yuyi | 63eacede95 | |
Hunam | 6da300428e | |
yuyi | 276bd8060c | |
Delyan Angelov | 0e5c1cee48 | |
Delyan Angelov | 4da2908d63 | |
StunxFS | cf92224248 | |
Delyan Angelov | ab1c265679 | |
spaceface | db185598d2 | |
yuyi | 990afe37e1 | |
yuyi | d72a25098a | |
yuyi | 25c1b174ca | |
yuyi | b9cf2db6a8 | |
playX | afbe6bf3a2 | |
Isaiah | a4fd349cf1 | |
yuyi | 968d2b4654 | |
spaceface | 332e821518 | |
Delyan Angelov | aed2d0caf2 | |
David 'Epper' Marshall | 91c1157810 | |
Daniel Däschle | ec92d467d1 | |
playX | 0b54196962 | |
Daniel Däschle | 9f8a34a528 | |
Delyan Angelov | 63d413f93c | |
Delyan Angelov | c0b37409d2 | |
Delyan Angelov | 8da42bfc85 | |
Delyan Angelov | 5277ce7dce | |
David 'Epper' Marshall | a2338dbb7c | |
Delyan Angelov | dcdfdf4dd8 | |
spaceface | dab649ec8a | |
Alexander Medvednikov | ce31a01a70 | |
yuyi | cd30b6ea82 | |
Daniel Däschle | 08fd0ce0de | |
StunxFS | db185e6580 | |
Benjamin Thomas | 48eb40cd2c | |
David 'Epper' Marshall | 881d0c04f1 | |
yuyi | ec865cfb37 | |
yuyi | 317acfda97 | |
Wertzui123 | 872f739396 | |
StunxFS | 995485c649 | |
StunxFS | 8b798acadd | |
Alexander Medvednikov | 77645fcf35 | |
spaceface | 14309594fe | |
David 'Epper' Marshall | 5a42350a78 | |
StunxFS | e24482a143 | |
playX | e56385d57d | |
yuyi | 7aca67fb60 | |
yuyi | dd94ab890a | |
yuyi | c802688690 | |
Atom | a225b25117 | |
Delyan Angelov | 4538efd8f4 | |
Delyan Angelov | e0ed8f8278 | |
Delyan Angelov | f72297c331 | |
Delyan Angelov | be04ec0620 | |
yuyi | 7dd5d9ee61 | |
yuyi | 09f8b6a380 | |
tzSharing | eb03fad934 | |
Delyan Angelov | f53b9b4f12 | |
Alexander Medvednikov | 7dbfa86f25 | |
yuyi | 82ac39eca6 | |
yuyi | 752e105f25 | |
tzSharing | 85f616877f | |
playX | b76095f28a | |
R cqls | c26b7666c7 | |
yuyi | be513b4c27 | |
Larpon | 1c48a8d760 | |
yuyi | 660201c188 | |
Brian Callahan | b9a0e2d285 | |
yuyi | 38afd74d26 | |
playX | 95880dfe5c | |
playX | dce2173ac9 | |
Alexander Medvednikov | 501b293e84 | |
Larpon | d799abd139 | |
yuyi | e42dc8e228 | |
yuyi | f89c81087b | |
yuyi | aeba110d01 | |
Larpon | 283d181047 | |
yuyi | 88f22b4367 | |
Delyan Angelov | 60e205a193 | |
Delyan Angelov | d35d67c2bd | |
Nick Treleaven | d8a5df9044 | |
Delyan Angelov | 147e6e669f | |
yuyi | 922cee9162 | |
Delyan Angelov | 1291b621f6 | |
fleur | ddbe812f1b | |
Haren S | 11ee2b6409 | |
stackotter | 563469ed9f | |
yuyi | c819f0f86f | |
Alexander Medvednikov | 9355048b6c | |
Delyan Angelov | 3388caa6c5 | |
Delyan Angelov | 365e7d6b34 | |
yuyi | d934472b17 | |
yuyi | b86320a669 | |
Claudio Cesar de Sá | a2db44bc38 | |
yuyi | 5dce091379 | |
Alexander Medvednikov | 9b565bf765 | |
tzSharing | 03d21a727e | |
Larpon | 506259adb6 | |
yuyi | 26b0e7fd34 | |
Delyan Angelov | 2080557f50 | |
yuyi | 8a18f9175a | |
yuyi | 448938be0d | |
yuyi | 99eb9fdaab | |
yuyi | f13583b04a | |
yuyi | 8013bd43b0 | |
Delyan Angelov | 5e8c4a3aff | |
StunxFS | 2a0b372d0d | |
ChAoS_UnItY | c5824c36f2 | |
Delyan Angelov | c789ea5a15 | |
sunnylcw | 4491b535ec | |
Delyan Angelov | 31b28af179 | |
lemon | 960225f7a7 | |
Nick Treleaven | 1533b77404 | |
yuyi | 0260c2a552 | |
Hunam | 0374f021c5 | |
mjh | 1546645f63 | |
Larpon | a1342e85c3 | |
yuyi | 52ea0b8cc3 | |
yuyi | ce4c2afc9c | |
yuyi | 44ba19716b | |
yuyi | 0c3b69eaef | |
Alexander Medvednikov | 364656b312 | |
Isaiah | 0887b59254 | |
yuyi | 8cc79e4299 | |
playX | 711e90cf99 | |
playX | f6a0c26a85 | |
Delyan Angelov | 9646e4b9d8 | |
Delyan Angelov | 006df58451 | |
JalonSolov | daf5d32327 | |
yuyi | a318a2e09e | |
yuyi | e16ce3af88 | |
yuyi | 6164654d11 | |
Nick Treleaven | 4400efeb9f | |
yuyi | 7ef64bde50 | |
yuyi | d0a11f50ca | |
Delyan Angelov | 379b638b57 | |
yuyi | fe371845da | |
spaceface | 775c4c34b5 | |
Ikko Ashimine | 56a3539ea9 | |
yuyi | 17c34b09a6 | |
yuyi | cb44f5981e | |
Vincenzo Palazzo | 4f14f7714f | |
Vincenzo Palazzo | 48486e1afb | |
Cameron Katri | 1fc54a1e5b | |
Delyan Angelov | 8a57f7ed2d | |
Julien de Carufel | 16ead4e63c | |
Alexander Medvednikov | 43931a8e77 | |
Delyan Angelov | 5b7e538119 | |
Delyan Angelov | 4a71b27c52 | |
Delyan Angelov | d75c408868 | |
Delyan Angelov | 82c5621621 | |
Delyan Angelov | 675f8b6300 | |
Delyan Angelov | ad231cec2f | |
Delyan Angelov | 87a373d82c | |
Delyan Angelov | c7aedb8e8d | |
Delyan Angelov | 375361b787 | |
Delyan Angelov | 840f474fb5 | |
Delyan Angelov | e802e0b9cb | |
Delyan Angelov | bb2a324d61 | |
Delyan Angelov | 868d3e1008 | |
Alexander Medvednikov | c03fe020bf | |
Delyan Angelov | 6f5a513d8b | |
Delyan Angelov | e18cb9748f | |
Delyan Angelov | 173e6a943b | |
Delyan Angelov | cc8803c602 | |
Alexander Medvednikov | 78cb6e2b41 | |
Alexander Medvednikov | 1c6f63ac0a | |
Alexander Medvednikov | fbb9e65c0f | |
Alexander Medvednikov | ae6a25f44e | |
Alexander Medvednikov | e97ebf8cfc | |
Alexander Medvednikov | 258d1f77dc | |
Alexander Medvednikov | af73e195da | |
Alexander Medvednikov | fb192d949b | |
Alexander Medvednikov | 0527ac633e | |
Alexander Medvednikov | dbcf6e9c33 | |
Alexander Medvednikov | c14984899b | |
Alexander Medvednikov | a1372e284c | |
Alexander Medvednikov | c3ad4e2069 | |
Alexander Medvednikov | d4a0d6f73c | |
Alexander Medvednikov | b49d873217 | |
Alexander Medvednikov | 014c3c97f0 | |
Alexander Medvednikov | 7f3b91e688 | |
Alexander Medvednikov | 1e7eb713fb | |
Alexander Medvednikov | ba7b329c73 | |
Alexander Medvednikov | e6ff1508d2 |
|
@ -15,6 +15,8 @@ ls -lat
|
|||
## try running the known failing tests first to get faster feedback
|
||||
./v test vlib/builtin/string_test.v vlib/strings/builder_test.v
|
||||
|
||||
./v test-cleancode
|
||||
|
||||
./v test-self
|
||||
|
||||
./v build-vbinaries
|
||||
|
|
|
@ -33,6 +33,7 @@ jobs:
|
|||
run: |
|
||||
echo $VFLAGS
|
||||
make
|
||||
./v test-cleancode
|
||||
./v -d debug_malloc -d debug_realloc -o v cmd/v
|
||||
./v -cg -cstrict -o v cmd/v
|
||||
# Test v -realloc arena allocation
|
||||
|
@ -54,6 +55,8 @@ jobs:
|
|||
echo $VFLAGS
|
||||
./v cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests
|
||||
run: ./v test-self
|
||||
# - name: Self tests (-cstrict)
|
||||
|
@ -125,13 +128,15 @@ jobs:
|
|||
run: |
|
||||
./v -gc boehm cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests with `-gc boehm` with V compiler using Boehm-GC itself
|
||||
run: ./v -gc boehm test-self
|
||||
- name: Test leak detector
|
||||
run: |
|
||||
./v -gc boehm_leak -o testcase_leak vlib/v/tests/testcase_leak.vv
|
||||
./testcase_leak 2>leaks.txt
|
||||
grep "Found 1 leaked object" leaks.txt && grep ", sz=1000," leaks.txt
|
||||
grep "Found 1 leaked object" leaks.txt && grep -P ", sz=\s?1000," leaks.txt
|
||||
- name: Test leak detector not being active for `-gc boehm`
|
||||
run: |
|
||||
./v -gc boehm -o testcase_leak vlib/v/tests/testcase_leak.vv
|
||||
|
@ -188,6 +193,8 @@ jobs:
|
|||
echo $VFLAGS
|
||||
./v cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests
|
||||
run: VJOBS=1 ./v test-self
|
||||
- name: Build examples
|
||||
|
@ -280,6 +287,8 @@ jobs:
|
|||
echo $VFLAGS
|
||||
./v cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests
|
||||
run: ./v test-self
|
||||
- name: Self tests (-prod)
|
||||
|
@ -372,6 +381,8 @@ jobs:
|
|||
echo $VFLAGS
|
||||
./v cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests
|
||||
run: ./v test-self
|
||||
- name: Self tests (-prod)
|
||||
|
@ -429,7 +440,7 @@ jobs:
|
|||
- name: Test new v.c
|
||||
run: |
|
||||
.\v.exe -o v.c cmd/v
|
||||
gcc -Werror -I ./thirdparty/stdatomic/win -municode -w v.c
|
||||
gcc -Werror -municode -w v.c
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
.\v.exe setup-freetype
|
||||
|
@ -442,6 +453,8 @@ jobs:
|
|||
echo $VFLAGS
|
||||
./v cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests
|
||||
run: .\v.exe test-self
|
||||
# - name: Test
|
||||
|
@ -500,6 +513,9 @@ jobs:
|
|||
echo $VFLAGS
|
||||
./v cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
### TODO: test-cleancode fails with msvc. Investigate why???
|
||||
## - name: All code is formatted
|
||||
## run: ./v test-cleancode
|
||||
- name: Self tests
|
||||
run: |
|
||||
./v -cg cmd\tools\vtest-self.v
|
||||
|
@ -534,7 +550,7 @@ jobs:
|
|||
- name: Test new v.c
|
||||
run: |
|
||||
.\v.exe -o v.c cmd/v
|
||||
.\thirdparty\tcc\tcc.exe -I ./thirdparty/stdatomic/win -Werror -w -ladvapi32 -bt10 v.c
|
||||
.\thirdparty\tcc\tcc.exe -Werror -w -ladvapi32 -bt10 v.c
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
.\v.exe setup-freetype
|
||||
|
@ -555,8 +571,8 @@ jobs:
|
|||
run: ./v doc -v clipboard
|
||||
- name: Test v build-tools
|
||||
run: ./v -W build-tools
|
||||
- name: Test ./v doc clipboard
|
||||
run: ./v doc clipboard
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests
|
||||
run: ./v test-self
|
||||
- name: Test v->js
|
||||
|
@ -575,7 +591,7 @@ jobs:
|
|||
## .\v.exe wipe-cache
|
||||
## .\make.bat -tcc32
|
||||
## - name: Test new v.c
|
||||
## run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -I ./thirdparty/stdatomic/win -Werror -g -w -ladvapi32 -bt10 v.c
|
||||
## run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -Werror -g -w -ladvapi32 -bt10 v.c
|
||||
## - name: v doctor
|
||||
## run: ./v doctor
|
||||
##
|
||||
|
@ -609,40 +625,40 @@ jobs:
|
|||
## run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
|
||||
|
||||
|
||||
# ubuntu-autofree-selfcompile:
|
||||
# runs-on: ubuntu-20.04
|
||||
# timeout-minutes: 121
|
||||
# env:
|
||||
# VFLAGS: -cc gcc
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - name: Build V
|
||||
# run: make -j4
|
||||
# - name: V self compilation with -autofree
|
||||
# run: ./v -o v2 -autofree cmd/v && ./v2 -o v3 -autofree cmd/v && ./v3 -o v4 -autofree cmd/v
|
||||
# ubuntu-autofree-selfcompile:
|
||||
# runs-on: ubuntu-20.04
|
||||
# timeout-minutes: 121
|
||||
# env:
|
||||
# VFLAGS: -cc gcc
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - name: Build V
|
||||
# run: make -j4
|
||||
# - name: V self compilation with -autofree
|
||||
# run: ./v -o v2 -autofree cmd/v && ./v2 -o v3 -autofree cmd/v && ./v3 -o v4 -autofree cmd/v
|
||||
|
||||
|
||||
# ubuntu-musl:
|
||||
# runs-on: ubuntu-20.04
|
||||
# timeout-minutes: 121
|
||||
# env:
|
||||
# VFLAGS: -cc musl-gcc
|
||||
# V_CI_MUSL: 1
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: actions/setup-node@v1
|
||||
# with:
|
||||
# node-version: 12.x
|
||||
# - name: Install dependencies
|
||||
# run: |
|
||||
# sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
|
||||
# - name: Build v
|
||||
# run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
|
||||
# # - name: Test v binaries
|
||||
# # run: ./v build-vbinaries
|
||||
# ## - name: Test v->js
|
||||
# ## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
|
||||
# - name: quick debug
|
||||
# run: ./v -stats vlib/strconv/format_test.v
|
||||
# - name: Self tests
|
||||
# run: ./v test-self
|
||||
# ubuntu-musl:
|
||||
# runs-on: ubuntu-20.04
|
||||
# timeout-minutes: 121
|
||||
# env:
|
||||
# VFLAGS: -cc musl-gcc
|
||||
# V_CI_MUSL: 1
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: actions/setup-node@v1
|
||||
# with:
|
||||
# node-version: 12.x
|
||||
# - name: Install dependencies
|
||||
# run: |
|
||||
# sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
|
||||
# - name: Build v
|
||||
# run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
|
||||
# # - name: Test v binaries
|
||||
# # run: ./v build-vbinaries
|
||||
# ## - name: Test v->js
|
||||
# ## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
|
||||
# - name: quick debug
|
||||
# run: ./v -stats vlib/strconv/format_test.v
|
||||
# - name: Self tests
|
||||
# run: ./v test-self
|
||||
|
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
env:
|
||||
VFLAGS: -cc tcc -no-retry-compilation
|
||||
B_CFLAGS: -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w
|
||||
B_CFLAGS: -g -std=gnu11 -w
|
||||
B_LFLAGS: -lm -lpthread
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -52,7 +52,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
env:
|
||||
VFLAGS: -cc clang
|
||||
B_CFLAGS: -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w
|
||||
B_CFLAGS: -g -std=gnu11 -w
|
||||
B_LFLAGS: -lm -lpthread
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
|
|
@ -71,14 +71,14 @@ jobs:
|
|||
- name: v.c can be compiled and run with -os cross
|
||||
run: |
|
||||
./v -os cross -o /tmp/v.c cmd/v
|
||||
gcc -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w -o v_from_vc /tmp/v.c -lm -lpthread
|
||||
gcc -g -std=gnu11 -w -o v_from_vc /tmp/v.c -lm -lpthread
|
||||
ls -lart v_from_vc
|
||||
./v_from_vc version
|
||||
|
||||
- name: v_win.c can be compiled and run with -os windows
|
||||
run: |
|
||||
./v -cc msvc -os windows -o /tmp/v_win.c cmd/v
|
||||
x86_64-w64-mingw32-gcc -I ./thirdparty/stdatomic/win /tmp/v_win.c -std=c99 -w -municode -o v_from_vc.exe
|
||||
x86_64-w64-mingw32-gcc /tmp/v_win.c -std=c99 -w -municode -o v_from_vc.exe
|
||||
ls -lart v_from_vc.exe
|
||||
wine64 ./v_from_vc.exe version
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ on:
|
|||
paths:
|
||||
- '!**'
|
||||
- 'cmd/tools/vtest*'
|
||||
- 'cmd/tools/builders/**.v'
|
||||
- 'cmd/tools/builders/**.v'
|
||||
- 'vlib/builtin/**.v'
|
||||
- 'vlib/strconv/**.v'
|
||||
- 'vlib/strings/**.v'
|
||||
|
@ -43,7 +43,7 @@ on:
|
|||
paths:
|
||||
- '!**'
|
||||
- 'cmd/tools/vtest*'
|
||||
- 'cmd/tools/builders/**.v'
|
||||
- 'cmd/tools/builders/**.v'
|
||||
- 'vlib/builtin/**.v'
|
||||
- 'vlib/strconv/**.v'
|
||||
- 'vlib/strings/**.v'
|
||||
|
@ -91,7 +91,9 @@ jobs:
|
|||
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
|
||||
sudo apt-get install clang
|
||||
- name: Build V
|
||||
run: make -j4 && ./v -cg -cstrict -o v cmd/v
|
||||
run: make && ./v -cg -cstrict -o v cmd/v
|
||||
- name: Ensure code is well formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests (-fsanitize=undefined)
|
||||
run: ./v -cflags "-fsanitize=undefined" -o v2 cmd/v && ./v2 -cflags -fsanitize=undefined test-self
|
||||
- name: Build examples (V compiled with -fsanitize=undefined)
|
||||
|
@ -115,7 +117,9 @@ jobs:
|
|||
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind
|
||||
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
|
||||
- name: Build V
|
||||
run: make -j4 && ./v -cg -cstrict -o v cmd/v
|
||||
run: make && ./v -cg -cstrict -o v cmd/v
|
||||
- name: Ensure code is well formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests (-fsanitize=undefined)
|
||||
run: ./v -cflags "-fsanitize=undefined" -o v2 cmd/v && ./v2 -cflags -fsanitize=undefined test-self
|
||||
- name: Build examples (V compiled with -fsanitize=undefined)
|
||||
|
@ -140,7 +144,9 @@ jobs:
|
|||
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
|
||||
sudo apt-get install clang
|
||||
- name: Build V
|
||||
run: make -j4 && ./v -cg -cstrict -o v cmd/v
|
||||
run: make && ./v -cg -cstrict -o v cmd/v
|
||||
- name: Ensure code is well formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests (-fsanitize=address)
|
||||
run: ASAN_OPTIONS=detect_leaks=0 ./v -cflags "-fsanitize=address,pointer-compare,pointer-subtract" test-self
|
||||
- name: Self tests (V compiled with -fsanitize=address)
|
||||
|
@ -168,6 +174,11 @@ jobs:
|
|||
echo $VFLAGS
|
||||
.\make.bat -msvc
|
||||
.\v.exe self
|
||||
- name: Ensure code is well formatted
|
||||
run: |
|
||||
.\v.exe fmt -verify vlib/builtin/ vlib/v/scanner/ vlib/v/parser/ vlib/v/gen/
|
||||
## TODO: check to see why `v test-cleancode` does not work with msvc on windows
|
||||
|
||||
## - name: Install dependencies
|
||||
## run: |
|
||||
## .\v.exe setup-freetype
|
||||
|
@ -195,7 +206,9 @@ jobs:
|
|||
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
|
||||
sudo apt-get install clang
|
||||
- name: Build V
|
||||
run: make -j4 && ./v -cg -cstrict -o v cmd/v
|
||||
run: make && ./v -cg -cstrict -o v cmd/v
|
||||
- name: Ensure code is well formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests (-fsanitize=address)
|
||||
run: ASAN_OPTIONS=detect_leaks=0 ./v -cflags -fsanitize=address test-self
|
||||
- name: Self tests (V compiled with -fsanitize=address)
|
||||
|
@ -224,11 +237,14 @@ jobs:
|
|||
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
|
||||
sudo apt-get install clang
|
||||
- name: Build V
|
||||
run: make -j4 && ./v -cc clang -cg -cstrict -o v cmd/v
|
||||
run: make && ./v -cc clang -cg -cstrict -o v cmd/v
|
||||
- name: Ensure code is well formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests (-fsanitize=memory)
|
||||
run: ./v -cflags -fsanitize=memory test-self
|
||||
- name: Self tests (V compiled with -fsanitize=memory)
|
||||
run:
|
||||
./v -cflags -fsanitize=memory -o v cmd/v && ./v -cc tcc test-self -msan-compiler
|
||||
run: |
|
||||
./v -cflags -fsanitize=memory -o v cmd/v
|
||||
./v -cc tcc test-self -msan-compiler
|
||||
- name: Build examples (V compiled with -fsanitize=memory)
|
||||
run: ./v build-examples
|
||||
|
|
|
@ -42,6 +42,9 @@ jobs:
|
|||
- name: Build V
|
||||
run: CC=gcc make
|
||||
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
|
||||
- name: Test V fixed tests
|
||||
run: ./v test-self
|
||||
|
||||
|
@ -69,5 +72,9 @@ jobs:
|
|||
echo $VFLAGS
|
||||
./v cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
|
||||
- name: Test V fixed tests
|
||||
run: ./v test-self
|
||||
|
|
|
@ -25,12 +25,13 @@ jobs:
|
|||
.\v.exe setup-freetype
|
||||
.\.github\workflows\windows-install-sqlite.bat
|
||||
- name: v doctor
|
||||
run: |
|
||||
./v doctor
|
||||
run: ./v doctor
|
||||
- name: Verify `v test` works
|
||||
run: |
|
||||
./v cmd/tools/test_if_v_test_system_works.v
|
||||
./cmd/tools/test_if_v_test_system_works
|
||||
- name: All code is formatted
|
||||
run: ./v test-cleancode
|
||||
- name: Self tests
|
||||
run: |
|
||||
./v -cg cmd\tools\vtest-self.v
|
||||
|
|
|
@ -85,6 +85,7 @@ jobs:
|
|||
- name: g++ version
|
||||
run: g++-9 --version
|
||||
- name: V self compilation with g++
|
||||
continue-on-error: true
|
||||
run: ./v -cc g++-9 -no-std -cflags -std=c++11 -o v2 cmd/v && ./v2 -cc g++-9 -no-std -cflags -std=c++11 -o v3 cmd/v
|
||||
## - name: Running tests with g++
|
||||
## run: ./v -cc g++-9 test-self
|
||||
|
@ -93,6 +94,7 @@ jobs:
|
|||
run: ./v -autofree -o v2 cmd/v ## NB: this does not mean it runs, but at least keeps it from regressing
|
||||
|
||||
- name: Shader examples can be build
|
||||
continue-on-error: true
|
||||
run: |
|
||||
wget https://github.com/floooh/sokol-tools-bin/raw/33d2e4cc26088c6c28eaef5467990f8940d15aab/bin/linux/sokol-shdc
|
||||
chmod +x ./sokol-shdc
|
||||
|
@ -146,116 +148,3 @@ jobs:
|
|||
./v test-parser -S examples/regex_example_fuzz.v
|
||||
./v test-parser -S examples/2048/2048_fuzz.v
|
||||
|
||||
v-apps-compile:
|
||||
runs-on: ubuntu-20.04
|
||||
timeout-minutes: 121
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build V
|
||||
run: make && sudo ./v symlink
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install --quiet -y libgc-dev
|
||||
sudo apt-get install --quiet -y libsodium-dev libssl-dev sqlite3 libsqlite3-dev valgrind
|
||||
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
|
||||
sudo apt-get install --quiet -y xfonts-75dpi xfonts-base
|
||||
|
||||
## vls
|
||||
- name: Clone VLS
|
||||
run: git clone --depth 1 https://github.com/vlang/vls
|
||||
- name: Build VLS
|
||||
run: pushd vls; v cmd/vls ; popd
|
||||
- name: Build VLS with -prod
|
||||
run: pushd vls; v -prod cmd/vls; popd
|
||||
- name: Build VLS with -gc boehm -skip-unused
|
||||
run: pushd vls; v -gc boehm -skip-unused cmd/vls; popd
|
||||
|
||||
## vsl
|
||||
- name: Clone VSL
|
||||
run: git clone --depth 1 https://github.com/vlang/vsl ~/.vmodules/vsl
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev libgc-dev
|
||||
- name: Execute Tests using Pure V Backend
|
||||
run: ~/.vmodules/vsl/bin/test
|
||||
- name: Execute Tests using Pure V Backend with Pure V Math
|
||||
run: ~/.vmodules/vsl/bin/test --use-cblas
|
||||
- name: Execute Tests using Pure V Backend and Garbage Collection enabled
|
||||
run: ~/.vmodules/vsl/bin/test --use-gc boehm
|
||||
- name: Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled
|
||||
run: ~/.vmodules/vsl/bin/test --use-cblas --use-gc boehm
|
||||
|
||||
## vtl
|
||||
- name: Clone VTL
|
||||
run: git clone --depth 1 https://github.com/vlang/vtl ~/.vmodules/vtl
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev libgc-dev
|
||||
- name: Execute Tests using Pure V Backend
|
||||
run: ~/.vmodules/vtl/bin/test
|
||||
- name: Execute Tests using Pure V Backend with Pure V Math
|
||||
run: ~/.vmodules/vtl/bin/test --use-cblas
|
||||
- name: Execute Tests using Pure V Backend and Garbage Collection enabled
|
||||
run: ~/.vmodules/vtl/bin/test --use-gc boehm
|
||||
- name: Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled
|
||||
run: ~/.vmodules/vtl/bin/test --use-cblas --use-gc boehm
|
||||
|
||||
## vab
|
||||
- name: Clone vab
|
||||
run: git clone --depth 1 https://github.com/vlang/vab
|
||||
- name: Build vab
|
||||
run: cd vab; ../v ./vab.v ; cd ..
|
||||
- name: Build vab with -gc boehm -skip-unused
|
||||
run: cd vab; ../v -gc boehm -skip-unused ./vab.v ; cd ..
|
||||
|
||||
## gitly
|
||||
- name: Install markdown
|
||||
run: ./v install markdown
|
||||
- name: Build Gitly
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/vlang/gitly
|
||||
cd gitly
|
||||
../v .
|
||||
# ./gitly -ci_run
|
||||
../v -autofree .
|
||||
../v -o x tests/first_run.v
|
||||
./x
|
||||
cd ..
|
||||
|
||||
## vex
|
||||
- name: Install Vex dependencies
|
||||
run: sudo apt-get install --quiet -y libsodium-dev libssl-dev sqlite3 libsqlite3-dev
|
||||
- name: Install Vex
|
||||
run: mkdir -p ~/.vmodules/nedpals; git clone https://github.com/nedpals/vex ~/.vmodules/nedpals/vex
|
||||
- name: Compile all of the Vex examples
|
||||
run: ./v should-compile-all ~/.vmodules/nedpals/vex/examples
|
||||
- name: Compile the simple Vex example with -gc boehm -skip-unused
|
||||
run: ./v -gc boehm -skip-unused ~/.vmodules/nedpals/vex/examples/simple_example.v
|
||||
- name: Run Vex Tests
|
||||
run: ./v test ~/.vmodules/nedpals/vex
|
||||
|
||||
## vpm modules
|
||||
- name: Install UI through VPM
|
||||
run: ./v install ui
|
||||
|
||||
## libsodium
|
||||
- name: Install libsodium-dev package
|
||||
run: sudo apt-get install --quiet -y libsodium-dev
|
||||
- name: Installl the libsodium wrapper through VPM
|
||||
run: ./v install libsodium
|
||||
- name: Test libsodium
|
||||
run: VJOBS=1 ./v -stats test ~/.vmodules/libsodium
|
||||
|
||||
## Go2V
|
||||
- name: Clone & Build go2v
|
||||
run: git clone --depth=1 https://github.com/vlang/go2v go2v/
|
||||
- name: Build go2v
|
||||
run: ./v go2v/
|
||||
- name: Run tests for go2v
|
||||
run: VJOBS=1 ./v -stats test go2v/
|
||||
|
||||
## vlang/pdf
|
||||
- name: Clone & Build vlang/pdf
|
||||
run: git clone --depth=1 https://github.com/vlang/pdf ~/.vmodules/pdf/
|
||||
- name: PDF examples should compile
|
||||
run: ./v should-compile-all ~/.vmodules/pdf/examples
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
name: V Apps and Modules
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
|
||||
concurrency:
|
||||
group: build-other-${{ github.event.pull_request.number || github.sha }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
v-apps-compile:
|
||||
runs-on: ubuntu-20.04
|
||||
timeout-minutes: 121
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build V
|
||||
run: make && sudo ./v symlink
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install --quiet -y libgc-dev
|
||||
sudo apt-get install --quiet -y libsodium-dev libssl-dev sqlite3 libsqlite3-dev valgrind
|
||||
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
|
||||
sudo apt-get install --quiet -y xfonts-75dpi xfonts-base
|
||||
|
||||
- name: Install UI through VPM
|
||||
continue-on-error: true
|
||||
run: |
|
||||
echo "Official VPM modules should be installable"
|
||||
./v install ui
|
||||
|
||||
- name: Build V Language Server (VLS)
|
||||
continue-on-error: true
|
||||
run: |
|
||||
echo "Clone VLS"
|
||||
git clone --depth 1 https://github.com/vlang/vls
|
||||
echo "Build VLS"
|
||||
pushd vls; v cmd/vls ; popd
|
||||
echo "Build VLS with -prod"
|
||||
pushd vls; v -prod cmd/vls; popd
|
||||
echo "Build VLS with -gc boehm -skip-unused"
|
||||
pushd vls; v -gc boehm -skip-unused cmd/vls; popd
|
||||
|
||||
- name: Build VSL
|
||||
continue-on-error: true
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/vlang/vsl ~/.vmodules/vsl
|
||||
sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev libgc-dev
|
||||
echo "Execute Tests using Pure V Backend"
|
||||
~/.vmodules/vsl/bin/test
|
||||
echo "Execute Tests using Pure V Backend with Pure V Math"
|
||||
~/.vmodules/vsl/bin/test --use-cblas
|
||||
echo "Execute Tests using Pure V Backend and Garbage Collection enabled"
|
||||
~/.vmodules/vsl/bin/test --use-gc boehm
|
||||
echo "Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled"
|
||||
~/.vmodules/vsl/bin/test --use-cblas --use-gc boehm
|
||||
|
||||
- name: Build VTL
|
||||
continue-on-error: true
|
||||
run: |
|
||||
echo "Clone VTL"
|
||||
git clone --depth 1 https://github.com/vlang/vtl ~/.vmodules/vtl
|
||||
echo "Install dependencies"
|
||||
sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev libgc-dev
|
||||
echo "Execute Tests using Pure V Backend"
|
||||
~/.vmodules/vtl/bin/test
|
||||
echo "Execute Tests using Pure V Backend with Pure V Math"
|
||||
~/.vmodules/vtl/bin/test --use-cblas
|
||||
echo "Execute Tests using Pure V Backend and Garbage Collection enabled"
|
||||
~/.vmodules/vtl/bin/test --use-gc boehm
|
||||
echo "Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled"
|
||||
~/.vmodules/vtl/bin/test --use-cblas --use-gc boehm
|
||||
|
||||
- name: Build VAB
|
||||
continue-on-error: true
|
||||
run: |
|
||||
echo "Clone vab"
|
||||
git clone --depth 1 https://github.com/vlang/vab
|
||||
echo "Build vab"
|
||||
cd vab; ../v ./vab.v ; cd ..
|
||||
echo "Build vab with -gc boehm -skip-unused"
|
||||
cd vab; ../v -gc boehm -skip-unused ./vab.v ; cd ..
|
||||
|
||||
- name: Build Gitly
|
||||
continue-on-error: true
|
||||
run: |
|
||||
echo "Clone markdown"
|
||||
git clone https://github.com/vlang/markdown ~/.vmodules/markdown
|
||||
echo "Clone Gitly"
|
||||
git clone --depth 1 https://github.com/vlang/gitly
|
||||
cd gitly
|
||||
echo "Build Gitly"
|
||||
../v .
|
||||
echo "Build Gitly with -autofree"
|
||||
../v -autofree .
|
||||
echo "Run first_run.v"
|
||||
../v run tests/first_run.v
|
||||
# ./gitly -ci_run
|
||||
|
||||
- name: Build libsodium
|
||||
continue-on-error: true
|
||||
run: |
|
||||
echo "Install libsodium-dev package"
|
||||
sudo apt-get install --quiet -y libsodium-dev
|
||||
echo "Clone the libsodium wrapper"
|
||||
git clone https://github.com/vlang/libsodium ~/.vmodules/libsodium
|
||||
echo "Test libsodium"
|
||||
VJOBS=1 ./v -stats test ~/.vmodules/libsodium
|
||||
|
||||
- name: Build VEX
|
||||
continue-on-error: true
|
||||
run: |
|
||||
echo "Install Vex dependencies"
|
||||
sudo apt-get install --quiet -y libsodium-dev libssl-dev sqlite3 libsqlite3-dev
|
||||
echo "Clone Vex"
|
||||
mkdir -p ~/.vmodules/nedpals; git clone https://github.com/nedpals/vex ~/.vmodules/nedpals/vex
|
||||
echo "Compile all of the Vex examples"
|
||||
./v should-compile-all ~/.vmodules/nedpals/vex/examples
|
||||
echo "Compile the simple Vex example with -gc boehm -skip-unused"
|
||||
./v -gc boehm -skip-unused ~/.vmodules/nedpals/vex/examples/simple_example.v
|
||||
echo "Run Vex Tests"
|
||||
./v test ~/.vmodules/nedpals/vex
|
||||
|
||||
- name: Build go2v
|
||||
continue-on-error: true
|
||||
run: |
|
||||
echo "Clone go2v"
|
||||
clone --depth=1 https://github.com/vlang/go2v go2v/
|
||||
echo "Build go2v"
|
||||
./v go2v/
|
||||
## echo "Run tests for go2v"
|
||||
## VJOBS=1 ./v -stats test go2v/
|
||||
|
||||
- name: Build vlang/pdf
|
||||
continue-on-error: true
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/vlang/pdf ~/.vmodules/pdf/
|
||||
echo "PDF examples should compile"
|
||||
./v should-compile-all ~/.vmodules/pdf/examples
|
|
@ -1,12 +1,11 @@
|
|||
@echo off
|
||||
|
||||
curl -L https://www.sqlite.org/2020/sqlite-amalgamation-3320300.zip -o sqlite-amalgamation-3320300.zip
|
||||
curl -L https://www.sqlite.org/2022/sqlite-amalgamation-3380200.zip -o sqlite-amalgamation-3380200.zip
|
||||
|
||||
unzip sqlite-amalgamation-3320300.zip -d thirdparty\
|
||||
unzip sqlite-amalgamation-3380200.zip -d thirdparty\
|
||||
|
||||
del thirdparty\sqlite-amalgamation-3320300\shell.c
|
||||
del thirdparty\sqlite-amalgamation-3380200\shell.c
|
||||
|
||||
move /y thirdparty\sqlite-amalgamation-3320300 thirdparty\sqlite
|
||||
move /y thirdparty\sqlite-amalgamation-3380200 thirdparty\sqlite
|
||||
|
||||
dir thirdparty\sqlite
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
matrix:
|
||||
PLATFORM:
|
||||
- 'linux/amd64'
|
||||
- 'linux/arm64'
|
||||
|
||||
platform: ${PLATFORM}
|
||||
branches: ['master']
|
||||
depends_on:
|
||||
- 'vc'
|
||||
|
||||
pipeline:
|
||||
build:
|
||||
image: 'menci/archlinuxarm:base-devel'
|
||||
commands:
|
||||
# Update packages
|
||||
- pacman -Syu --noconfirm
|
||||
# Create non-root user to perform build & switch to their home
|
||||
- groupadd -g 1000 builder
|
||||
- useradd -mg builder builder
|
||||
- chown -R builder:builder "$PWD"
|
||||
- "echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
|
||||
- su builder
|
||||
# Build the package
|
||||
- makepkg -s --noconfirm --needed
|
||||
|
||||
publish:
|
||||
image: 'curlimages/curl'
|
||||
secrets:
|
||||
- 'vieter_api_key'
|
||||
commands:
|
||||
# Publish the package
|
||||
- 'for pkg in $(ls -1 *.pkg*); do curl -f -XPOST -T "$pkg" -H "X-API-KEY: $VIETER_API_KEY" https://arch.r8r.be/vieter/publish; done'
|
|
@ -0,0 +1,18 @@
|
|||
platform: 'linux/amd64'
|
||||
branches: ['master']
|
||||
depends_on:
|
||||
- 'vc'
|
||||
|
||||
pipeline:
|
||||
build-publish:
|
||||
image: 'woodpeckerci/plugin-docker-buildx'
|
||||
secrets: [ docker_username, docker_password ]
|
||||
settings:
|
||||
repo: chewingbever/vlang
|
||||
tag: latest
|
||||
dockerfile: Dockerfile.builder
|
||||
platforms: [ linux/arm64/v8, linux/amd64 ]
|
||||
# The build can run every time, because we should only push when there's
|
||||
# actual changes
|
||||
when:
|
||||
event: push
|
|
@ -0,0 +1,48 @@
|
|||
platform: 'linux/amd64'
|
||||
branches: ['master']
|
||||
|
||||
pipeline:
|
||||
gen-vc:
|
||||
# This is what the official CI uses as well
|
||||
image: 'ubuntu:latest'
|
||||
secrets:
|
||||
- deploy_key
|
||||
commands:
|
||||
# Install necessary dependencies
|
||||
- apt-get update -y && apt-get install openssh-client git build-essential -y
|
||||
# Build the compiler
|
||||
- make
|
||||
# Run ssh-agent
|
||||
- eval $(ssh-agent -s)
|
||||
# Add ssh key
|
||||
- echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add -
|
||||
# Create ssh dir with proper permissions
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
# Configure git credentials
|
||||
- git config --global user.email 'vbot@rustybever.be'
|
||||
- git config --global user.name 'vbot'
|
||||
# Verify SSH keys
|
||||
- ssh-keyscan git.rustybever.be > ~/.ssh/known_hosts
|
||||
|
||||
# The following is copied over from the official repo's CI
|
||||
# https://github.com/vlang/v/blob/master/.github/workflows/gen_vc.yml
|
||||
- export "COMMIT_HASH=$(git rev-parse --short HEAD)"
|
||||
- export "COMMIT_MSG=$(git log -1 --oneline --pretty='%s' HEAD)"
|
||||
- rm -rf vc
|
||||
- git clone --depth=1 'git@git.rustybever.be:vieter/vc.git'
|
||||
- rm -rf vc/v.c vc/v_win.c
|
||||
- ./v -o vc/v.c -os cross cmd/v
|
||||
- ./v -o vc/v_win.c -os windows -cc msvc cmd/v
|
||||
- sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v.c
|
||||
- sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v_win.c
|
||||
# ensure the C files are over 5000 lines long, as a safety measure
|
||||
- '[ $(wc -l < vc/v.c) -gt 5000 ]'
|
||||
- '[ $(wc -l < vc/v_win.c) -gt 5000 ]'
|
||||
- git -C vc add v.c v_win.c
|
||||
- 'git -C vc commit -m "[v:master] $COMMIT_HASH - $COMMIT_MSG"'
|
||||
# in case there are recent commits:
|
||||
- git -C vc pull --rebase origin main
|
||||
- git -C vc push
|
||||
when:
|
||||
event: push
|
|
@ -2,6 +2,7 @@
|
|||
-*Not yet released, changelog is not full*
|
||||
- Introduce `isize` and `usize` types, deprecate `size_t` in favor of `usize`.
|
||||
- Add `datatypes` and `datatypes.fsm` modules.
|
||||
- Add `compile_error` and `compile_warn` comptime functions.
|
||||
|
||||
-## V 0.2.4
|
||||
-*Not yet released, changelog is not full*
|
||||
|
|
|
@ -35,32 +35,35 @@ The main files are:
|
|||
- Creates a parser object for each file and runs `parse()` on them.
|
||||
- The correct backend is called (C, JS, native), and a binary is compiled.
|
||||
|
||||
2. `v/scanner` The scanner's job is to parse a list of characters and convert
|
||||
2. `vlib/v/scanner` The scanner's job is to parse a list of characters and convert
|
||||
them to tokens.
|
||||
|
||||
3. `v/token` This is simply a list of all tokens, their string values, and a
|
||||
3. `vlib/v/token` This is simply a list of all tokens, their string values, and a
|
||||
couple of helper functions.
|
||||
|
||||
4. `v/parser` The parser. It converts a list of tokens into an AST.
|
||||
4. `vlib/v/parser` The parser. It converts a list of tokens into an AST.
|
||||
In V, objects can be used before declaration, so unknown types are marked as
|
||||
unresolved. They are resolved later in the type checker.
|
||||
|
||||
5. `v/table` V creates one table object that is shared by all parsers. It
|
||||
5. `vlib/v/table` V creates one table object that is shared by all parsers. It
|
||||
contains all types, consts, and functions, as well as several helpers to search
|
||||
for objects by name, register new objects, modify types' fields, etc.
|
||||
|
||||
6. `v/checker` Type checker and resolver. It processes the AST and makes sure
|
||||
6. `vlib/v/checker` Type checker and resolver. It processes the AST and makes sure
|
||||
the types are correct. Unresolved types are resolved, type information is added
|
||||
to the AST.
|
||||
|
||||
7. `v/gen/c` C backend. It simply walks the AST and generates C code that can be
|
||||
7. `vlib/v/gen/c` C backend. It simply walks the AST and generates C code that can be
|
||||
compiled with Clang, GCC, Visual Studio, and TCC.
|
||||
|
||||
8. `json.v` defines the json code generation. This file will be removed once V
|
||||
8. `vlib/v/gen/js` JavaScript backend. It simply walks the AST and generates JS code that can be
|
||||
executed on the browser or in NodeJS/Deno.
|
||||
|
||||
9. `vlib/v/gen/c/json.v` defines the json code generation. This file will be removed once V
|
||||
supports comptime code generation, and it will be possible to do this using the
|
||||
language's tools.
|
||||
|
||||
9. `v/gen/native` is the directory with all the machine code generation logic. It
|
||||
10. `vlib/v/gen/native` is the directory with all the machine code generation logic. It
|
||||
defines a set of functions that translate assembly instructions to machine code
|
||||
and build the binary from scratch byte by byte. It manually builds all headers,
|
||||
segments, sections, symtable, relocations, etc. Right now it only has basic
|
||||
|
@ -90,6 +93,7 @@ making pullrequests, and you can just do normal git operations such as:
|
|||
|
||||
5. When finished with a feature/bugfix/change, you can:
|
||||
`git checkout -b fix_alabala`
|
||||
- Don't forget to keep formatting standards, run `v fmt -w YOUR_MODIFIED_FILES` before committing
|
||||
6. `git push pullrequest` # (NOTE: the `pullrequest` remote was setup on step 4)
|
||||
7. On GitHub's web interface, go to: https://github.com/vlang/v/pulls
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
FROM alpine:3.15
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
WORKDIR /opt/vlang
|
||||
|
||||
ENV VVV /opt/vlang
|
||||
ENV PATH /opt/vlang:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
ENV VFLAGS -cc gcc -d dynamic_boehm
|
||||
ENV V_PATH /opt/vlang/v
|
||||
|
||||
RUN ln -s /opt/vlang/v /usr/bin/v && \
|
||||
apk --no-cache add \
|
||||
git make gcc curl openssl \
|
||||
musl-dev \
|
||||
openssl-libs-static openssl-dev \
|
||||
zlib-static bzip2-static xz-dev expat-static zstd-static lz4-static \
|
||||
sqlite-static sqlite-dev \
|
||||
libx11-dev glfw-dev freetype-dev \
|
||||
libarchive-static libarchive-dev \
|
||||
gc-dev \
|
||||
diffutils
|
||||
|
||||
RUN git clone https://git.rustybever.be/vieter/v /opt/vlang && \
|
||||
make && \
|
||||
v -version
|
||||
|
||||
RUN if [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
|
||||
wget -O /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc && \
|
||||
chmod +x /usr/local/bin/mc ; \
|
||||
fi
|
||||
|
||||
CMD ["v"]
|
|
@ -1,10 +1,10 @@
|
|||
FROM mstorsjo/llvm-mingw
|
||||
|
||||
LABEL maintainer="Vitaly Takmazov <vitalyster@gmail.com>"
|
||||
LABEL maintainer="Delyan Angelov <delian66@gmail.com>"
|
||||
COPY . .
|
||||
RUN make
|
||||
RUN ./v -os windows -o v.c cmd/v
|
||||
RUN x86_64-w64-mingw32-gcc v.c -std=c99 -I ./thirdparty/stdatomic/win -w -municode -o v.exe
|
||||
RUN x86_64-w64-mingw32-gcc v.c -std=c99 -w -municode -o v.exe
|
||||
RUN file v.exe
|
||||
|
||||
CMD [ "bash" ]
|
||||
|
|
12
GNUmakefile
12
GNUmakefile
|
@ -5,7 +5,7 @@ TMPDIR ?= /tmp
|
|||
VROOT ?= .
|
||||
VC ?= ./vc
|
||||
V ?= ./v
|
||||
VCREPO ?= https://github.com/vlang/vc
|
||||
VCREPO ?= https://git.rustybever.be/vieter/vc
|
||||
TCCREPO ?= https://github.com/vlang/tccbin
|
||||
|
||||
VCFILE := v.c
|
||||
|
@ -76,7 +76,7 @@ endif
|
|||
endif
|
||||
endif
|
||||
|
||||
.PHONY: all clean fresh_vc fresh_tcc check_for_working_tcc
|
||||
.PHONY: all clean check fresh_vc fresh_tcc check_for_working_tcc
|
||||
|
||||
ifdef prod
|
||||
VFLAGS+=-prod
|
||||
|
@ -84,13 +84,13 @@ endif
|
|||
|
||||
all: latest_vc latest_tcc
|
||||
ifdef WIN32
|
||||
$(CC) $(CFLAGS) -std=c99 -municode -w -I ./thirdparty/stdatomic/nix -o v1.exe $(VC)/$(VCFILE) $(LDFLAGS)
|
||||
$(CC) $(CFLAGS) -std=c99 -municode -w -o v1.exe $(VC)/$(VCFILE) $(LDFLAGS)
|
||||
v1.exe -no-parallel -o v2.exe $(VFLAGS) cmd/v
|
||||
v2.exe -o $(V) $(VFLAGS) cmd/v
|
||||
del v1.exe
|
||||
del v2.exe
|
||||
else
|
||||
$(CC) $(CFLAGS) -std=gnu99 -w -I ./thirdparty/stdatomic/nix -o v1.exe $(VC)/$(VCFILE) -lm -lpthread $(LDFLAGS)
|
||||
$(CC) $(CFLAGS) -std=gnu99 -w -o v1.exe $(VC)/$(VCFILE) -lm -lpthread $(LDFLAGS)
|
||||
./v1.exe -no-parallel -o v2.exe $(VFLAGS) cmd/v
|
||||
./v2.exe -o $(V) $(VFLAGS) cmd/v
|
||||
rm -rf v1.exe v2.exe
|
||||
|
@ -113,7 +113,7 @@ endif
|
|||
|
||||
check_for_working_tcc:
|
||||
@$(TMPTCC)/tcc.exe --version > /dev/null 2> /dev/null || echo "The executable '$(TMPTCC)/tcc.exe' does not work."
|
||||
|
||||
|
||||
fresh_vc:
|
||||
rm -rf $(VC)
|
||||
$(GITFASTCLONE) $(VCREPO) $(VC)
|
||||
|
@ -164,3 +164,5 @@ selfcompile-static:
|
|||
install:
|
||||
@echo 'Please use `sudo ./v symlink` instead.'
|
||||
|
||||
check:
|
||||
$(V) test-all
|
||||
|
|
9
Makefile
9
Makefile
|
@ -3,12 +3,17 @@ VFLAGS ?=
|
|||
CFLAGS ?=
|
||||
LDFLAGS ?=
|
||||
|
||||
.PHONY: all check
|
||||
|
||||
all:
|
||||
rm -rf vc/
|
||||
git clone --depth 1 --quiet https://github.com/vlang/vc
|
||||
$(CC) $(CFLAGS) -std=gnu11 -w -I ./thirdparty/stdatomic/nix -o v1 vc/v.c -lm -lexecinfo -lpthread $(LDFLAGS)
|
||||
git clone --depth 1 --quiet https://git.rustybever.be/vieter/vc
|
||||
$(CC) $(CFLAGS) -std=gnu11 -w -o v1 vc/v.c -lm -lexecinfo -lpthread $(LDFLAGS)
|
||||
./v1 -no-parallel -o v2 $(VFLAGS) cmd/v
|
||||
./v2 -o v $(VFLAGS) cmd/v
|
||||
rm -rf v1 v2 vc/
|
||||
@echo "V has been successfully built"
|
||||
./v run ./cmd/tools/detect_tcc.v
|
||||
|
||||
check:
|
||||
./v test-all
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
# Maintainer: Jef Roosens
|
||||
# This PKGBUILD is mostly copied over from the AUR
|
||||
# https://aur.archlinux.org/packages/vlang-git
|
||||
|
||||
pkgname=vieter-v
|
||||
pkgver=0.2.2.r796.gfbc02cbc5
|
||||
pkgrel=1
|
||||
pkgdesc='Simple, fast, safe, compiled language for developing maintainable software'
|
||||
arch=('x86_64' 'aarch64')
|
||||
url='https://vlang.io'
|
||||
license=('MIT')
|
||||
depends=('glibc')
|
||||
makedepends=('git')
|
||||
optdepends=('glfw: Needed for graphics support'
|
||||
'freetype2: Needed for graphics support'
|
||||
'openssl: Needed for http support')
|
||||
provides=('vlang')
|
||||
conflicts=('v' 'vlang' 'vlang-bin')
|
||||
source=('vlang::git+https://git.rustybever.be/Chewing_Bever/v')
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd "${srcdir}/vlang"
|
||||
# Weekly tags are considered older than semantic tags that are older than
|
||||
# them, so to prevent version resolution problems we exclude weekly tags.
|
||||
git describe --long --tags --exclude "weekly*" | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/vlang"
|
||||
# We don't require optimizations when compiling the bootstrap executable and
|
||||
# -O2 actually breaks `./v self` (resulting in "cgen error:"), so we empty
|
||||
# CFLAGS and LDFLAGS to ensure successful compilation.
|
||||
CFLAGS="" LDFLAGS="" prod=1 make
|
||||
|
||||
# vpm and vdoc fail to compile with "unsupported linker option" when LDFLAGS
|
||||
# is set
|
||||
LDFLAGS="" ./v build-tools
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${srcdir}/vlang"
|
||||
install -d "$pkgdir/usr/lib/vlang" "$pkgdir/usr/share/vlang" "$pkgdir/usr/bin"
|
||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
install -Dm755 v "$pkgdir/usr/lib/vlang"
|
||||
cp -a cmd "$pkgdir/usr/lib/vlang/"
|
||||
cp -a examples "$pkgdir/usr/share/vlang/"
|
||||
cp -a thirdparty "$pkgdir/usr/lib/vlang/"
|
||||
cp -a vlib "$pkgdir/usr/lib/vlang/"
|
||||
cp v.mod "$pkgdir/usr/lib/vlang/"
|
||||
ln -s /usr/lib/vlang/v "$pkgdir/usr/bin/v"
|
||||
|
||||
touch "$pkgdir/usr/lib/vlang/cmd/tools/.disable_autorecompilation"
|
||||
}
|
12
README.md
12
README.md
|
@ -4,11 +4,7 @@
|
|||
</p>
|
||||
<h1>The V Programming Language</h1>
|
||||
|
||||
[vlang.io](https://vlang.io) |
|
||||
[Docs](https://github.com/vlang/v/blob/master/doc/docs.md) |
|
||||
[Changelog](https://github.com/vlang/v/blob/master/CHANGELOG.md) |
|
||||
[Speed](https://fast.vlang.io/) |
|
||||
[Contributing & compiler design](https://github.com/vlang/v/blob/master/CONTRIBUTING.md)
|
||||
[vlang.io](https://vlang.io) | [Docs](https://github.com/vlang/v/blob/master/doc/docs.md) | [Changelog](https://github.com/vlang/v/blob/master/CHANGELOG.md) | [Speed](https://fast.vlang.io/) | [Contributing & compiler design](https://github.com/vlang/v/blob/master/CONTRIBUTING.md)
|
||||
|
||||
</div>
|
||||
<div align="center">
|
||||
|
@ -64,11 +60,11 @@ language, very similar to the way it is right now.
|
|||
|
||||
### Linux, macOS, Windows, *BSD, Solaris, WSL, Android, etc.
|
||||
|
||||
Usually installing V is quite simple if you have an environment that already has a
|
||||
functional `git` installation.
|
||||
Usually installing V is quite simple if you have an environment that already has a
|
||||
functional `git` installation.
|
||||
|
||||
* *(* ***PLEASE NOTE:*** *If you run into any trouble or you have a different operating
|
||||
system or Linux distribution that doesn't install or work immediately, please see
|
||||
system or Linux distribution that doesn't install or work immediately, please see
|
||||
[Installation Issues](https://github.com/vlang/v/discussions/categories/installation-issues)
|
||||
and search for your OS and problem. If you can't find your problem, please add it to an
|
||||
existing discussion if one exists for your OS, or create a new one if a main discussion
|
||||
|
|
|
@ -14,9 +14,9 @@ fn main() {
|
|||
mut checksum := u64(0)
|
||||
mut start_pos := 0
|
||||
mut bgenerating := benchmark.start()
|
||||
mut bytepile := []byte{}
|
||||
mut bytepile := []u8{}
|
||||
for _ in 0 .. sample_size * max_str_len {
|
||||
bytepile << byte(rand.int_in_range(40, 125) or { 40 })
|
||||
bytepile << u8(rand.int_in_range(40, 125) or { 40 })
|
||||
}
|
||||
mut str_lens := []int{}
|
||||
for _ in 0 .. sample_size {
|
||||
|
@ -30,7 +30,7 @@ fn main() {
|
|||
checksum = 0
|
||||
for len in str_lens {
|
||||
end_pos := start_pos + len
|
||||
checksum ^= wyhash.wyhash_c(unsafe { &byte(bytepile.data) + start_pos }, u64(len),
|
||||
checksum ^= wyhash.wyhash_c(unsafe { &u8(bytepile.data) + start_pos }, u64(len),
|
||||
1)
|
||||
start_pos = end_pos
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ fn main() {
|
|||
vexe := pref.vexe_path()
|
||||
vroot := os.dir(vexe)
|
||||
util.set_vroot_folder(vroot)
|
||||
os.chdir(vroot) ?
|
||||
os.chdir(vroot)?
|
||||
cmd := diff.find_working_diff_command() or { '' }
|
||||
mut app := App{
|
||||
diff_cmd: cmd
|
||||
|
|
|
@ -4,7 +4,8 @@ fn main() {
|
|||
exit(0)
|
||||
}
|
||||
|
||||
println('
|
||||
$if !macos {
|
||||
println('
|
||||
Note: `tcc` was not used, so unless you install it yourself, your backend
|
||||
C compiler will be `cc`, which is usually either `clang`, `gcc` or `msvc`.
|
||||
|
||||
|
@ -12,4 +13,5 @@ These C compilers, are several times slower at compiling C source code,
|
|||
compared to `tcc`. They do produce more optimised executables, but that
|
||||
is done at the cost of compilation speed.
|
||||
')
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ const vdir = @VEXEROOT
|
|||
fn main() {
|
||||
dump(fast_dir)
|
||||
dump(vdir)
|
||||
os.chdir(fast_dir) ?
|
||||
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`')
|
||||
}
|
||||
|
@ -28,37 +28,37 @@ fn main() {
|
|||
return
|
||||
}
|
||||
}
|
||||
// Fetch the last commit's hash
|
||||
|
||||
// fetch the last commit's hash
|
||||
commit := exec('git rev-parse HEAD')[..8]
|
||||
if !os.exists('table.html') {
|
||||
os.create('table.html') ?
|
||||
os.create('table.html')?
|
||||
}
|
||||
mut table := os.read_file('table.html') ?
|
||||
mut table := os.read_file('table.html')?
|
||||
if os.exists('website/index.html') {
|
||||
uploaded_index := os.read_file('website/index.html') ?
|
||||
uploaded_index := os.read_file('website/index.html')?
|
||||
if uploaded_index.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')
|
||||
|
||||
// build an optimized V
|
||||
println(' Building vprod...')
|
||||
os.chdir(vdir) ?
|
||||
os.chdir(vdir)?
|
||||
if os.args.contains('-noprod') {
|
||||
exec('./v -o vprod cmd/v') // for faster debugging
|
||||
} else {
|
||||
exec('./v -o vprod -prod -prealloc cmd/v')
|
||||
}
|
||||
|
||||
// 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'
|
||||
|
@ -71,23 +71,24 @@ fn main() {
|
|||
if os.args.contains('-clang') {
|
||||
tcc_path = 'clang'
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
os.chdir(fast_dir)?
|
||||
mut out := os.create('table.html')?
|
||||
|
||||
// place the new row on top
|
||||
html_message := message.replace_each(['<', '<', '>', '>'])
|
||||
table =
|
||||
'<tr>
|
||||
' <tr>
|
||||
<td>$date.format()</td>
|
||||
<td><a target=_blank href="https://github.com/vlang/v/commit/$commit">$commit</a></td>
|
||||
<td>$html_message</td>
|
||||
|
@ -104,26 +105,25 @@ fn main() {
|
|||
<td>${int(f64(vlines) / f64(diff1) * 1000.0)}</td>
|
||||
</tr>\n' +
|
||||
table.trim_space()
|
||||
out.writeln(table) ?
|
||||
out.writeln(table)?
|
||||
out.close()
|
||||
// Regenerate index.html
|
||||
header := os.read_file('header.html') ?
|
||||
footer := os.read_file('footer.html') ?
|
||||
mut res := os.create('index.html') ?
|
||||
res.writeln(header) ?
|
||||
res.writeln(table) ?
|
||||
res.writeln(footer) ?
|
||||
|
||||
// regenerate index.html
|
||||
header := os.read_file('header.html')?
|
||||
footer := os.read_file('footer.html')?
|
||||
mut res := os.create('index.html')?
|
||||
res.writeln(header)?
|
||||
res.writeln(table)?
|
||||
res.writeln(footer)?
|
||||
res.close()
|
||||
//}
|
||||
// exec('git checkout master')
|
||||
// os.write_file('last_commit.txt', commits[commits.len - 1]) ?
|
||||
// Upload the result to github pages
|
||||
|
||||
// upload the result to github pages
|
||||
if os.args.contains('-upload') {
|
||||
println('uploading...')
|
||||
os.chdir('website') ?
|
||||
os.chdir('website')?
|
||||
os.execute_or_exit('git checkout gh-pages')
|
||||
os.cp('../index.html', 'index.html') ?
|
||||
os.rm('../index.html') ?
|
||||
os.cp('../index.html', 'index.html')?
|
||||
os.rm('../index.html')?
|
||||
os.system('git commit -am "update benchmark"')
|
||||
os.system('git push origin gh-pages')
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ fn exec(s string) string {
|
|||
return e.output.trim_right('\r\n')
|
||||
}
|
||||
|
||||
// returns milliseconds
|
||||
// measure returns milliseconds
|
||||
fn measure(cmd string, description string) int {
|
||||
println(' Measuring $description')
|
||||
println(' Warming up...')
|
||||
|
@ -186,7 +186,7 @@ fn measure_steps(vdir string) (int, int, int, int, int) {
|
|||
cgen = line[0].int()
|
||||
}
|
||||
} else {
|
||||
// Fetch number of V lines
|
||||
// fetch number of V lines
|
||||
if line[0].contains('V') && line[0].contains('source') && line[0].contains('size') {
|
||||
start := line[0].index(':') or { 0 }
|
||||
end := line[0].index('lines,') or { 0 }
|
||||
|
|
|
@ -19,6 +19,8 @@ pub const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
|||
|
||||
pub const fail_fast = os.getenv('VTEST_FAIL_FAST') == '1'
|
||||
|
||||
pub const fail_flaky = os.getenv('VTEST_FAIL_FLAKY') == '1'
|
||||
|
||||
pub const test_only = os.getenv('VTEST_ONLY').split_any(',')
|
||||
|
||||
pub const test_only_fn = os.getenv('VTEST_ONLY_FN').split_any(',')
|
||||
|
@ -35,7 +37,6 @@ pub mut:
|
|||
vroot string
|
||||
vtmp_dir string
|
||||
vargs string
|
||||
failed bool
|
||||
fail_fast bool
|
||||
benchmark benchmark.Benchmark
|
||||
rm_binaries bool = true
|
||||
|
@ -286,7 +287,7 @@ pub fn (mut ts TestSession) test() {
|
|||
fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||
mut ts := &TestSession(p.get_shared_context())
|
||||
if ts.fail_fast {
|
||||
if ts.failed {
|
||||
if ts.failed_cmds.len > 0 {
|
||||
return pool.no_result
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +363,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
|||
details := get_test_details(file)
|
||||
os.setenv('VTEST_RETRY_MAX', '$details.retry', true)
|
||||
for retry := 1; retry <= details.retry; retry++ {
|
||||
ts.append_message(.info, ' retrying $retry/$details.retry of $relative_file ...')
|
||||
ts.append_message(.info, ' [stats] retrying $retry/$details.retry of $relative_file ; known flaky: $details.flaky ...')
|
||||
os.setenv('VTEST_RETRY', '$retry', true)
|
||||
status = os.system(cmd)
|
||||
if status == 0 {
|
||||
|
@ -372,7 +373,12 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
|||
}
|
||||
time.sleep(500 * time.millisecond)
|
||||
}
|
||||
ts.failed = true
|
||||
if details.flaky && !testing.fail_flaky {
|
||||
ts.append_message(.info, ' *FAILURE* of the known flaky test file $relative_file is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: $details.retry .')
|
||||
unsafe {
|
||||
goto test_passed_system
|
||||
}
|
||||
}
|
||||
ts.benchmark.fail()
|
||||
tls_bench.fail()
|
||||
ts.add_failed_cmd(cmd)
|
||||
|
@ -388,7 +394,6 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
|||
}
|
||||
mut r := os.execute(cmd)
|
||||
if r.exit_code < 0 {
|
||||
ts.failed = true
|
||||
ts.benchmark.fail()
|
||||
tls_bench.fail()
|
||||
ts.append_message(.fail, tls_bench.step_message_fail(normalised_relative_file))
|
||||
|
@ -399,7 +404,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
|||
details := get_test_details(file)
|
||||
os.setenv('VTEST_RETRY_MAX', '$details.retry', true)
|
||||
for retry := 1; retry <= details.retry; retry++ {
|
||||
ts.append_message(.info, ' retrying $retry/$details.retry of $relative_file ...')
|
||||
ts.append_message(.info, ' retrying $retry/$details.retry of $relative_file ; known flaky: $details.flaky ...')
|
||||
os.setenv('VTEST_RETRY', '$retry', true)
|
||||
r = os.execute(cmd)
|
||||
if r.exit_code == 0 {
|
||||
|
@ -408,7 +413,12 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
|||
}
|
||||
}
|
||||
}
|
||||
ts.failed = true
|
||||
if details.flaky && !testing.fail_flaky {
|
||||
ts.append_message(.info, ' *FAILURE* of the known flaky test file $relative_file is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: $details.retry .')
|
||||
unsafe {
|
||||
goto test_passed_execute
|
||||
}
|
||||
}
|
||||
ts.benchmark.fail()
|
||||
tls_bench.fail()
|
||||
ending_newline := if r.output.ends_with('\n') { '\n' } else { '' }
|
||||
|
@ -457,7 +467,7 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
|
|||
// for example module import tests, or subtests, that are compiled/run by other parent tests
|
||||
// in specific configurations, etc.
|
||||
if fnormalised.contains('testdata/') || fnormalised.contains('modules/')
|
||||
|| f.contains('preludes/') {
|
||||
|| fnormalised.contains('preludes/') {
|
||||
continue
|
||||
}
|
||||
$if windows {
|
||||
|
@ -475,7 +485,8 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
|
|||
skipped << skipped_f
|
||||
}
|
||||
for skip_prefix in oskipped {
|
||||
if f.starts_with(skip_prefix) {
|
||||
skip_folder := skip_prefix + '/'
|
||||
if fnormalised.starts_with(skip_folder) {
|
||||
continue next_file
|
||||
}
|
||||
}
|
||||
|
@ -495,7 +506,7 @@ pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string, c
|
|||
cb(mut session)
|
||||
session.test()
|
||||
eprintln(session.benchmark.total_message(finish_label))
|
||||
return session.failed
|
||||
return session.failed_cmds.len > 0
|
||||
}
|
||||
|
||||
pub fn build_v_cmd_failed(cmd string) bool {
|
||||
|
@ -562,6 +573,7 @@ pub fn setup_new_vtmp_folder() string {
|
|||
pub struct TestDetails {
|
||||
pub mut:
|
||||
retry int
|
||||
flaky bool // when flaky tests fail, the whole run is still considered successfull, unless VTEST_FAIL_FLAKY is 1
|
||||
}
|
||||
|
||||
pub fn get_test_details(file string) TestDetails {
|
||||
|
@ -571,6 +583,9 @@ pub fn get_test_details(file string) TestDetails {
|
|||
if line.starts_with('// vtest retry:') {
|
||||
res.retry = line.all_after(':').trim_space().int()
|
||||
}
|
||||
if line.starts_with('// vtest flaky:') {
|
||||
res.flaky = line.all_after(':').trim_space().bool()
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ fn main() {
|
|||
should_sync := fp.bool('cache-sync', `s`, false, 'Update the local cache')
|
||||
context.is_bisect = fp.bool('bisect', `b`, false, 'Bisect mode. Use the current commit in the repo where oldv is.')
|
||||
if !should_sync && !context.is_bisect {
|
||||
fp.limit_free_args(1, 1) ?
|
||||
fp.limit_free_args(1, 1)?
|
||||
}
|
||||
////
|
||||
context.cleanup = fp.bool('clean', 0, false, 'Clean before running (slower).')
|
||||
|
|
|
@ -194,7 +194,7 @@ fn main() {
|
|||
fp.description(tool_description)
|
||||
fp.arguments_description('COMMIT_BEFORE [COMMIT_AFTER]')
|
||||
fp.skip_executable()
|
||||
fp.limit_free_args(1, 2) ?
|
||||
fp.limit_free_args(1, 2)?
|
||||
context.vflags = fp.string('vflags', 0, '', 'Additional options to pass to the v commands, for example "-cc tcc"')
|
||||
context.hyperfineopts = fp.string('hyperfine_options', 0, '', 'Additional options passed to hyperfine.
|
||||
${flag.space}For example on linux, you may want to pass:
|
||||
|
|
|
@ -143,7 +143,7 @@ const (
|
|||
|
||||
fn main() {
|
||||
mut context := Context{}
|
||||
context.parse_options() ?
|
||||
context.parse_options()?
|
||||
context.run()
|
||||
context.show_diff_summary()
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ fn (mut context Context) parse_options() ? {
|
|||
fp.description('Repeat command(s) and collect statistics. Note: you have to quote each command, if it contains spaces.')
|
||||
fp.arguments_description('CMD1 CMD2 ...')
|
||||
fp.skip_executable()
|
||||
fp.limit_free_args_to_at_least(1) ?
|
||||
fp.limit_free_args_to_at_least(1)?
|
||||
context.count = fp.int('count', `c`, 10, 'Repetition count.')
|
||||
context.series = fp.int('series', `s`, 2, 'Series count. `-s 2 -c 4 a b` => aaaabbbbaaaabbbb, while `-s 3 -c 2 a b` => aabbaabbaabb.')
|
||||
context.warmup = fp.int('warmup', `w`, 2, 'Warmup runs. These are done *only at the start*, and are ignored.')
|
||||
|
|
|
@ -42,7 +42,7 @@ fn cleanup_tdir() {
|
|||
|
||||
fn create_test(tname string, tcontent string) ?string {
|
||||
tpath := os.join_path(tdir, tname)
|
||||
os.write_file(tpath, tcontent) ?
|
||||
os.write_file(tpath, tcontent)?
|
||||
eprintln('>>>>>>>> tpath: $tpath | tcontent: $tcontent')
|
||||
return tpath
|
||||
}
|
||||
|
@ -52,17 +52,17 @@ fn main() {
|
|||
os.chdir(os.wd_at_startup) or {}
|
||||
}
|
||||
println('> vroot: $vroot | vexe: $vexe | tdir: $tdir')
|
||||
ok_fpath := create_test('a_single_ok_test.v', 'fn test_ok(){ assert true }') ?
|
||||
ok_fpath := create_test('a_single_ok_test.v', 'fn test_ok(){ assert true }')?
|
||||
check_ok('"$vexe" "$ok_fpath"')
|
||||
check_ok('"$vexe" test "$ok_fpath"')
|
||||
check_ok('"$vexe" test "$tdir"')
|
||||
fail_fpath := create_test('a_single_failing_test.v', 'fn test_fail(){ assert 1 == 2 }') ?
|
||||
fail_fpath := create_test('a_single_failing_test.v', 'fn test_fail(){ assert 1 == 2 }')?
|
||||
check_fail('"$vexe" "$fail_fpath"')
|
||||
check_fail('"$vexe" test "$fail_fpath"')
|
||||
check_fail('"$vexe" test "$tdir"')
|
||||
rel_dir := os.join_path(tdir, rand.ulid())
|
||||
os.mkdir(rel_dir) ?
|
||||
os.chdir(rel_dir) ?
|
||||
os.mkdir(rel_dir)?
|
||||
os.chdir(rel_dir)?
|
||||
check_ok('"$vexe" test "..${os.path_separator + os.base(ok_fpath)}"')
|
||||
println('> all done')
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ fn C.cJSON_CreateNull() &C.cJSON
|
|||
|
||||
// fn C.cJSON_CreateNumber() &C.cJSON
|
||||
// fn C.cJSON_CreateString() &C.cJSON
|
||||
fn C.cJSON_CreateRaw(&byte) &C.cJSON
|
||||
fn C.cJSON_CreateRaw(&u8) &C.cJSON
|
||||
|
||||
fn C.cJSON_IsInvalid(voidptr) bool
|
||||
|
||||
|
@ -45,13 +45,13 @@ fn C.cJSON_IsObject(voidptr) bool
|
|||
|
||||
fn C.cJSON_IsRaw(voidptr) bool
|
||||
|
||||
fn C.cJSON_AddItemToObject(voidptr, &byte, voidptr)
|
||||
fn C.cJSON_AddItemToObject(voidptr, &u8, voidptr)
|
||||
|
||||
fn C.cJSON_AddItemToArray(voidptr, voidptr)
|
||||
|
||||
fn C.cJSON_Delete(voidptr)
|
||||
|
||||
fn C.cJSON_Print(voidptr) &byte
|
||||
fn C.cJSON_Print(voidptr) &u8
|
||||
|
||||
[inline]
|
||||
fn create_object() &C.cJSON {
|
||||
|
|
|
@ -44,7 +44,7 @@ fn main() {
|
|||
for hf in hfields.split(',') {
|
||||
ctx.hide_names[hf] = true
|
||||
}
|
||||
fp.limit_free_args_to_at_least(1) ?
|
||||
fp.limit_free_args_to_at_least(1)?
|
||||
rest_of_args := fp.remaining_parameters()
|
||||
for vfile in rest_of_args {
|
||||
file := get_abs_path(vfile)
|
||||
|
@ -283,7 +283,7 @@ fn (t Tree) embed_file(node ast.EmbeddedFile) &Node {
|
|||
obj.add('compression_type', t.string_node(node.compression_type))
|
||||
obj.add('is_compressed', t.bool_node(node.is_compressed))
|
||||
obj.add('len', t.number_node(node.len))
|
||||
obj.add('bytes', t.array_node_byte(node.bytes))
|
||||
obj.add('bytes', t.array_node_u8(node.bytes))
|
||||
return obj
|
||||
}
|
||||
|
||||
|
@ -1216,7 +1216,7 @@ fn (t Tree) string_inter_literal(node ast.StringInterLiteral) &Node {
|
|||
obj.add_terse('pluss', t.array_node_bool(node.pluss))
|
||||
obj.add_terse('fills', t.array_node_bool(node.fills))
|
||||
obj.add_terse('fmt_poss', t.array_node_position(node.fmt_poss))
|
||||
obj.add_terse('fmts', t.array_node_byte(node.fmts))
|
||||
obj.add_terse('fmts', t.array_node_u8(node.fmts))
|
||||
obj.add_terse('need_fmts', t.array_node_bool(node.need_fmts))
|
||||
obj.add('pos', t.pos(node.pos))
|
||||
return obj
|
||||
|
@ -2209,7 +2209,7 @@ fn (t Tree) array_node_int(nodes []int) &Node {
|
|||
return arr
|
||||
}
|
||||
|
||||
fn (t Tree) array_node_byte(nodes []byte) &Node {
|
||||
fn (t Tree) array_node_u8(nodes []u8) &Node {
|
||||
mut arr := new_array()
|
||||
for node in nodes {
|
||||
arr.add_item(t.number_node(node))
|
||||
|
|
|
@ -46,12 +46,12 @@ fn (context Context) footer() string {
|
|||
return ')\n'
|
||||
}
|
||||
|
||||
fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
|
||||
fn (context Context) file2v(bname string, fbytes []u8, bn_max int) string {
|
||||
mut sb := strings.new_builder(1000)
|
||||
bn_diff_len := bn_max - bname.len
|
||||
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = $fbytes.len\n')
|
||||
fbyte := fbytes[0]
|
||||
bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [byte($fbyte), '
|
||||
bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [u8($fbyte), '
|
||||
sb.write_string(bnmae_line)
|
||||
mut line_len := bnmae_line.len + 3
|
||||
for i := 1; i < fbytes.len; i++ {
|
||||
|
@ -73,7 +73,7 @@ fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
|
|||
return sb.str()
|
||||
}
|
||||
|
||||
fn (context Context) bname_and_bytes(file string) ?(string, []byte) {
|
||||
fn (context Context) bname_and_bytes(file string) ?(string, []u8) {
|
||||
fname := os.file_name(file)
|
||||
fname_escaped := fname.replace_each(['.', '_', '-', '_'])
|
||||
byte_name := '$context.prefix$fname_escaped'.to_lower()
|
||||
|
@ -120,7 +120,7 @@ fn main() {
|
|||
if context.write_file != '' && os.file_ext(context.write_file) !in ['.vv', '.v'] {
|
||||
context.write_file += '.v'
|
||||
}
|
||||
mut file_byte_map := map[string][]byte{}
|
||||
mut file_byte_map := map[string][]u8{}
|
||||
for file in real_files {
|
||||
bname, fbytes := context.bname_and_bytes(file) or {
|
||||
eprintln(err.msg())
|
||||
|
@ -130,12 +130,12 @@ fn main() {
|
|||
}
|
||||
max_bname := context.max_bname_len(file_byte_map.keys())
|
||||
if context.write_file.len > 0 {
|
||||
mut out_file := os.create(context.write_file) ?
|
||||
out_file.write_string(context.header()) ?
|
||||
mut out_file := os.create(context.write_file)?
|
||||
out_file.write_string(context.header())?
|
||||
for bname, fbytes in file_byte_map {
|
||||
out_file.write_string(context.file2v(bname, fbytes, max_bname)) ?
|
||||
out_file.write_string(context.file2v(bname, fbytes, max_bname))?
|
||||
}
|
||||
out_file.write_string(context.footer()) ?
|
||||
out_file.write_string(context.footer())?
|
||||
} else {
|
||||
print(context.header())
|
||||
for bname, fbytes in file_byte_map {
|
||||
|
|
|
@ -12,7 +12,8 @@ const efolders = [
|
|||
fn main() {
|
||||
args_string := os.args[1..].join(' ')
|
||||
params := args_string.all_before('build-examples')
|
||||
skip_prefixes := efolders.map(os.real_path(os.join_path_single(vroot, it)))
|
||||
skip_prefixes := efolders.map(os.real_path(os.join_path_single(vroot, it)).replace('\\',
|
||||
'/'))
|
||||
res := testing.v_build_failing_skipped(params, 'examples', skip_prefixes, fn (mut session testing.TestSession) {
|
||||
for x in efolders {
|
||||
pathsegments := x.split_any('/')
|
||||
|
|
|
@ -23,7 +23,7 @@ fn main() {
|
|||
args_string := os.args[1..].join(' ')
|
||||
vexe := os.getenv('VEXE')
|
||||
vroot := os.dir(vexe)
|
||||
os.chdir(vroot) ?
|
||||
os.chdir(vroot)?
|
||||
folder := os.join_path('cmd', 'tools')
|
||||
tfolder := os.join_path(vroot, 'cmd', 'tools')
|
||||
main_label := 'Building $folder ...'
|
||||
|
@ -31,7 +31,7 @@ fn main() {
|
|||
//
|
||||
mut skips := []string{}
|
||||
for stool in tools_in_subfolders {
|
||||
skips << os.join_path(tfolder, stool)
|
||||
skips << os.join_path(tfolder, stool).replace('\\', '/')
|
||||
}
|
||||
buildopts := args_string.all_before('build-tools')
|
||||
mut session := testing.prepare_test_session(buildopts, folder, skips, main_label)
|
||||
|
@ -43,11 +43,11 @@ fn main() {
|
|||
// eprintln('> session.skip_files: $session.skip_files')
|
||||
session.test()
|
||||
eprintln(session.benchmark.total_message(finish_label))
|
||||
if session.failed {
|
||||
if session.failed_cmds.len > 0 {
|
||||
exit(1)
|
||||
}
|
||||
//
|
||||
mut executables := os.ls(session.vtmp_dir) ?
|
||||
mut executables := os.ls(session.vtmp_dir)?
|
||||
executables.sort()
|
||||
for texe in executables {
|
||||
tname := texe.replace(os.file_ext(texe), '')
|
||||
|
|
|
@ -20,7 +20,7 @@ const (
|
|||
tool_version = \'1.2.1\'
|
||||
version: \'0.2.42\'
|
||||
VERSION = "1.23.8"
|
||||
|
||||
|
||||
Examples:
|
||||
Bump the patch version in v.mod if it exists
|
||||
v bump --patch
|
||||
|
|
|
@ -68,21 +68,21 @@ fn run_individual_test(case BumpTestCase) ? {
|
|||
test_file := os.join_path_single(temp_dir, case.file_name)
|
||||
|
||||
os.rm(test_file) or {}
|
||||
os.write_file(test_file, case.contents) ?
|
||||
os.write_file(test_file, case.contents)?
|
||||
//
|
||||
os.execute_or_exit('${os.quoted_path(vexe)} bump --patch ${os.quoted_path(test_file)}')
|
||||
patch_lines := os.read_lines(test_file) ?
|
||||
patch_lines := os.read_lines(test_file)?
|
||||
assert patch_lines[case.line] == case.expected_patch
|
||||
|
||||
os.execute_or_exit('${os.quoted_path(vexe)} bump --minor ${os.quoted_path(test_file)}')
|
||||
minor_lines := os.read_lines(test_file) ?
|
||||
minor_lines := os.read_lines(test_file)?
|
||||
assert minor_lines[case.line] == case.expected_minor
|
||||
|
||||
os.execute_or_exit('${os.quoted_path(vexe)} bump --major ${os.quoted_path(test_file)}')
|
||||
major_lines := os.read_lines(test_file) ?
|
||||
major_lines := os.read_lines(test_file)?
|
||||
assert major_lines[case.line] == case.expected_major
|
||||
//
|
||||
os.rm(test_file) ?
|
||||
os.rm(test_file)?
|
||||
}
|
||||
|
||||
fn test_all_bump_cases() {
|
||||
|
|
|
@ -160,7 +160,7 @@ fn create(args []string) {
|
|||
if c.version == '' {
|
||||
c.version = default_version
|
||||
}
|
||||
default_license := 'MIT'
|
||||
default_license := os.getenv_opt('VLICENSE') or { 'MIT' }
|
||||
c.license = os.input('Input your project license: ($default_license) ')
|
||||
if c.license == '' {
|
||||
c.license = default_license
|
||||
|
|
|
@ -5,7 +5,7 @@ const test_path = 'vcreate_test'
|
|||
fn init_and_check() ? {
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
|
||||
assert os.read_file('vcreate_test.v') ? == [
|
||||
assert os.read_file('vcreate_test.v')? == [
|
||||
'module main\n',
|
||||
'fn main() {',
|
||||
" println('Hello World!')",
|
||||
|
@ -13,7 +13,7 @@ fn init_and_check() ? {
|
|||
'',
|
||||
].join_lines()
|
||||
|
||||
assert os.read_file('v.mod') ? == [
|
||||
assert os.read_file('v.mod')? == [
|
||||
'Module {',
|
||||
" name: 'vcreate_test'",
|
||||
" description: ''",
|
||||
|
@ -24,7 +24,7 @@ fn init_and_check() ? {
|
|||
'',
|
||||
].join_lines()
|
||||
|
||||
assert os.read_file('.gitignore') ? == [
|
||||
assert os.read_file('.gitignore')? == [
|
||||
'# Binaries for programs and plugins',
|
||||
'main',
|
||||
'vcreate_test',
|
||||
|
@ -37,7 +37,7 @@ fn init_and_check() ? {
|
|||
'',
|
||||
].join_lines()
|
||||
|
||||
assert os.read_file('.gitattributes') ? == [
|
||||
assert os.read_file('.gitattributes')? == [
|
||||
'*.v linguist-language=V text=auto eol=lf',
|
||||
'*.vv linguist-language=V text=auto eol=lf',
|
||||
'*.vsh linguist-language=V text=auto eol=lf',
|
||||
|
@ -45,7 +45,7 @@ fn init_and_check() ? {
|
|||
'',
|
||||
].join_lines()
|
||||
|
||||
assert os.read_file('.editorconfig') ? == [
|
||||
assert os.read_file('.editorconfig')? == [
|
||||
'[*]',
|
||||
'charset = utf-8',
|
||||
'end_of_line = lf',
|
||||
|
@ -66,9 +66,9 @@ fn test_v_init() ? {
|
|||
defer {
|
||||
os.rmdir_all(dir) or {}
|
||||
}
|
||||
os.chdir(dir) ?
|
||||
os.chdir(dir)?
|
||||
|
||||
init_and_check() ?
|
||||
init_and_check()?
|
||||
}
|
||||
|
||||
fn test_v_init_in_git_dir() ? {
|
||||
|
@ -78,24 +78,24 @@ fn test_v_init_in_git_dir() ? {
|
|||
defer {
|
||||
os.rmdir_all(dir) or {}
|
||||
}
|
||||
os.chdir(dir) ?
|
||||
os.chdir(dir)?
|
||||
os.execute_or_exit('git init .')
|
||||
init_and_check() ?
|
||||
init_and_check()?
|
||||
}
|
||||
|
||||
fn test_v_init_no_overwrite_gitignore() ? {
|
||||
dir := os.join_path(os.temp_dir(), test_path)
|
||||
os.rmdir_all(dir) or {}
|
||||
os.mkdir(dir) or {}
|
||||
os.write_file('$dir/.gitignore', 'blah') ?
|
||||
os.write_file('$dir/.gitignore', 'blah')?
|
||||
defer {
|
||||
os.rmdir_all(dir) or {}
|
||||
}
|
||||
os.chdir(dir) ?
|
||||
os.chdir(dir)?
|
||||
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
|
||||
assert os.read_file('.gitignore') ? == 'blah'
|
||||
assert os.read_file('.gitignore')? == 'blah'
|
||||
}
|
||||
|
||||
fn test_v_init_no_overwrite_gitattributes_and_editorconfig() ? {
|
||||
|
@ -114,15 +114,15 @@ indent_size = 4
|
|||
dir := os.join_path(os.temp_dir(), test_path)
|
||||
os.rmdir_all(dir) or {}
|
||||
os.mkdir(dir) or {}
|
||||
os.write_file('$dir/.gitattributes', git_attributes_content) ?
|
||||
os.write_file('$dir/.editorconfig', editor_config_content) ?
|
||||
os.write_file('$dir/.gitattributes', git_attributes_content)?
|
||||
os.write_file('$dir/.editorconfig', editor_config_content)?
|
||||
defer {
|
||||
os.rmdir_all(dir) or {}
|
||||
}
|
||||
os.chdir(dir) ?
|
||||
os.chdir(dir)?
|
||||
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
|
||||
assert os.read_file('.gitattributes') ? == git_attributes_content
|
||||
assert os.read_file('.editorconfig') ? == editor_config_content
|
||||
assert os.read_file('.gitattributes')? == git_attributes_content
|
||||
assert os.read_file('.editorconfig')? == editor_config_content
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ fn html_highlight(code string, tb &ast.Table) string {
|
|||
} else if typ == .char {
|
||||
'`$tok.lit`'
|
||||
} else if typ == .comment {
|
||||
if tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
|
||||
if tok.lit != '' && tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
|
||||
} else {
|
||||
tok.lit
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ fn html_highlight(code string, tb &ast.Table) string {
|
|||
break
|
||||
}
|
||||
} else {
|
||||
buf.write_byte(code[i])
|
||||
buf.write_u8(code[i])
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
module main
|
||||
|
||||
const (
|
||||
source_root = 'temp'
|
||||
source_root = 'temp' // some const
|
||||
another = int(5) //
|
||||
)
|
||||
const (
|
||||
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
|
||||
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
|
||||
)
|
||||
Used to indicate that you don't care what the window position is.
|
||||
fn funky()
|
||||
funky - comment for function below
|
||||
funky - comment for function below
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
module main
|
||||
|
||||
const (
|
||||
source_root = 'temp'
|
||||
source_root = 'temp' // some const
|
||||
another = int(5) //
|
||||
)
|
||||
fn funky()
|
||||
const (
|
||||
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
|
||||
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
|
||||
)
|
||||
fn funky()
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
pub const (
|
||||
source_root = 'temp'
|
||||
source_root = 'temp' // some const
|
||||
another = int(5) //
|
||||
)
|
||||
|
||||
// Used to indicate that you don't care what the window position is.
|
||||
pub const (
|
||||
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
|
||||
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
|
||||
)
|
||||
|
||||
// funky - comment for function below
|
||||
|
|
|
@ -16,7 +16,7 @@ fn find_diff_cmd() string {
|
|||
|
||||
fn test_vet() ? {
|
||||
os.setenv('VCOLORS', 'never', true)
|
||||
os.chdir(vroot) ?
|
||||
os.chdir(vroot)?
|
||||
test_dir := 'cmd/tools/vdoc/tests/testdata'
|
||||
main_files := get_main_files_in_dir(test_dir)
|
||||
fails := check_path(vexe, test_dir, main_files)
|
||||
|
|
|
@ -162,7 +162,11 @@ fn color_highlight(code string, tb &ast.Table) string {
|
|||
lit = term.yellow('`$tok.lit`')
|
||||
}
|
||||
.comment {
|
||||
lit = if tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
|
||||
lit = if tok.lit != '' && tok.lit[0] == 1 {
|
||||
'//${tok.lit[1..]}'
|
||||
} else {
|
||||
'//$tok.lit'
|
||||
}
|
||||
}
|
||||
.keyword {
|
||||
lit = term.bright_blue(tok.lit)
|
||||
|
@ -209,16 +213,18 @@ fn color_highlight(code string, tb &ast.Table) string {
|
|||
} else if
|
||||
next_tok.kind in [.lcbr, .rpar, .eof, .comma, .pipe, .name, .rcbr, .assign, .key_pub, .key_mut, .pipe, .comma]
|
||||
&& prev.kind in [.name, .amp, .rsbr, .key_type, .assign, .dot, .question, .rpar, .key_struct, .key_enum, .pipe, .key_interface]
|
||||
&& (tok.lit[0].is_capital() || prev_prev.lit in ['C', 'JS']) {
|
||||
&& ((tok.lit != '' && tok.lit[0].is_capital())
|
||||
|| prev_prev.lit in ['C', 'JS']) {
|
||||
tok_typ = .symbol
|
||||
} else if next_tok.kind == .lpar || (!tok.lit[0].is_capital()
|
||||
&& next_tok.kind == .lt && next_tok.pos == tok.pos + tok.lit.len) {
|
||||
} else if next_tok.kind == .lpar
|
||||
|| (!(tok.lit != '' && tok.lit[0].is_capital()) && next_tok.kind == .lt
|
||||
&& next_tok.pos == tok.pos + tok.lit.len) {
|
||||
tok_typ = .function
|
||||
} else if next_tok.kind == .dot {
|
||||
if tok.lit in ['C', 'JS'] {
|
||||
tok_typ = .prefix
|
||||
} else {
|
||||
if tok.lit[0].is_capital() {
|
||||
if tok.lit != '' && tok.lit[0].is_capital() {
|
||||
tok_typ = .symbol
|
||||
} else {
|
||||
tok_typ = .module_
|
||||
|
@ -271,7 +277,7 @@ fn color_highlight(code string, tb &ast.Table) string {
|
|||
tok = next_tok
|
||||
next_tok = s.scan()
|
||||
} else {
|
||||
buf.write_byte(code[i])
|
||||
buf.write_u8(code[i])
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,9 +132,9 @@ fn (vd VDoc) write_plaintext_content(contents []doc.DocNode, mut pw strings.Buil
|
|||
for ex in examples {
|
||||
pw.write_string(' Example: ')
|
||||
mut fex := ex
|
||||
if ex.index_byte(`\n`) >= 0 {
|
||||
if ex.index_u8(`\n`) >= 0 {
|
||||
// multi-line example
|
||||
pw.write_byte(`\n`)
|
||||
pw.write_u8(`\n`)
|
||||
fex = indent(ex)
|
||||
}
|
||||
if cfg.is_color {
|
||||
|
|
|
@ -61,9 +61,7 @@ fn main() {
|
|||
if term_colors {
|
||||
os.setenv('VCOLORS', 'always', true)
|
||||
}
|
||||
if foptions.is_verbose {
|
||||
eprintln('vfmt foptions: $foptions')
|
||||
}
|
||||
foptions.vlog('vfmt foptions: $foptions')
|
||||
if foptions.is_worker {
|
||||
// -worker should be added by a parent vfmt process.
|
||||
// We launch a sub process for each file because
|
||||
|
@ -109,9 +107,7 @@ fn main() {
|
|||
mut worker_command_array := cli_args_no_files.clone()
|
||||
worker_command_array << ['-worker', util.quote_path(fpath)]
|
||||
worker_cmd := worker_command_array.join(' ')
|
||||
if foptions.is_verbose {
|
||||
eprintln('vfmt worker_cmd: $worker_cmd')
|
||||
}
|
||||
foptions.vlog('vfmt worker_cmd: $worker_cmd')
|
||||
worker_result := os.execute(worker_cmd)
|
||||
// Guard against a possibly crashing worker process.
|
||||
if worker_result.exit_code != 0 {
|
||||
|
@ -151,43 +147,43 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn (foptions &FormatOptions) format_file(file string) {
|
||||
fn setup_preferences_and_table() (&pref.Preferences, &ast.Table) {
|
||||
table := ast.new_table()
|
||||
mut prefs := pref.new_preferences()
|
||||
prefs.is_fmt = true
|
||||
prefs.skip_warnings = true
|
||||
return prefs, table
|
||||
}
|
||||
|
||||
fn (foptions &FormatOptions) vlog(msg string) {
|
||||
if foptions.is_verbose {
|
||||
eprintln('vfmt2 running fmt.fmt over file: $file')
|
||||
eprintln(msg)
|
||||
}
|
||||
table := ast.new_table()
|
||||
// checker := checker.new_checker(table, prefs)
|
||||
}
|
||||
|
||||
fn (foptions &FormatOptions) format_file(file string) {
|
||||
foptions.vlog('vfmt2 running fmt.fmt over file: $file')
|
||||
prefs, table := setup_preferences_and_table()
|
||||
file_ast := parser.parse_file(file, table, .parse_comments, prefs)
|
||||
// checker.check(file_ast)
|
||||
// checker.new_checker(table, prefs).check(file_ast)
|
||||
formatted_content := fmt.fmt(file_ast, table, prefs, foptions.is_debug)
|
||||
file_name := os.file_name(file)
|
||||
ulid := rand.ulid()
|
||||
vfmt_output_path := os.join_path(vtmp_folder, 'vfmt_${ulid}_$file_name')
|
||||
os.write_file(vfmt_output_path, formatted_content) or { panic(err) }
|
||||
if foptions.is_verbose {
|
||||
eprintln('fmt.fmt worked and $formatted_content.len bytes were written to $vfmt_output_path .')
|
||||
}
|
||||
foptions.vlog('fmt.fmt worked and $formatted_content.len bytes were written to $vfmt_output_path .')
|
||||
eprintln('$formatted_file_token$vfmt_output_path')
|
||||
}
|
||||
|
||||
fn (foptions &FormatOptions) format_pipe() {
|
||||
mut prefs := pref.new_preferences()
|
||||
prefs.is_fmt = true
|
||||
if foptions.is_verbose {
|
||||
eprintln('vfmt2 running fmt.fmt over stdin')
|
||||
}
|
||||
foptions.vlog('vfmt2 running fmt.fmt over stdin')
|
||||
prefs, table := setup_preferences_and_table()
|
||||
input_text := os.get_raw_lines_joined()
|
||||
table := ast.new_table()
|
||||
// checker := checker.new_checker(table, prefs)
|
||||
file_ast := parser.parse_text(input_text, '', table, .parse_comments, prefs)
|
||||
// checker.check(file_ast)
|
||||
// checker.new_checker(table, prefs).check(file_ast)
|
||||
formatted_content := fmt.fmt(file_ast, table, prefs, foptions.is_debug)
|
||||
print(formatted_content)
|
||||
if foptions.is_verbose {
|
||||
eprintln('fmt.fmt worked and $formatted_content.len bytes were written to stdout.')
|
||||
}
|
||||
foptions.vlog('fmt.fmt worked and $formatted_content.len bytes were written to stdout.')
|
||||
}
|
||||
|
||||
fn print_compiler_options(compiler_params &pref.Preferences) {
|
||||
|
@ -234,9 +230,7 @@ fn (mut foptions FormatOptions) post_process_file(file string, formatted_file_pa
|
|||
return
|
||||
}
|
||||
diff_cmd := foptions.find_diff_cmd()
|
||||
if foptions.is_verbose {
|
||||
eprintln('Using diff command: $diff_cmd')
|
||||
}
|
||||
foptions.vlog('Using diff command: $diff_cmd')
|
||||
diff := diff.color_compare_files(diff_cmd, file, formatted_file_path)
|
||||
if diff.len > 0 {
|
||||
println(diff)
|
||||
|
|
|
@ -142,11 +142,11 @@ fn main() {
|
|||
exit(1)
|
||||
}
|
||||
|
||||
opt.config = new_config(opt.root_path, toml_conf) ?
|
||||
opt.config = new_config(opt.root_path, toml_conf)?
|
||||
|
||||
gen_in_path := arg_paths[0]
|
||||
if arg_paths.len >= 1 {
|
||||
generate_screenshots(mut opt, gen_in_path) ?
|
||||
generate_screenshots(mut opt, gen_in_path)?
|
||||
}
|
||||
if arg_paths.len > 1 {
|
||||
target_path := arg_paths[1]
|
||||
|
@ -199,7 +199,7 @@ fn generate_screenshots(mut opt Options, output_path string) ? {
|
|||
if opt.verbose {
|
||||
eprintln('Creating output path `$dst_path`')
|
||||
}
|
||||
os.mkdir_all(dst_path) ?
|
||||
os.mkdir_all(dst_path)?
|
||||
}
|
||||
|
||||
screenshot_path := os.join_path(dst_path, rel_out_path)
|
||||
|
@ -332,7 +332,7 @@ fn take_screenshots(opt Options, app AppConfig) ?[]string {
|
|||
// ensure_env returns nothing if everything is okay.
|
||||
fn ensure_env(opt Options) ? {
|
||||
if !os.exists(tmp_dir) {
|
||||
os.mkdir_all(tmp_dir) ?
|
||||
os.mkdir_all(tmp_dir)?
|
||||
}
|
||||
|
||||
if runtime_os !in supported_hosts {
|
||||
|
@ -355,9 +355,9 @@ fn vexe() string {
|
|||
|
||||
fn new_config(root_path string, toml_config string) ?Config {
|
||||
doc := if os.is_file(toml_config) {
|
||||
toml.parse_file(toml_config) ?
|
||||
toml.parse_file(toml_config)?
|
||||
} else {
|
||||
toml.parse_text(toml_config) ?
|
||||
toml.parse_text(toml_config)?
|
||||
}
|
||||
|
||||
path := os.real_path(root_path).trim_right('/')
|
||||
|
|
|
@ -5,8 +5,8 @@ import os
|
|||
import flag
|
||||
|
||||
const (
|
||||
tool_name = os.file_name(os.executable())
|
||||
tool_version = '0.0.3'
|
||||
tool_name = 'v missdoc'
|
||||
tool_version = '0.0.4'
|
||||
tool_description = 'Prints all V functions in .v files under PATH/, that do not yet have documentation comments.'
|
||||
work_dir_prefix = normalise_path(os.real_path(os.wd_at_startup) + '/')
|
||||
)
|
|
@ -584,17 +584,22 @@ fn get_all_modules() []string {
|
|||
mut read_len := 0
|
||||
mut modules := []string{}
|
||||
for read_len < s.len {
|
||||
mut start_token := '<a href="/mod'
|
||||
mut start_token := "<a href='/mod"
|
||||
end_token := '</a>'
|
||||
// get the start index of the module entry
|
||||
mut start_index := s.index_after(start_token, read_len)
|
||||
if start_index == -1 {
|
||||
break
|
||||
start_token = '<a href="/mod'
|
||||
start_index = s.index_after(start_token, read_len)
|
||||
if start_index == -1 {
|
||||
break
|
||||
}
|
||||
}
|
||||
// get the index of the end of anchor (a) opening tag
|
||||
// we use the previous start_index to make sure we are getting a module and not just a random 'a' tag
|
||||
start_token = '">'
|
||||
start_token = '>'
|
||||
start_index = s.index_after(start_token, start_index) + start_token.len
|
||||
|
||||
// get the index of the end of module entry
|
||||
end_index := s.index_after(end_token, start_index)
|
||||
if end_index == -1 {
|
||||
|
|
|
@ -12,11 +12,11 @@ fn main() {
|
|||
fp.version('0.0.1')
|
||||
fp.description('\nScan .v source files, and print the V tokens contained in them.')
|
||||
fp.arguments_description('PATH [PATH]...')
|
||||
fp.limit_free_args_to_at_least(1) ?
|
||||
fp.limit_free_args_to_at_least(1)?
|
||||
pref := pref.new_preferences()
|
||||
mut all_paths := fp.remaining_parameters()
|
||||
for path in all_paths {
|
||||
mut scanner := scanner.new_scanner_file(path, .parse_comments, pref) ?
|
||||
mut scanner := scanner.new_scanner_file(path, .parse_comments, pref)?
|
||||
mut tok := token.Token{}
|
||||
for tok.kind != .eof {
|
||||
tok = scanner.scan()
|
||||
|
|
|
@ -15,7 +15,7 @@ fn main() {
|
|||
short_v_name := vexe_name.all_before('.')
|
||||
//
|
||||
recompilation.must_be_enabled(vroot, 'Please install V from source, to use `$vexe_name self` .')
|
||||
os.chdir(vroot) ?
|
||||
os.chdir(vroot)?
|
||||
os.setenv('VCOLORS', 'always', true)
|
||||
args := os.args[1..].filter(it != 'self')
|
||||
jargs := args.join(' ')
|
||||
|
|
|
@ -11,7 +11,7 @@ fn main() {
|
|||
$if windows {
|
||||
println('Setup freetype...')
|
||||
vroot := os.dir(pref.vexe_path())
|
||||
os.chdir(vroot) ?
|
||||
os.chdir(vroot)?
|
||||
if os.is_dir(freetype_folder) {
|
||||
println('Thirdparty "freetype" is already installed.')
|
||||
} else {
|
||||
|
|
|
@ -172,7 +172,7 @@ fn compile_shaders(opt Options, input_path string) ? {
|
|||
// Currently sokol-shdc allows for multiple --input flags
|
||||
// - but it's only the last entry that's actually compiled/used
|
||||
// Given this fact - we can only compile one '.glsl' file to one C '.h' header
|
||||
compile_shader(co, shader_file) ?
|
||||
compile_shader(co, shader_file)?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,10 +233,10 @@ fn collect(path string, mut list []string) {
|
|||
// tools can be setup or is already in place.
|
||||
fn ensure_external_tools(opt Options) ? {
|
||||
if !os.exists(cache_dir) {
|
||||
os.mkdir_all(cache_dir) ?
|
||||
os.mkdir_all(cache_dir)?
|
||||
}
|
||||
if opt.force_update {
|
||||
download_shdc(opt) ?
|
||||
download_shdc(opt)?
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ fn ensure_external_tools(opt Options) ? {
|
|||
return
|
||||
}
|
||||
|
||||
download_shdc(opt) ?
|
||||
download_shdc(opt)?
|
||||
}
|
||||
|
||||
// shdc_exe returns an absolute path to the `sokol-shdc` tool.
|
||||
|
@ -277,26 +277,26 @@ fn download_shdc(opt Options) ? {
|
|||
}
|
||||
}
|
||||
if os.exists(file) {
|
||||
os.rm(file) ?
|
||||
os.rm(file)?
|
||||
}
|
||||
|
||||
mut dtmp_file, dtmp_path := util.temp_file(util.TempFileOptions{ path: os.dir(file) }) ?
|
||||
mut dtmp_file, dtmp_path := util.temp_file(util.TempFileOptions{ path: os.dir(file) })?
|
||||
dtmp_file.close()
|
||||
if opt.verbose {
|
||||
eprintln('$tool_name downloading sokol-shdc from $download_url')
|
||||
}
|
||||
http.download_file(download_url, dtmp_path) or {
|
||||
os.rm(dtmp_path) ?
|
||||
os.rm(dtmp_path)?
|
||||
return error('$tool_name failed to download sokol-shdc needed for shader compiling: $err')
|
||||
}
|
||||
// Make it executable
|
||||
os.chmod(dtmp_path, 0o775) ?
|
||||
os.chmod(dtmp_path, 0o775)?
|
||||
// Move downloaded file in place
|
||||
os.mv(dtmp_path, file) ?
|
||||
os.mv(dtmp_path, file)?
|
||||
if runtime_os in ['linux', 'macos'] {
|
||||
// Use the .exe file ending to minimize platform friction.
|
||||
os.mv(file, shdc) ?
|
||||
os.mv(file, shdc)?
|
||||
}
|
||||
// Update internal version file
|
||||
os.write_file(shdc_version_file, update_to_shdc_version) ?
|
||||
os.write_file(shdc_version_file, update_to_shdc_version)?
|
||||
}
|
||||
|
|
|
@ -49,17 +49,26 @@ enum RunCommandKind {
|
|||
|
||||
const expect_nothing = '<nothing>'
|
||||
|
||||
const starts_with_nothing = '<nothing>'
|
||||
|
||||
const ends_with_nothing = '<nothing>'
|
||||
|
||||
const contains_nothing = '<nothing>'
|
||||
|
||||
struct Command {
|
||||
mut:
|
||||
line string
|
||||
label string // when set, the label will be printed *before* cmd.line is executed
|
||||
ecode int
|
||||
okmsg string
|
||||
errmsg string
|
||||
rmfile string
|
||||
runcmd RunCommandKind = .system
|
||||
expect string = expect_nothing
|
||||
output string
|
||||
line string
|
||||
label string // when set, the label will be printed *before* cmd.line is executed
|
||||
ecode int
|
||||
okmsg string
|
||||
errmsg string
|
||||
rmfile string
|
||||
runcmd RunCommandKind = .system
|
||||
expect string = expect_nothing
|
||||
starts_with string = starts_with_nothing
|
||||
ends_with string = ends_with_nothing
|
||||
contains string = contains_nothing
|
||||
output string
|
||||
}
|
||||
|
||||
fn get_all_commands() []Command {
|
||||
|
@ -81,12 +90,32 @@ fn get_all_commands() []Command {
|
|||
runcmd: .execute
|
||||
expect: 'Hello, World!\n'
|
||||
}
|
||||
if os.getenv('V_CI_MUSL').len == 0 {
|
||||
for compiler_name in ['clang', 'gcc'] {
|
||||
if _ := os.find_abs_path_of_executable(compiler_name) {
|
||||
res << Command{
|
||||
line: '$vexe -cc $compiler_name -gc boehm run examples/hello_world.v'
|
||||
okmsg: '`v -cc $compiler_name -gc boehm run examples/hello_world.v` works'
|
||||
runcmd: .execute
|
||||
expect: 'Hello, World!\n'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res << Command{
|
||||
line: '$vexe interpret examples/hello_world.v'
|
||||
okmsg: 'V can interpret hello world.'
|
||||
runcmd: .execute
|
||||
expect: 'Hello, World!\n'
|
||||
}
|
||||
res << Command{
|
||||
line: '$vexe interpret examples/hanoi.v'
|
||||
okmsg: 'V can interpret hanoi.v'
|
||||
runcmd: .execute
|
||||
starts_with: 'Disc 1 from A to C...\n'
|
||||
ends_with: 'Disc 1 from A to C...\n'
|
||||
contains: 'Disc 7 from A to C...\n'
|
||||
}
|
||||
res << Command{
|
||||
line: '$vexe -o - examples/hello_world.v | grep "#define V_COMMIT_HASH" > /dev/null'
|
||||
okmsg: 'V prints the generated source code to stdout with `-o -` .'
|
||||
|
@ -210,9 +239,8 @@ fn get_all_commands() []Command {
|
|||
rmfile: 'examples/tetris/tetris'
|
||||
}
|
||||
$if macos || linux {
|
||||
ipath := '$vroot/thirdparty/stdatomic/nix'
|
||||
res << Command{
|
||||
line: '$vexe -o v.c cmd/v && cc -Werror -I ${os.quoted_path(ipath)} v.c -lpthread -lm && rm -rf a.out'
|
||||
line: '$vexe -o v.c cmd/v && cc -Werror v.c -lpthread -lm && rm -rf a.out'
|
||||
label: 'v.c should be buildable with no warnings...'
|
||||
okmsg: 'v.c can be compiled without warnings. This is good :)'
|
||||
rmfile: 'v.c'
|
||||
|
@ -241,23 +269,56 @@ fn (mut cmd Command) run() {
|
|||
spent := sw.elapsed().milliseconds()
|
||||
//
|
||||
mut is_failed := false
|
||||
mut is_failed_expected := false
|
||||
mut is_failed_starts_with := false
|
||||
mut is_failed_ends_with := false
|
||||
mut is_failed_contains := false
|
||||
if cmd.ecode != 0 {
|
||||
is_failed = true
|
||||
}
|
||||
if cmd.expect != expect_nothing {
|
||||
if cmd.output != cmd.expect {
|
||||
is_failed = true
|
||||
is_failed_expected = true
|
||||
}
|
||||
}
|
||||
if cmd.starts_with != starts_with_nothing {
|
||||
if !cmd.output.starts_with(cmd.starts_with) {
|
||||
is_failed = true
|
||||
is_failed_starts_with = true
|
||||
}
|
||||
}
|
||||
if cmd.ends_with != ends_with_nothing {
|
||||
if !cmd.output.ends_with(cmd.ends_with) {
|
||||
is_failed = true
|
||||
is_failed_ends_with = true
|
||||
}
|
||||
}
|
||||
if cmd.contains != contains_nothing {
|
||||
if !cmd.output.contains(cmd.contains) {
|
||||
is_failed = true
|
||||
is_failed_contains = true
|
||||
}
|
||||
}
|
||||
//
|
||||
run_label := if is_failed { term.failed('FAILED') } else { term_highlight('OK') }
|
||||
println('> Running: "$cmd.line" took: $spent ms ... $run_label')
|
||||
//
|
||||
if is_failed && cmd.expect != expect_nothing {
|
||||
if cmd.output != cmd.expect {
|
||||
eprintln('> expected:\n$cmd.expect')
|
||||
eprintln('> output:\n$cmd.output')
|
||||
}
|
||||
if is_failed && is_failed_expected {
|
||||
eprintln('> expected:\n$cmd.expect')
|
||||
eprintln('> output:\n$cmd.output')
|
||||
}
|
||||
if is_failed && is_failed_starts_with {
|
||||
eprintln('> expected to start with:\n$cmd.starts_with')
|
||||
eprintln('> output:\n${cmd.output#[..cmd.starts_with.len]}')
|
||||
}
|
||||
if is_failed && is_failed_ends_with {
|
||||
eprintln('> expected to end with:\n$cmd.ends_with')
|
||||
eprintln('> output:\n${cmd.output#[-cmd.starts_with.len..]}')
|
||||
}
|
||||
if is_failed && is_failed_contains {
|
||||
eprintln('> expected to contain:\n$cmd.contains')
|
||||
eprintln('> output:\n$cmd.output')
|
||||
}
|
||||
if vtest_nocleanup {
|
||||
return
|
||||
|
|
|
@ -54,7 +54,7 @@ fn main() {
|
|||
context.pref = &pref.Preferences{
|
||||
output_mode: .silent
|
||||
}
|
||||
mut source := os.read_file(context.path) ?
|
||||
mut source := os.read_file(context.path)?
|
||||
source = source[..context.cut_index]
|
||||
|
||||
go fn (ms int) {
|
||||
|
|
|
@ -8,6 +8,8 @@ const github_job = os.getenv('GITHUB_JOB')
|
|||
|
||||
const (
|
||||
skip_test_files = [
|
||||
'cmd/tools/vdoc/html_tag_escape_test.v', /* can't locate local module: markdown */
|
||||
'cmd/tools/vdoc/tests/vdoc_file_test.v', /* fails on Windows; order of output is not as expected */
|
||||
'vlib/context/onecontext/onecontext_test.v',
|
||||
'vlib/context/deadline_test.v' /* sometimes blocks */,
|
||||
'vlib/mysql/mysql_orm_test.v' /* mysql not installed */,
|
||||
|
@ -45,6 +47,7 @@ const (
|
|||
'vlib/sqlite/sqlite_orm_test.v',
|
||||
'vlib/v/tests/orm_sub_struct_test.v',
|
||||
'vlib/v/tests/orm_sub_array_struct_test.v',
|
||||
'vlib/v/tests/orm_joined_tables_select_test.v',
|
||||
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
|
||||
'vlib/vweb/tests/vweb_test.v',
|
||||
'vlib/vweb/request_test.v',
|
||||
|
@ -85,6 +88,7 @@ const (
|
|||
'vlib/orm/orm_test.v',
|
||||
'vlib/v/tests/orm_sub_struct_test.v',
|
||||
'vlib/v/tests/orm_sub_array_struct_test.v',
|
||||
'vlib/v/tests/orm_joined_tables_select_test.v',
|
||||
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
|
||||
'vlib/clipboard/clipboard_test.v',
|
||||
'vlib/vweb/tests/vweb_test.v',
|
||||
|
@ -112,8 +116,7 @@ const (
|
|||
'vlib/context/value_test.v',
|
||||
'vlib/orm/orm_test.v',
|
||||
'vlib/v/tests/orm_sub_struct_test.v',
|
||||
'vlib/v/tests/closure_test.v',
|
||||
'vlib/v/tests/closure_generator_test.v',
|
||||
'vlib/v/tests/orm_joined_tables_select_test.v',
|
||||
'vlib/net/websocket/ws_test.v',
|
||||
'vlib/net/unix/unix_test.v',
|
||||
'vlib/net/unix/use_net_and_net_unix_together_test.v',
|
||||
|
@ -139,7 +142,6 @@ const (
|
|||
'do_not_remove',
|
||||
]
|
||||
skip_on_arm64 = [
|
||||
'vlib/v/tests/closure_generator_test.v',
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_non_amd64_or_arm64 = [
|
||||
|
@ -167,6 +169,7 @@ fn main() {
|
|||
cmd_prefix := args_string.all_before('test-self')
|
||||
title := 'testing vlib'
|
||||
mut all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
|
||||
all_test_files << os.walk_ext(os.join_path(vroot, 'cmd'), '_test.v')
|
||||
test_js_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.js.v')
|
||||
all_test_files << test_js_files
|
||||
testing.eheader(title)
|
||||
|
|
|
@ -69,7 +69,7 @@ fn main() {
|
|||
testing.header('Testing...')
|
||||
ts.test()
|
||||
println(ts.benchmark.total_message('all V _test.v files'))
|
||||
if ts.failed {
|
||||
if ts.failed_cmds.len > 0 {
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import v.pref
|
|||
fn main() {
|
||||
vexe := pref.vexe_path()
|
||||
vroot := os.dir(vexe)
|
||||
os.chdir(vroot) ?
|
||||
os.chdir(vroot)?
|
||||
os.setenv('VCOLORS', 'always', true)
|
||||
self_idx := os.args.index('tracev')
|
||||
args := os.args[1..self_idx]
|
||||
|
|
|
@ -26,7 +26,7 @@ fn new_app() App {
|
|||
fn main() {
|
||||
app := new_app()
|
||||
recompilation.must_be_enabled(app.vroot, 'Please install V from source, to use `v up` .')
|
||||
os.chdir(app.vroot) ?
|
||||
os.chdir(app.vroot)?
|
||||
println('Updating V...')
|
||||
app.update_from_master()
|
||||
v_hash := version.githash(false)
|
||||
|
@ -34,13 +34,19 @@ fn main() {
|
|||
// println(v_hash)
|
||||
// println(current_hash)
|
||||
if v_hash == current_hash {
|
||||
println('V is already updated.')
|
||||
app.show_current_v_version()
|
||||
return
|
||||
}
|
||||
$if windows {
|
||||
app.backup('cmd/tools/vup.exe')
|
||||
}
|
||||
app.recompile_v()
|
||||
if !app.recompile_v() {
|
||||
app.show_current_v_version()
|
||||
eprintln('Recompiling V *failed*.')
|
||||
eprintln('Try running `$get_make_cmd_name()` .')
|
||||
exit(1)
|
||||
}
|
||||
app.recompile_vup()
|
||||
app.show_current_v_version()
|
||||
}
|
||||
|
@ -66,7 +72,7 @@ fn (app App) update_from_master() {
|
|||
}
|
||||
}
|
||||
|
||||
fn (app App) recompile_v() {
|
||||
fn (app App) recompile_v() bool {
|
||||
// Note: app.vexe is more reliable than just v (which may be a symlink)
|
||||
opts := if app.is_prod { '-prod' } else { '' }
|
||||
vself := '${os.quoted_path(app.vexe)} $opts self'
|
||||
|
@ -74,35 +80,35 @@ fn (app App) recompile_v() {
|
|||
self_result := os.execute(vself)
|
||||
if self_result.exit_code == 0 {
|
||||
println(self_result.output.trim_space())
|
||||
return
|
||||
return true
|
||||
} else {
|
||||
app.vprintln('`$vself` failed, running `make`...')
|
||||
app.vprintln(self_result.output.trim_space())
|
||||
}
|
||||
app.make(vself)
|
||||
return app.make(vself)
|
||||
}
|
||||
|
||||
fn (app App) recompile_vup() {
|
||||
fn (app App) recompile_vup() bool {
|
||||
vup_result := os.execute('${os.quoted_path(app.vexe)} -g cmd/tools/vup.v')
|
||||
if vup_result.exit_code != 0 {
|
||||
eprintln('recompiling vup.v failed:')
|
||||
eprintln(vup_result.output)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fn (app App) make(vself string) {
|
||||
mut make := 'make'
|
||||
$if windows {
|
||||
make = 'make.bat'
|
||||
}
|
||||
fn (app App) make(vself string) bool {
|
||||
make := get_make_cmd_name()
|
||||
make_result := os.execute(make)
|
||||
if make_result.exit_code != 0 {
|
||||
eprintln('> $make failed:')
|
||||
eprintln('> make output:')
|
||||
eprintln(make_result.output)
|
||||
return
|
||||
return false
|
||||
}
|
||||
app.vprintln(make_result.output)
|
||||
return true
|
||||
}
|
||||
|
||||
fn (app App) show_current_v_version() {
|
||||
|
@ -116,8 +122,7 @@ fn (app App) show_current_v_version() {
|
|||
vversion += ', timestamp: ' + latest_v_commit_time.output.trim_space()
|
||||
}
|
||||
}
|
||||
println('Current V version:')
|
||||
println(vversion)
|
||||
println('Current V version: $vversion')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,3 +167,11 @@ fn (app App) get_git() {
|
|||
eprintln("error: Install `git` using your system's package manager")
|
||||
}
|
||||
}
|
||||
|
||||
fn get_make_cmd_name() string {
|
||||
$if windows {
|
||||
return 'make.bat'
|
||||
} $else {
|
||||
return 'make'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cmd/tools/vvet/tests/array_init_one_val.vv:2: error: Use `var == value` instead of `var in [value]`
|
||||
NB: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
Note: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
|
|
|
@ -3,4 +3,4 @@ cmd/tools/vvet/tests/indent_with_space.vv:10: error: Looks like you are using sp
|
|||
cmd/tools/vvet/tests/indent_with_space.vv:17: error: Looks like you are using spaces for indentation.
|
||||
cmd/tools/vvet/tests/indent_with_space.vv:20: error: Looks like you are using spaces for indentation.
|
||||
cmd/tools/vvet/tests/indent_with_space.vv:22: error: Looks like you are using spaces for indentation.
|
||||
NB: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
Note: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// Some header comment
|
||||
|
||||
// read_response is a carefully constructed comment.
|
||||
// read_response_body. <-- this would earlier trigger a false
|
||||
// postive.
|
||||
pub fn read_response() ?(string, string) {}
|
|
@ -1,2 +1,2 @@
|
|||
cmd/tools/vvet/tests/parens_space_a.vv:1: error: Looks like you are adding a space after `(`
|
||||
NB: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
Note: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cmd/tools/vvet/tests/parens_space_b.vv:1: error: Looks like you are adding a space before `)`
|
||||
NB: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
Note: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
|
|
|
@ -14,7 +14,7 @@ fn find_diff_cmd() string {
|
|||
fn test_vet() ? {
|
||||
vexe := os.getenv('VEXE')
|
||||
vroot := os.dir(vexe)
|
||||
os.chdir(vroot) ?
|
||||
os.chdir(vroot)?
|
||||
test_dir := 'cmd/tools/vvet/tests'
|
||||
tests := get_tests_in_dir(test_dir)
|
||||
fails := check_path(vexe, test_dir, tests)
|
||||
|
|
|
@ -20,11 +20,12 @@ mut:
|
|||
}
|
||||
|
||||
struct Options {
|
||||
is_force bool
|
||||
is_werror bool
|
||||
is_verbose bool
|
||||
show_warnings bool
|
||||
use_color bool
|
||||
is_force bool
|
||||
is_werror bool
|
||||
is_verbose bool
|
||||
show_warnings bool
|
||||
use_color bool
|
||||
doc_private_fns_too bool
|
||||
}
|
||||
|
||||
const term_colors = term.can_show_color_on_stderr()
|
||||
|
@ -38,6 +39,7 @@ fn main() {
|
|||
is_verbose: '-verbose' in vet_options || '-v' in vet_options
|
||||
show_warnings: '-hide-warnings' !in vet_options && '-w' !in vet_options
|
||||
use_color: '-color' in vet_options || (term_colors && '-nocolor' !in vet_options)
|
||||
doc_private_fns_too: '-p' in vet_options
|
||||
}
|
||||
}
|
||||
mut paths := cmdline.only_non_options(vet_options)
|
||||
|
@ -110,92 +112,104 @@ fn (mut vt Vet) vet_file(path string) {
|
|||
|
||||
// vet_line vets the contents of `line` from `vet.file`.
|
||||
fn (mut vt Vet) vet_line(lines []string, line string, lnumber int) {
|
||||
// Vet public functions
|
||||
if line.starts_with('pub fn') || (line.starts_with('fn ') && !(line.starts_with('fn C.')
|
||||
|| line.starts_with('fn main'))) {
|
||||
// Scan function declarations for missing documentation
|
||||
is_pub_fn := line.starts_with('pub fn')
|
||||
if lnumber > 0 {
|
||||
collect_tags := fn (line string) []string {
|
||||
mut cleaned := line.all_before('/')
|
||||
cleaned = cleaned.replace_each(['[', '', ']', '', ' ', ''])
|
||||
return cleaned.split(',')
|
||||
}
|
||||
ident_fn_name := fn (line string) string {
|
||||
mut fn_idx := line.index(' fn ') or { return '' }
|
||||
if line.len < fn_idx + 5 {
|
||||
return ''
|
||||
}
|
||||
mut tokens := line[fn_idx + 4..].split(' ')
|
||||
// Skip struct identifier
|
||||
if tokens.first().starts_with('(') {
|
||||
fn_idx = line.index(')') or { return '' }
|
||||
tokens = line[fn_idx..].split(' ')
|
||||
if tokens.len > 1 {
|
||||
tokens = [tokens[1]]
|
||||
}
|
||||
}
|
||||
if tokens.len > 0 {
|
||||
return tokens[0].all_before('(')
|
||||
}
|
||||
vt.vet_fn_documentation(lines, line, lnumber)
|
||||
}
|
||||
|
||||
// vet_fn_documentation ensures that functions are documented
|
||||
fn (mut vt Vet) vet_fn_documentation(lines []string, line string, lnumber int) {
|
||||
if line.starts_with('fn C.') {
|
||||
return
|
||||
}
|
||||
is_pub_fn := line.starts_with('pub fn ')
|
||||
is_fn := is_pub_fn || line.starts_with('fn ')
|
||||
if !is_fn {
|
||||
return
|
||||
}
|
||||
if line.starts_with('fn main') {
|
||||
return
|
||||
}
|
||||
if !(is_pub_fn || vt.opt.doc_private_fns_too) {
|
||||
return
|
||||
}
|
||||
// Scan function declarations for missing documentation
|
||||
if lnumber > 0 {
|
||||
collect_tags := fn (line string) []string {
|
||||
mut cleaned := line.all_before('/')
|
||||
cleaned = cleaned.replace_each(['[', '', ']', '', ' ', ''])
|
||||
return cleaned.split(',')
|
||||
}
|
||||
ident_fn_name := fn (line string) string {
|
||||
mut fn_idx := line.index(' fn ') or { return '' }
|
||||
if line.len < fn_idx + 5 {
|
||||
return ''
|
||||
}
|
||||
mut line_above := lines[lnumber - 1]
|
||||
mut tags := []string{}
|
||||
if !line_above.starts_with('//') {
|
||||
mut grab := true
|
||||
for j := lnumber - 1; j >= 0; j-- {
|
||||
prev_line := lines[j]
|
||||
if prev_line.contains('}') { // We've looked back to the above scope, stop here
|
||||
break
|
||||
} else if prev_line.starts_with('[') {
|
||||
tags << collect_tags(prev_line)
|
||||
continue
|
||||
} else if prev_line.starts_with('//') { // Single-line comment
|
||||
grab = false
|
||||
break
|
||||
}
|
||||
mut tokens := line[fn_idx + 4..].split(' ')
|
||||
// Skip struct identifier
|
||||
if tokens.first().starts_with('(') {
|
||||
fn_idx = line.index(')') or { return '' }
|
||||
tokens = line[fn_idx..].split(' ')
|
||||
if tokens.len > 1 {
|
||||
tokens = [tokens[1]]
|
||||
}
|
||||
if grab {
|
||||
}
|
||||
if tokens.len > 0 {
|
||||
return tokens[0].all_before('(')
|
||||
}
|
||||
return ''
|
||||
}
|
||||
mut line_above := lines[lnumber - 1]
|
||||
mut tags := []string{}
|
||||
if !line_above.starts_with('//') {
|
||||
mut grab := true
|
||||
for j := lnumber - 1; j >= 0; j-- {
|
||||
prev_line := lines[j]
|
||||
if prev_line.contains('}') { // We've looked back to the above scope, stop here
|
||||
break
|
||||
} else if prev_line.starts_with('[') {
|
||||
tags << collect_tags(prev_line)
|
||||
continue
|
||||
} else if prev_line.starts_with('//') { // Single-line comment
|
||||
grab = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if grab {
|
||||
clean_line := line.all_before_last('{').trim(' ')
|
||||
vt.warn('Function documentation seems to be missing for "$clean_line".',
|
||||
lnumber, .doc)
|
||||
}
|
||||
} else {
|
||||
fn_name := ident_fn_name(line)
|
||||
mut grab := true
|
||||
for j := lnumber - 1; j >= 0; j-- {
|
||||
mut prev_prev_line := ''
|
||||
if j - 1 >= 0 {
|
||||
prev_prev_line = lines[j - 1]
|
||||
}
|
||||
prev_line := lines[j]
|
||||
if prev_line.contains('}') { // We've looked back to the above scope, stop here
|
||||
break
|
||||
} else if prev_line.starts_with('// $fn_name ') {
|
||||
grab = false
|
||||
break
|
||||
} else if prev_line.starts_with('// $fn_name') && !prev_prev_line.starts_with('//') {
|
||||
grab = false
|
||||
clean_line := line.all_before_last('{').trim(' ')
|
||||
if is_pub_fn {
|
||||
vt.warn('Function documentation seems to be missing for "$clean_line".',
|
||||
lnumber, .doc)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fn_name := ident_fn_name(line)
|
||||
mut grab := true
|
||||
for j := lnumber - 1; j >= 0; j-- {
|
||||
prev_line := lines[j]
|
||||
if prev_line.contains('}') { // We've looked back to the above scope, stop here
|
||||
break
|
||||
} else if prev_line.starts_with('// $fn_name ') {
|
||||
grab = false
|
||||
break
|
||||
} else if prev_line.starts_with('// $fn_name') {
|
||||
grab = false
|
||||
if is_pub_fn {
|
||||
clean_line := line.all_before_last('{').trim(' ')
|
||||
vt.warn('The documentation for "$clean_line" seems incomplete.',
|
||||
lnumber, .doc)
|
||||
}
|
||||
break
|
||||
} else if prev_line.starts_with('[') {
|
||||
tags << collect_tags(prev_line)
|
||||
continue
|
||||
} else if prev_line.starts_with('//') { // Single-line comment
|
||||
continue
|
||||
}
|
||||
}
|
||||
if grab {
|
||||
clean_line := line.all_before_last('{').trim(' ')
|
||||
if is_pub_fn {
|
||||
vt.warn('A function name is missing from the documentation of "$clean_line".',
|
||||
lnumber, .doc)
|
||||
}
|
||||
vt.warn('The documentation for "$clean_line" seems incomplete.', lnumber,
|
||||
.doc)
|
||||
break
|
||||
} else if prev_line.starts_with('[') {
|
||||
tags << collect_tags(prev_line)
|
||||
continue
|
||||
} else if prev_line.starts_with('//') { // Single-line comment
|
||||
continue
|
||||
}
|
||||
}
|
||||
if grab {
|
||||
clean_line := line.all_before_last('{').trim(' ')
|
||||
vt.warn('A function name is missing from the documentation of "$clean_line".',
|
||||
lnumber, .doc)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ fn main() {
|
|||
fp.description('Collect all .v files needed for a compilation, then re-run the compilation when any of the source changes.')
|
||||
fp.arguments_description('[--silent] [--clear] [--ignore .db] [--add /path/to/a/file.v] [run] program.v')
|
||||
fp.allow_unknown_args()
|
||||
fp.limit_free_args_to_at_least(1) ?
|
||||
fp.limit_free_args_to_at_least(1)?
|
||||
context.is_worker = fp.bool('vwatchworker', 0, false, 'Internal flag. Used to distinguish vwatch manager and worker processes.')
|
||||
context.silent = fp.bool('silent', `s`, false, 'Be more silent; do not print the watch timestamp before each re-run.')
|
||||
context.clear_terminal = fp.bool('clear', `c`, false, 'Clears the terminal before each re-run.')
|
||||
|
|
|
@ -257,7 +257,7 @@ see also `v help build`.
|
|||
Passing -no-std will remove that flag, and you can then use -cflags ''
|
||||
to pass the other options for your specific C compiler.
|
||||
|
||||
-assert aborts
|
||||
-assert aborts
|
||||
Call abort() after an assertion failure. Debuggers usually
|
||||
install signal handlers for SIGABRT, so your program will stop and you
|
||||
will get a backtrace. If you are running your program outside of a
|
||||
|
@ -267,3 +267,14 @@ see also `v help build`.
|
|||
Call print_backtrace() after an assertion failure. Note that
|
||||
backtraces are not implemented yet on all combinations of
|
||||
platform/compiler.
|
||||
|
||||
-thread-stack-size 4194304
|
||||
Set the thread stack size to 4MB. Use multiples of 4096.
|
||||
The default is 8MB, which is enough for compiling V programs, with deeply
|
||||
nested expressions (~40 levels).
|
||||
It may need to be increased, if you are getting stack overflow errors for
|
||||
deeply recursive programs like some of the stages of the V compiler itself,
|
||||
that use relatively few threads.
|
||||
It may be decreased, to reduce the memory footprint of programs that launch
|
||||
hundreds/thousands of threads, but where each of the threads does not need
|
||||
a big stack.
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
v missdoc 0.0.4
|
||||
-----------------------------------------------
|
||||
Usage: v missdoc [options] PATH [PATH]...
|
||||
|
||||
Description: Prints all V functions in .v files under PATH/, that do not yet have documentation comments.
|
||||
|
||||
Options:
|
||||
-h, --help Show this help text.
|
||||
-t, --tags Also print function tags if any is found.
|
||||
-d, --deprecated Include deprecated functions in output.
|
||||
-p, --private Include private functions in output.
|
||||
--js Include JavaScript functions in output.
|
||||
-n, --no-line-numbers Exclude line numbers in output.
|
||||
-e, --exclude <multiple strings>
|
||||
|
||||
-r, --relative-paths Use relative paths in output.
|
|
@ -14,5 +14,8 @@ Options:
|
|||
-v, -verbose
|
||||
Enable verbose logging.
|
||||
|
||||
-p
|
||||
Report private functions with missing documentation too (by default, only the `pub fn` functions will be reported).
|
||||
|
||||
-force
|
||||
(NB: vet development only!) Do not skip the vet regression tests.
|
||||
|
|
|
@ -28,6 +28,7 @@ const (
|
|||
'doctor',
|
||||
'fmt',
|
||||
'gret',
|
||||
'missdoc',
|
||||
'repl',
|
||||
'self',
|
||||
'setup-freetype',
|
||||
|
|
96
doc/docs.md
96
doc/docs.md
|
@ -1,5 +1,7 @@
|
|||
# V Documentation
|
||||
|
||||
(See https://modules.vlang.io/ for documentation of V's standard library)
|
||||
|
||||
## Introduction
|
||||
|
||||
V is a statically typed compiled programming language designed for building maintainable software.
|
||||
|
@ -434,7 +436,7 @@ bool
|
|||
string
|
||||
|
||||
i8 i16 int i64 i128 (soon)
|
||||
byte u16 u32 u64 u128 (soon)
|
||||
u8 u16 u32 u64 u128 (soon)
|
||||
|
||||
rune // represents a Unicode code point
|
||||
|
||||
|
@ -460,7 +462,7 @@ These are the allowed possibilities:
|
|||
↘ ↘
|
||||
f32 → f64
|
||||
↗ ↗
|
||||
byte → u16 → u32 → u64 ⬎
|
||||
u8 → u16 → u32 → u64 ⬎
|
||||
↘ ↘ ↘ ptr
|
||||
i8 → i16 → int → i64 ⬏
|
||||
```
|
||||
|
@ -490,7 +492,7 @@ d := b + x // d is of type `f64` - automatic promotion of `x`'s value
|
|||
```v nofmt
|
||||
name := 'Bob'
|
||||
assert name.len == 3 // will print 3
|
||||
assert name[0] == byte(66) // indexing gives a byte, byte(66) == `B`
|
||||
assert name[0] == u8(66) // indexing gives a byte, u8(66) == `B`
|
||||
assert name[1..3] == 'ob' // slicing gives a string 'ob'
|
||||
|
||||
// escape codes
|
||||
|
@ -499,7 +501,7 @@ assert windows_newline.len == 2
|
|||
|
||||
// arbitrary bytes can be directly specified using `\x##` notation where `#` is
|
||||
// a hex digit aardvark_str := '\x61ardvark' assert aardvark_str == 'aardvark'
|
||||
assert '\xc0'[0] == byte(0xc0)
|
||||
assert '\xc0'[0] == u8(0xc0)
|
||||
|
||||
// or using octal escape `\###` notation where `#` is an octal digit
|
||||
aardvark_str2 := '\141ardvark'
|
||||
|
@ -518,7 +520,7 @@ In V, a string is a read-only array of bytes. All Unicode characters are encoded
|
|||
s := 'hello 🌎' // emoji takes 4 bytes
|
||||
assert s.len == 10
|
||||
|
||||
arr := s.bytes() // convert `string` to `[]byte`
|
||||
arr := s.bytes() // convert `string` to `[]u8`
|
||||
assert arr.len == 10
|
||||
|
||||
s2 := arr.bytestr() // convert `[]byte` to `string`
|
||||
|
@ -692,7 +694,7 @@ A `rune` can be converted to UTF-8 bytes by using the `.bytes()` method.
|
|||
|
||||
```v
|
||||
rocket := `🚀`
|
||||
assert rocket.bytes() == [byte(0xf0), 0x9f, 0x9a, 0x80]
|
||||
assert rocket.bytes() == [u8(0xf0), 0x9f, 0x9a, 0x80]
|
||||
```
|
||||
|
||||
Hex, Unicode, and Octal escape sequences also work in a `rune` literal:
|
||||
|
@ -704,9 +706,9 @@ assert `\u0061` == `a`
|
|||
|
||||
// multibyte literals work too
|
||||
assert `\u2605` == `★`
|
||||
assert `\u2605`.bytes() == [byte(0xe2), 0x98, 0x85]
|
||||
assert `\xe2\x98\x85`.bytes() == [byte(0xe2), 0x98, 0x85]
|
||||
assert `\342\230\205`.bytes() == [byte(0xe2), 0x98, 0x85]
|
||||
assert `\u2605`.bytes() == [u8(0xe2), 0x98, 0x85]
|
||||
assert `\xe2\x98\x85`.bytes() == [u8(0xe2), 0x98, 0x85]
|
||||
assert `\342\230\205`.bytes() == [u8(0xe2), 0x98, 0x85]
|
||||
```
|
||||
|
||||
Note that `rune` literals use the same escape syntax as strings, but they can only hold one unicode
|
||||
|
@ -763,7 +765,7 @@ If you want a different type of integer, you can use casting:
|
|||
|
||||
```v
|
||||
a := i64(123)
|
||||
b := byte(42)
|
||||
b := u8(42)
|
||||
c := i16(12345)
|
||||
```
|
||||
|
||||
|
@ -854,7 +856,7 @@ The type of an array is determined by the first element:
|
|||
* `[1, 2, 3]` is an array of ints (`[]int`).
|
||||
* `['a', 'b']` is an array of strings (`[]string`).
|
||||
|
||||
The user can explicitly specify the type for the first element: `[byte(16), 32, 64, 128]`.
|
||||
The user can explicitly specify the type for the first element: `[u8(16), 32, 64, 128]`.
|
||||
V arrays are homogeneous (all elements must have the same type).
|
||||
This means that code like `[1, 'a']` will not compile.
|
||||
|
||||
|
@ -1301,7 +1303,7 @@ large_index := 999
|
|||
val := arr[large_index] or { panic('out of bounds') }
|
||||
println(val)
|
||||
// you can also do this, if you want to *propagate* the access error:
|
||||
val2 := arr[333] ?
|
||||
val2 := arr[333]?
|
||||
println(val2)
|
||||
```
|
||||
|
||||
|
@ -1891,7 +1893,7 @@ enum State {
|
|||
|
||||
// write log file and return number of bytes written
|
||||
fn write_log(s State) ?int {
|
||||
mut f := os.create('log.txt') ?
|
||||
mut f := os.create('log.txt')?
|
||||
defer {
|
||||
f.close()
|
||||
}
|
||||
|
@ -2420,9 +2422,6 @@ V supports closures too.
|
|||
This means that anonymous functions can inherit variables from the scope they were created in.
|
||||
They must do so explicitly by listing all variables that are inherited.
|
||||
|
||||
> Warning: currently works on Unix-based, x64 architectures only.
|
||||
Some work is in progress to make closures work on Windows, then other architectures.
|
||||
|
||||
```v oksyntax
|
||||
my_int := 1
|
||||
my_closure := fn [my_int] () {
|
||||
|
@ -3420,7 +3419,7 @@ propagate the error:
|
|||
import net.http
|
||||
|
||||
fn f(url string) ?string {
|
||||
resp := http.get(url) ?
|
||||
resp := http.get(url)?
|
||||
return resp.text
|
||||
}
|
||||
```
|
||||
|
@ -3938,7 +3937,7 @@ println(user.last_name)
|
|||
println(user.age)
|
||||
// You can also decode JSON arrays:
|
||||
sfoos := '[{"x":123},{"x":456}]'
|
||||
foos := json.decode([]Foo, sfoos) ?
|
||||
foos := json.decode([]Foo, sfoos)?
|
||||
println(foos[0].x)
|
||||
println(foos[1].x)
|
||||
```
|
||||
|
@ -4043,8 +4042,8 @@ If a test function has an error return type, any propagated errors will fail the
|
|||
import strconv
|
||||
|
||||
fn test_atoi() ? {
|
||||
assert strconv.atoi('1') ? == 1
|
||||
assert strconv.atoi('one') ? == 1 // test will fail
|
||||
assert strconv.atoi('1')? == 1
|
||||
assert strconv.atoi('one')? == 1 // test will fail
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -4436,7 +4435,7 @@ struct Customer {
|
|||
country string [nonull]
|
||||
}
|
||||
|
||||
db := sqlite.connect('customers.db') ?
|
||||
db := sqlite.connect('customers.db')?
|
||||
|
||||
// you can create tables:
|
||||
// CREATE TABLE IF NOT EXISTS `Customer` (
|
||||
|
@ -5357,7 +5356,7 @@ Full list of builtin options:
|
|||
import os
|
||||
fn main() {
|
||||
embedded_file := $embed_file('v.png')
|
||||
os.write_file('exported.png', embedded_file.to_string()) ?
|
||||
os.write_file('exported.png', embedded_file.to_string())?
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -5381,7 +5380,7 @@ Currently only one compression type is supported: `zlib`
|
|||
import os
|
||||
fn main() {
|
||||
embedded_file := $embed_file('v.png', .zlib) // compressed using zlib
|
||||
os.write_file('exported.png', embedded_file.to_string()) ?
|
||||
os.write_file('exported.png', embedded_file.to_string())?
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -5432,9 +5431,6 @@ numbers: [1, 2, 3]
|
|||
3
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
#### `$env`
|
||||
|
||||
```v
|
||||
|
@ -5450,6 +5446,34 @@ V can bring in values at compile time from environment variables.
|
|||
`$env('ENV_VAR')` can also be used in top-level `#flag` and `#include` statements:
|
||||
`#flag linux -I $env('JAVA_HOME')/include`.
|
||||
|
||||
#### `$compile_error` and `$compile_warn`
|
||||
|
||||
These two comptime functions are very useful for displaying custom errors/warnings during
|
||||
compile time.
|
||||
|
||||
Both receive as their only argument a string literal that contains the message to display:
|
||||
|
||||
```v failcompile nofmt
|
||||
// x.v
|
||||
module main
|
||||
|
||||
$if linux {
|
||||
$compile_error('Linux is not supported')
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
||||
$ v run x.v
|
||||
x.v:4:5: error: Linux is not supported
|
||||
2 |
|
||||
3 | $if linux {
|
||||
4 | $compile_error('Linux is not supported')
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
5 | }
|
||||
6 |
|
||||
```
|
||||
|
||||
### Environment specific files
|
||||
|
||||
If a file has an environment-specific suffix, it will only be compiled for that environment.
|
||||
|
@ -5809,7 +5833,7 @@ fn sh(cmd string){
|
|||
rmdir_all('build') or { }
|
||||
|
||||
// Create build/, never fails as build/ does not exist
|
||||
mkdir('build') ?
|
||||
mkdir('build')?
|
||||
|
||||
// Move *.v files to build/
|
||||
result := execute('mv *.v build/')
|
||||
|
@ -5820,7 +5844,7 @@ if result.exit_code != 0 {
|
|||
sh('ls')
|
||||
|
||||
// Similar to:
|
||||
// files := ls('.') ?
|
||||
// files := ls('.')?
|
||||
// mut count := 0
|
||||
// if files.len > 0 {
|
||||
// for file in files {
|
||||
|
@ -6024,7 +6048,7 @@ a nested loop, and those do not risk violating memory-safety.
|
|||
|
||||
## Appendix I: Keywords
|
||||
|
||||
V has 41 reserved keywords (3 are literals):
|
||||
V has 42 reserved keywords (3 are literals):
|
||||
|
||||
```v ignore
|
||||
as
|
||||
|
@ -6036,7 +6060,6 @@ const
|
|||
continue
|
||||
defer
|
||||
else
|
||||
embed
|
||||
enum
|
||||
false
|
||||
fn
|
||||
|
@ -6048,6 +6071,7 @@ import
|
|||
in
|
||||
interface
|
||||
is
|
||||
isreftype
|
||||
lock
|
||||
match
|
||||
module
|
||||
|
@ -6095,15 +6119,15 @@ This lists operators for [primitive types](#primitive-types) only.
|
|||
|
||||
<< left shift integer << unsigned integer
|
||||
>> right shift integer >> unsigned integer
|
||||
>>> unsigned right shift integer >> unsigned integer
|
||||
>>> unsigned right shift integer >> unsigned integer
|
||||
|
||||
|
||||
Precedence Operator
|
||||
5 * / % << >> >>> &
|
||||
4 + - | ^
|
||||
3 == != < <= > >=
|
||||
2 &&
|
||||
1 ||
|
||||
5 * / % << >> >>> &
|
||||
4 + - | ^
|
||||
3 == != < <= > >=
|
||||
2 &&
|
||||
1 ||
|
||||
|
||||
|
||||
Assignment Operators
|
||||
|
|
|
@ -556,11 +556,11 @@ fn (mut app App) set_theme(idx int) {
|
|||
}
|
||||
|
||||
fn (mut app App) resize() {
|
||||
mut s := gg.dpi_scale()
|
||||
mut s := app.gg.scale
|
||||
if s == 0.0 {
|
||||
s = 1.0
|
||||
}
|
||||
window_size := gg.window_size()
|
||||
window_size := app.gg.window_size()
|
||||
w := window_size.width
|
||||
h := window_size.height
|
||||
m := f32(math.min(w, h))
|
||||
|
|
|
@ -5,9 +5,9 @@ import io
|
|||
|
||||
fn main() {
|
||||
// Make a new connection
|
||||
mut conn := net.dial_tcp('google.com:80') ?
|
||||
mut conn := net.dial_tcp('google.com:80')?
|
||||
// Simple http HEAD request for a file
|
||||
conn.write_string('GET /index.html HTTP/1.0\r\n\r\n') ?
|
||||
conn.write_string('GET /index.html HTTP/1.0\r\n\r\n')?
|
||||
// Wrap in a buffered reader
|
||||
mut r := io.new_buffered_reader(reader: conn)
|
||||
for {
|
||||
|
|
|
@ -32,8 +32,7 @@ const (
|
|||
|
||||
struct App {
|
||||
minutes_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw,
|
||||
tp +
|
||||
1 * th, center - tw, tp + 1 * th]
|
||||
tp + 1 * th, center - tw, tp + 1 * th]
|
||||
hours_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 2 * th,
|
||||
center - tw, tp + 2 * th]
|
||||
hours3_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 3 * th,
|
||||
|
|
|
@ -4,7 +4,7 @@ import time
|
|||
|
||||
fn vlang_time(mut wg sync.WaitGroup) ?string {
|
||||
start := time.ticks()
|
||||
data := http.get('https://vlang.io/utc_now') ?
|
||||
data := http.get('https://vlang.io/utc_now')?
|
||||
finish := time.ticks()
|
||||
println('Finish getting time ${finish - start} ms')
|
||||
println(data.text)
|
||||
|
@ -14,7 +14,7 @@ fn vlang_time(mut wg sync.WaitGroup) ?string {
|
|||
|
||||
fn remote_ip(mut wg sync.WaitGroup) ?string {
|
||||
start := time.ticks()
|
||||
data := http.get('https://api.ipify.org') ?
|
||||
data := http.get('https://api.ipify.org')?
|
||||
finish := time.ticks()
|
||||
println('Finish getting ip ${finish - start} ms')
|
||||
println(data.text)
|
||||
|
|
|
@ -8,8 +8,8 @@ fn main() {
|
|||
password: ''
|
||||
dbname: 'mysql'
|
||||
}
|
||||
conn.connect() ?
|
||||
res := conn.query('show tables') ?
|
||||
conn.connect()?
|
||||
res := conn.query('show tables')?
|
||||
for row in res.rows() {
|
||||
println(row.vals.join(', '))
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import sqlite
|
||||
|
||||
fn main() {
|
||||
db := sqlite.connect(':memory:') ?
|
||||
db := sqlite.connect(':memory:')?
|
||||
db.exec("create table users (id integer primary key, name text default '');")
|
||||
|
||||
db.exec("insert into users (name) values ('Sam')")
|
||||
|
|
|
@ -7,9 +7,9 @@ type FNAdder = fn (int, int) int
|
|||
|
||||
fn main() {
|
||||
library_file_path := os.join_path(os.getwd(), dl.get_libname('library'))
|
||||
handle := dl.open_opt(library_file_path, dl.rtld_lazy) ?
|
||||
handle := dl.open_opt(library_file_path, dl.rtld_lazy)?
|
||||
eprintln('handle: ${ptr_str(handle)}')
|
||||
f := FNAdder(dl.sym_opt(handle, 'add_1') ?)
|
||||
f := FNAdder(dl.sym_opt(handle, 'add_1')?)
|
||||
eprintln('f: ${ptr_str(f)}')
|
||||
res := f(1, 2)
|
||||
eprintln('res: $res')
|
||||
|
|
|
@ -22,7 +22,7 @@ fn main() {
|
|||
mut a := i64(0)
|
||||
mut b := i64(0)
|
||||
mut c := i64(1)
|
||||
println(a + c + c)
|
||||
println(a + b + c)
|
||||
for _ in 0 .. stop {
|
||||
// Set a and b to the next term
|
||||
a = b
|
||||
|
|
|
@ -25,7 +25,7 @@ fn on_frame(mut app App) {
|
|||
for mut frame in app.frames {
|
||||
for mut rocket in frame {
|
||||
if !rocket.exploded {
|
||||
rocket.color.a = byte(f32_max(rocket.color.a - 8, 0))
|
||||
rocket.color.a = u8(f32_max(rocket.color.a - 8, 0))
|
||||
rocket.draw(mut app.gg)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import rand
|
|||
|
||||
pub fn random_color() gx.Color {
|
||||
return gx.Color{
|
||||
r: rand.byte()
|
||||
g: rand.byte()
|
||||
b: rand.byte()
|
||||
r: rand.u8()
|
||||
g: rand.u8()
|
||||
b: rand.u8()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn (particle Particle) draw(mut ctx gg.Context) {
|
|||
|
||||
pub fn (mut particle Particle) tick(mut rocket Rocket, mut ctx gg.Context) {
|
||||
particle.lifespan -= get_params().age_rate
|
||||
particle.color.a = byte(particle.lifespan)
|
||||
particle.color.a = u8(particle.lifespan)
|
||||
|
||||
if particle.lifespan <= 0 {
|
||||
rocket.dead = true
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
fn main() {
|
||||
graph := {
|
||||
'A': ['B', 'C']
|
||||
'B': ['A', 'D', 'E']
|
||||
'C': ['A', 'F']
|
||||
'D': ['B']
|
||||
'E': ['B', 'F']
|
||||
'F': ['C', 'E']
|
||||
}
|
||||
println('Graph: $graph')
|
||||
path := breadth_first_search_path(graph, 'A', 'F')
|
||||
println('The shortest path from node A to node F is: $path')
|
||||
assert path == ['A', 'C', 'F']
|
||||
}
|
||||
|
||||
// Breadth-First Search (BFS) allows you to find the shortest distance between two nodes in the graph.
|
||||
fn breadth_first_search_path(graph map[string][]string, vertex string, target string) []string {
|
||||
mut path := []string{}
|
||||
|
@ -24,18 +39,3 @@ fn breadth_first_search_path(graph map[string][]string, vertex string, target st
|
|||
}
|
||||
return path
|
||||
}
|
||||
|
||||
fn main() {
|
||||
graph := {
|
||||
'A': ['B', 'C']
|
||||
'B': ['A', 'D', 'E']
|
||||
'C': ['A', 'F']
|
||||
'D': ['B']
|
||||
'E': ['B', 'F']
|
||||
'F': ['C', 'E']
|
||||
}
|
||||
println('Graph: $graph')
|
||||
path := breadth_first_search_path(graph, 'A', 'F')
|
||||
println('The shortest path from node A to node F is: $path')
|
||||
assert path == ['A', 'C', 'F']
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
// Author: ccs
|
||||
// I follow literally code in C, done many years ago
|
||||
fn main() {
|
||||
// Adjacency matrix as a map
|
||||
graph := {
|
||||
'A': ['B', 'C']
|
||||
'B': ['A', 'D', 'E']
|
||||
'C': ['A', 'F']
|
||||
'D': ['B']
|
||||
'E': ['B', 'F']
|
||||
'F': ['C', 'E']
|
||||
}
|
||||
println('Graph: $graph')
|
||||
path := breadth_first_search_path(graph, 'A', 'F')
|
||||
println('\n The shortest path from node A to node F is: $path.reverse()')
|
||||
}
|
||||
|
||||
// Breadth-First Search (BFS) allows you to find the shortest distance between two nodes in the graph.
|
||||
fn breadth_first_search_path(graph map[string][]string, start string, target string) []string {
|
||||
mut path := []string{} // ONE PATH with SUCCESS = array
|
||||
mut queue := []string{} // a queue ... many paths
|
||||
// all_nodes := graph.keys() // get a key of this map
|
||||
n_nodes := graph.len // numbers of nodes of this graph
|
||||
// a map to store all the nodes visited to avoid cycles
|
||||
// start all them with False, not visited yet
|
||||
mut visited := a_map_nodes_bool(n_nodes) // a map fully
|
||||
// false ==> not visited yet: {'A': false, 'B': false, 'C': false, 'D': false, 'E': false}
|
||||
queue << start // first arrival
|
||||
for queue.len != 0 {
|
||||
mut node := departure(mut queue) // get the front node and remove it
|
||||
if visited[node] == false { // check if this node is already visited
|
||||
// if no ... test it searchinf for a final node
|
||||
visited[node] = true // means: visit this node
|
||||
if node == target {
|
||||
path = build_path_reverse(graph, start, node, visited)
|
||||
return path
|
||||
}
|
||||
// Expansion of node removed from queue
|
||||
print('\n Expansion of node $node (true/false): ${graph[node]}')
|
||||
// take all nodes from the node
|
||||
for vertex in graph[node] { // println("\n ...${vertex}")
|
||||
// not explored yet
|
||||
if visited[vertex] == false {
|
||||
queue << vertex
|
||||
}
|
||||
}
|
||||
print('\n QUEUE: $queue (only not visited) \n Visited: $visited')
|
||||
}
|
||||
}
|
||||
path = ['Path not found, problem in the Graph, start or end nodes! ']
|
||||
return path
|
||||
}
|
||||
|
||||
// Creating a map for VISITED nodes ...
|
||||
// starting by false ===> means this node was not visited yet
|
||||
fn a_map_nodes_bool(size int) map[string]bool {
|
||||
mut my_map := map[string]bool{} // look this map ...
|
||||
base := u8(65)
|
||||
mut key := base.ascii_str()
|
||||
for i in 0 .. size {
|
||||
key = u8(base + i).ascii_str()
|
||||
my_map[key] = false
|
||||
}
|
||||
return my_map
|
||||
}
|
||||
|
||||
// classical removing of a node from the start of a queue
|
||||
fn departure(mut queue []string) string {
|
||||
mut x := queue[0]
|
||||
queue.delete(0)
|
||||
return x
|
||||
}
|
||||
|
||||
// Based in the current node that is final, search for its parent, already visited, up to the root or start node
|
||||
fn build_path_reverse(graph map[string][]string, start string, final string, visited map[string]bool) []string {
|
||||
print('\n\n Nodes visited (true) or no (false): $visited')
|
||||
array_of_nodes := graph.keys()
|
||||
mut current := final
|
||||
mut path := []string{}
|
||||
path << current
|
||||
|
||||
for (current != start) {
|
||||
for i in array_of_nodes {
|
||||
if (current in graph[i]) && (visited[i] == true) {
|
||||
current = i
|
||||
break // the first ocurrence is enough
|
||||
}
|
||||
}
|
||||
path << current // update the path tracked
|
||||
}
|
||||
return path
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
// Author: ccs
|
||||
// I follow literally code in C, done many years ago
|
||||
|
||||
fn main() {
|
||||
// Adjacency matrix as a map
|
||||
// Example 01
|
||||
graph_01 := {
|
||||
'A': ['B', 'C']
|
||||
'B': ['A', 'D', 'E']
|
||||
'C': ['A', 'F']
|
||||
'D': ['B']
|
||||
'E': ['F', 'B', 'F']
|
||||
'F': ['C', 'E']
|
||||
}
|
||||
// Example 02
|
||||
graph_02 := {
|
||||
'A': ['B', 'C', 'D']
|
||||
'B': ['E']
|
||||
'C': ['F']
|
||||
'D': ['E']
|
||||
'E': ['H']
|
||||
'F': ['H']
|
||||
'G': ['H']
|
||||
'H': ['E', 'F', 'G']
|
||||
}
|
||||
// println('Graph: $graph')
|
||||
path_01 := depth_first_search_path(graph_01, 'A', 'F')
|
||||
println('\n Graph_01: a first path from node A to node F is: $path_01.reverse()')
|
||||
path_02 := depth_first_search_path(graph_02, 'A', 'H')
|
||||
println('\n Graph_02: a first path from node A to node F is: $path_02.reverse()')
|
||||
}
|
||||
|
||||
// Depth-First Search (BFS) allows you to find a path between two nodes in the graph.
|
||||
fn depth_first_search_path(graph map[string][]string, start string, target string) []string {
|
||||
mut path := []string{} // ONE PATH with SUCCESS = array
|
||||
mut stack := []string{} // a stack ... many nodes
|
||||
// all_nodes := graph.keys() // get a key of this map
|
||||
n_nodes := graph.len // numbers of nodes of this graph
|
||||
mut visited := a_map_nodes_bool(n_nodes) // a map fully
|
||||
// false ... not visited yet: {'A': false, 'B': false, 'C': false, 'D': false, 'E': false}
|
||||
|
||||
stack << start // first push on the stack
|
||||
for stack.len > 0 {
|
||||
mut node := stack.pop() // get the top node and remove it from the stack
|
||||
|
||||
// check if this node is already visited
|
||||
if visited[node] == false {
|
||||
// if no ... test it searchin for a final node
|
||||
visited[node] = true // means: node visited
|
||||
if node == target {
|
||||
path = build_path_reverse(graph, start, node, visited)
|
||||
return path
|
||||
}
|
||||
// Exploring of node removed from stack and add its relatives
|
||||
print('\n Exploring of node $node (true/false): ${graph[node]}')
|
||||
// graph[node].reverse() take a classical choice for DFS
|
||||
// at most os left in this case.
|
||||
// use vertex in graph[node] the choice is right
|
||||
|
||||
// take all nodes from the node
|
||||
for vertex in graph[node].reverse() {
|
||||
// println("\n ...${vertex}")
|
||||
// not explored yet
|
||||
if visited[vertex] == false {
|
||||
stack << vertex
|
||||
}
|
||||
}
|
||||
print('\n Stack: $stack (only not visited) \n Visited: $visited')
|
||||
}
|
||||
}
|
||||
path = ['Path not found, problem in the Graph, start or end nodes! ']
|
||||
return path
|
||||
}
|
||||
|
||||
// Creating a map for nodes not VISITED visited ...
|
||||
// starting by false ===> means this node was not visited yet
|
||||
fn a_map_nodes_bool(size int) map[string]bool {
|
||||
mut my_map := map[string]bool{} // look this map ...
|
||||
for i in 0 .. size {
|
||||
my_map[u8(65 + i).ascii_str()] = false
|
||||
}
|
||||
return my_map
|
||||
}
|
||||
|
||||
// Based in the current node that is final, search for his parent, that is already visited, up to the root or start node
|
||||
fn build_path_reverse(graph map[string][]string, start string, final string, visited map[string]bool) []string {
|
||||
print('\n\n Nodes visited (true) or no (false): $visited')
|
||||
array_of_nodes := graph.keys()
|
||||
mut current := final
|
||||
mut path := []string{}
|
||||
path << current
|
||||
|
||||
for current != start {
|
||||
for i in array_of_nodes {
|
||||
if (current in graph[i]) && (visited[i] == true) {
|
||||
current = i
|
||||
break // the first ocurrence is enough
|
||||
}
|
||||
}
|
||||
path << current // updating the path tracked
|
||||
}
|
||||
return path
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
// https://en.wikipedia.org/wiki/Topological_sorting
|
||||
// A DFS RECURSIVE ALGORITHM ....
|
||||
// An alternative algorithm for topological sorting is based on depth-first search. The algorithm loops through each node of the graph, in an arbitrary order, initiating a depth-first search that terminates when it hits any node that has already been visited since the beginning
|
||||
// of the topological sort or the node has no outgoing edges (i.e. a leaf node)
|
||||
// Discussion: https://www.gatevidyalay.com/topological-sort-topological-sorting/
|
||||
// $ v run dfs_topological_ordering.v
|
||||
// Author: CCS
|
||||
|
||||
// THE DFS RECURSIVE .... classical searchig for leaves nodes
|
||||
// the arguments are used in the function to avoid global variables....
|
||||
fn dfs_recursive(u string, mut visited map[string]bool, graph map[string][]string, mut top_sorting []string) {
|
||||
print(' Visiting: $u -> ')
|
||||
visited[u] = true
|
||||
|
||||
for v in graph[u] {
|
||||
if visited[v] == false {
|
||||
dfs_recursive(v, mut visited, graph, mut top_sorting)
|
||||
}
|
||||
}
|
||||
top_sorting << u
|
||||
}
|
||||
|
||||
// Creating aa map to initialize with of visited nodes .... all with false in the init
|
||||
// so these nodes are NOT VISITED YET
|
||||
fn visited_init(a_graph map[string][]string) map[string]bool {
|
||||
mut array_of_keys := a_graph.keys() // get all keys of this map
|
||||
mut temp := map[string]bool{} // attention in these initializations with maps
|
||||
for i in array_of_keys {
|
||||
temp[i] = false
|
||||
}
|
||||
return temp
|
||||
}
|
||||
|
||||
// attention here a map STRING ---> ONE BOOLEAN ... not a string
|
||||
|
||||
fn main() {
|
||||
// A map illustration to use in a graph
|
||||
// the graph: adjacency matrix
|
||||
graph_01 := {
|
||||
'A': ['C', 'B']
|
||||
'B': ['D']
|
||||
'C': ['D']
|
||||
'D': []
|
||||
}
|
||||
|
||||
graph_02 := {
|
||||
'A': ['B', 'C', 'D']
|
||||
'B': ['E']
|
||||
'C': ['F']
|
||||
'D': ['G']
|
||||
'E': ['H']
|
||||
'F': ['H']
|
||||
'G': ['H']
|
||||
'H': [] // no cycles
|
||||
}
|
||||
// from: https://en.wikipedia.org/wiki/Topological_sorting
|
||||
graph_03 := {
|
||||
'5': ['11']
|
||||
'7': ['11', '8']
|
||||
'3': ['8', '10']
|
||||
'11': ['2', '9', '10']
|
||||
'8': ['9']
|
||||
'2': []
|
||||
'9': []
|
||||
'10': []
|
||||
}
|
||||
|
||||
mut graph := map[string][]string{} // the graph: adjacency matrix
|
||||
for index, g_value in [graph_01, graph_02, graph_03] {
|
||||
println('Topological sorting for the graph $index using a DFS recursive')
|
||||
graph = g_value.clone() // graphs_sample[g].clone() // choice your SAMPLE
|
||||
|
||||
// mut n_nodes := graph.len
|
||||
mut visited := visited_init(graph) // a map with nodes not visited
|
||||
|
||||
// mut start := (graph.keys()).first() // arbitrary, any node if you wish
|
||||
mut top_sorting := []string{}
|
||||
// advantages of map ... getting all nodes
|
||||
for i in graph.keys() {
|
||||
if visited[i] != true {
|
||||
dfs_recursive(i, mut visited, graph, mut top_sorting)
|
||||
}
|
||||
}
|
||||
|
||||
print('\n A topological sorting of graph $index : ')
|
||||
// println(g_value)
|
||||
println(top_sorting.reverse())
|
||||
println('')
|
||||
} // End of for
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
// The idea of this algorithm follow :
|
||||
// https://www.gatevidyalay.com/topological-sort-topological-sorting/ (GREEDY)
|
||||
// (no cycles are detected)
|
||||
// https://en.wikipedia.org/wiki/Topological_sorting ... just the input data
|
||||
// and the Kahn algorithm
|
||||
// Author: CCS
|
||||
|
||||
// the idea is rude: https://www.gatevidyalay.com/topological-sort-topological-sorting/
|
||||
fn topog_sort_greedy(graph map[string][]string) []string {
|
||||
n_nodes := graph.len // numbers of nodes of this graph
|
||||
mut top_order := []string{} // a vector with sequence of nodes visited
|
||||
mut count := 0
|
||||
/*
|
||||
IDEA ( a greedy algorythm ):
|
||||
|
||||
1. choose allways the node with smallest input degree
|
||||
2. visit it
|
||||
3. put it in the output vector
|
||||
4. remove it from graph
|
||||
5. update the graph (a new graph)
|
||||
6. find a new vector degree
|
||||
7. until all nodes has been visited
|
||||
Back to step 1 (used the variable count)
|
||||
|
||||
Maybe it seems the Kahn's algorithm
|
||||
*/
|
||||
mut v_degree := in_degree(graph) // return: map [string] int
|
||||
print('V Degree $v_degree')
|
||||
mut small_degree := min_degree(v_degree)
|
||||
mut new_graph := remove_node_from_graph(small_degree, graph)
|
||||
top_order << small_degree
|
||||
count++
|
||||
|
||||
for (count < n_nodes) {
|
||||
v_degree = in_degree(new_graph) // return: map [string] int
|
||||
print('\nV Degree $v_degree')
|
||||
small_degree = min_degree(v_degree)
|
||||
new_graph = remove_node_from_graph(small_degree, new_graph)
|
||||
|
||||
top_order << small_degree
|
||||
count++
|
||||
}
|
||||
// print("\n New Graph ${new_graph}")
|
||||
|
||||
return top_order
|
||||
}
|
||||
|
||||
// Give a node, return a list with all nodes incidents or fathers of this node
|
||||
fn all_fathers(node string, a_map map[string][]string) []string {
|
||||
mut array_of_keys := a_map.keys() // get a key of this map
|
||||
mut all_incident := []string{}
|
||||
for i in array_of_keys {
|
||||
// in : function
|
||||
if node in a_map[i] {
|
||||
all_incident << i // a queue of this search
|
||||
}
|
||||
}
|
||||
return all_incident
|
||||
}
|
||||
|
||||
// Input: a map with input degree values, return the key with smallest value
|
||||
fn min_degree(a_map map[string]int) string {
|
||||
mut array_of_keys := a_map.keys() // get a key of this map
|
||||
mut key_min := array_of_keys.first()
|
||||
mut val_min := a_map[key_min]
|
||||
// print("\n MIN: ${val_min} \t key_min: ${key_min} \n the map inp_degree: ${a_map}")
|
||||
for i in array_of_keys {
|
||||
// there is a smaller
|
||||
if val_min > a_map[i] {
|
||||
val_min = a_map[i]
|
||||
key_min = i
|
||||
}
|
||||
}
|
||||
return key_min // the key with smallest value
|
||||
}
|
||||
|
||||
// Given a graph ... return a list of integer with degree of each node
|
||||
fn in_degree(a_map map[string][]string) map[string]int {
|
||||
mut array_of_keys := a_map.keys() // get a key of this map
|
||||
// print(array_of_keys)
|
||||
mut degree := map[string]int{}
|
||||
for i in array_of_keys {
|
||||
degree[i] = all_fathers(i, a_map).len
|
||||
}
|
||||
// print("\n Degree ${in_degree}" )
|
||||
return degree // a vector of the indegree graph
|
||||
}
|
||||
|
||||
// REMOVE A NODE FROM A GRAPH AND RETURN ANOTHER GRAPH
|
||||
fn remove_node_from_graph(node string, a_map map[string][]string) map[string][]string {
|
||||
// mut new_graph := map [string] string {}
|
||||
mut new_graph := a_map.clone() // copy the graph
|
||||
new_graph.delete(node)
|
||||
mut all_nodes := new_graph.keys() // get all nodes of this graph
|
||||
// FOR THE FUTURE with filter
|
||||
// for i in all_nodes {
|
||||
// new_graph[i] = new_graph[i].filter(index(it) != node)
|
||||
// }
|
||||
// A HELP FROM V discussion GITHUB - thread
|
||||
for key in all_nodes {
|
||||
i := new_graph[key].index(node)
|
||||
if i >= 0 {
|
||||
new_graph[key].delete(i)
|
||||
}
|
||||
}
|
||||
// print("\n NEW ${new_graph}" )
|
||||
return new_graph
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// A map illustration to use in a graph
|
||||
// adjacency matrix
|
||||
graph_01 := {
|
||||
'A': ['C', 'B']
|
||||
'B': ['D']
|
||||
'C': ['D']
|
||||
'D': []
|
||||
}
|
||||
|
||||
graph_02 := {
|
||||
'A': ['B', 'C', 'D']
|
||||
'B': ['E']
|
||||
'C': ['F']
|
||||
'D': ['G']
|
||||
'E': ['H']
|
||||
'F': ['H']
|
||||
'G': ['H']
|
||||
'H': []
|
||||
}
|
||||
// from: https://en.wikipedia.org/wiki/Topological_sorting
|
||||
graph_03 := {
|
||||
'5': ['11']
|
||||
'7': ['11', '8']
|
||||
'3': ['8', '10']
|
||||
'11': ['2', '9', '10']
|
||||
'8': ['9']
|
||||
'2': []
|
||||
'9': []
|
||||
'10': []
|
||||
}
|
||||
|
||||
println('\nA Topological Sort of G1: ${topog_sort_greedy(graph_01)}')
|
||||
println('\nA Topological Sort of G2: ${topog_sort_greedy(graph_02)}')
|
||||
println('\nA Topological Sort of G3: ${topog_sort_greedy(graph_03)}')
|
||||
// ['2', '9', '10', '11', '5', '8', '7', '3']
|
||||
}
|
|
@ -34,5 +34,5 @@ fn main() {
|
|||
mut server := Server{
|
||||
handler: ExampleHandler{}
|
||||
}
|
||||
server.listen_and_serve() ?
|
||||
server.listen_and_serve()?
|
||||
}
|
||||
|
|
|
@ -348,19 +348,19 @@ fn animate(mut state State, time f64) {
|
|||
fn main() {
|
||||
canvas, gl := get_webgl()
|
||||
|
||||
vertex_buffer := gl.createBuffer() ?
|
||||
vertex_buffer := gl.createBuffer()?
|
||||
gl.bindBuffer(dom.gl_array_buffer(), vertex_buffer)
|
||||
gl.bufferData(dom.gl_array_buffer(), float32_array(vertices), dom.gl_static_draw())
|
||||
|
||||
color_buffer := gl.createBuffer() ?
|
||||
color_buffer := gl.createBuffer()?
|
||||
gl.bindBuffer(dom.gl_array_buffer(), color_buffer)
|
||||
gl.bufferData(dom.gl_array_buffer(), float32_array(colors), dom.gl_static_draw())
|
||||
|
||||
index_buffer := gl.createBuffer() ?
|
||||
index_buffer := gl.createBuffer()?
|
||||
gl.bindBuffer(dom.gl_element_array_buffer(), index_buffer)
|
||||
gl.bufferData(dom.gl_element_array_buffer(), uint16_array(indices), dom.gl_static_draw())
|
||||
|
||||
vert_shader := gl.createShader(dom.gl_vertex_shader()) ?
|
||||
vert_shader := gl.createShader(dom.gl_vertex_shader())?
|
||||
gl.shaderSource(vert_shader, vert_code.str)
|
||||
gl.compileShader(vert_shader)
|
||||
|
||||
|
@ -368,14 +368,14 @@ fn main() {
|
|||
panic('An error occurred when compiling vertex shader: ${string(gl.getShaderInfoLog(vert_shader))}')
|
||||
}
|
||||
|
||||
frag_shader := gl.createShader(dom.gl_fragment_shader()) ?
|
||||
frag_shader := gl.createShader(dom.gl_fragment_shader())?
|
||||
gl.shaderSource(frag_shader, frag_code.str)
|
||||
gl.compileShader(frag_shader)
|
||||
if !bool(JS.Boolean(gl.getShaderParameter(frag_shader, dom.gl_compile_status()))) {
|
||||
panic('An error occurred when compiling fragment shader: ${string(gl.getShaderInfoLog(frag_shader))}')
|
||||
}
|
||||
|
||||
shader_program := gl.createProgram() ?
|
||||
shader_program := gl.createProgram()?
|
||||
gl.attachShader(shader_program, vert_shader)
|
||||
gl.attachShader(shader_program, frag_shader)
|
||||
gl.linkProgram(shader_program)
|
||||
|
@ -384,9 +384,9 @@ fn main() {
|
|||
panic('unable to initialize the shader program: ${string(gl.getProgramInfoLog(shader_program))}')
|
||||
}
|
||||
|
||||
pmatrix := gl.getUniformLocation(shader_program, 'Pmatrix'.str) ?
|
||||
vmatrix := gl.getUniformLocation(shader_program, 'Vmatrix'.str) ?
|
||||
mmatrix := gl.getUniformLocation(shader_program, 'Mmatrix'.str) ?
|
||||
pmatrix := gl.getUniformLocation(shader_program, 'Pmatrix'.str)?
|
||||
vmatrix := gl.getUniformLocation(shader_program, 'Vmatrix'.str)?
|
||||
mmatrix := gl.getUniformLocation(shader_program, 'Mmatrix'.str)?
|
||||
|
||||
gl.bindBuffer(dom.gl_array_buffer(), vertex_buffer)
|
||||
position := gl.getAttribLocation(shader_program, 'position'.str)
|
||||
|
|
|
@ -32,10 +32,10 @@ mut:
|
|||
fn main() {
|
||||
window := dom.window()
|
||||
document := dom.document
|
||||
clear_btn := document.getElementById('clearButton'.str) ?
|
||||
canvas_elem := document.getElementById('canvas'.str) ?
|
||||
clear_btn := document.getElementById('clearButton'.str)?
|
||||
canvas_elem := document.getElementById('canvas'.str)?
|
||||
canvas := get_canvas(canvas_elem)
|
||||
ctx := canvas.getContext('2d'.str, js_undefined()) ?
|
||||
ctx := canvas.getContext('2d'.str, js_undefined())?
|
||||
context := match ctx {
|
||||
JS.CanvasRenderingContext2D {
|
||||
ctx
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import net
|
||||
|
||||
conn := net.dial_tcp('google.com:80') ?
|
||||
peer_addr := conn.peer_addr() ?
|
||||
conn := net.dial_tcp('google.com:80')?
|
||||
peer_addr := conn.peer_addr()?
|
||||
println('$peer_addr')
|
||||
|
|
|
@ -3,18 +3,18 @@ import io
|
|||
|
||||
fn main() {
|
||||
// Make a new connection
|
||||
mut conn := net.dial_tcp('google.com:80') ?
|
||||
mut conn := net.dial_tcp('google.com:80')?
|
||||
defer {
|
||||
conn.close() or {}
|
||||
}
|
||||
|
||||
println(' peer: $conn.peer_addr()')
|
||||
println('local: $conn.addr()')
|
||||
println(' peer: ${conn.peer_addr()?}')
|
||||
println('local: ${conn.addr()?}')
|
||||
|
||||
// Simple http HEAD request for a file
|
||||
conn.write_string('HEAD /index.html HTTP/1.0\r\n\r\n') ?
|
||||
conn.write_string('HEAD /index.html HTTP/1.0\r\n\r\n')?
|
||||
// Read all the data that is waiting
|
||||
result := io.read_all(reader: conn) ?
|
||||
result := io.read_all(reader: conn)?
|
||||
// Cast to string and print result
|
||||
println(result.bytestr())
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import time
|
|||
|
||||
fn send_request(mut wg sync.WaitGroup) ?string {
|
||||
start := time.ticks()
|
||||
data := http.get('https://google.com') ?
|
||||
data := http.get('https://google.com')?
|
||||
finish := time.ticks()
|
||||
println('Finish getting time ${finish - start} ms')
|
||||
wg.done()
|
||||
|
|
|
@ -9,10 +9,10 @@ fn main() {
|
|||
println('------------------------------------------')
|
||||
is_server := '-l' in os.args
|
||||
port := cmdline.option(os.args, '-p', '40001').int()
|
||||
mut buf := []byte{len: 100}
|
||||
mut buf := []u8{len: 100}
|
||||
if is_server {
|
||||
println('UDP echo server, listening for udp packets on port: $port')
|
||||
mut c := net.listen_udp(':$port') ?
|
||||
mut c := net.listen_udp(':$port')?
|
||||
for {
|
||||
read, addr := c.read(mut buf) or { continue }
|
||||
println('received $read bytes from $addr')
|
||||
|
@ -23,7 +23,7 @@ fn main() {
|
|||
}
|
||||
} else {
|
||||
println('UDP client, sending packets to port: ${port}.\nType `exit` to exit.')
|
||||
mut c := net.dial_udp('localhost:$port') ?
|
||||
mut c := net.dial_udp('localhost:$port')?
|
||||
for {
|
||||
mut line := os.input('client > ')
|
||||
match line {
|
||||
|
@ -36,8 +36,8 @@ fn main() {
|
|||
}
|
||||
else {}
|
||||
}
|
||||
c.write_string(line) ?
|
||||
read, _ := c.read(mut buf) ?
|
||||
c.write_string(line)?
|
||||
read, _ := c.read(mut buf)?
|
||||
println('server : ' + buf[0..read].bytestr())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import sim.anim
|
|||
import sim.args as simargs
|
||||
|
||||
fn main() {
|
||||
args := simargs.parse_args(extra_workers: 1) ? as simargs.ParallelArgs
|
||||
args := simargs.parse_args(extra_workers: 1)? as simargs.ParallelArgs
|
||||
|
||||
mut app := anim.new_app(args)
|
||||
mut workers := []thread{cap: args.workers}
|
||||
|
|
|
@ -7,11 +7,11 @@ import sim.args as simargs
|
|||
import sim.img
|
||||
|
||||
fn main() {
|
||||
args := simargs.parse_args(extra_workers: 2) ? as simargs.ParallelArgs
|
||||
args := simargs.parse_args(extra_workers: 2)? as simargs.ParallelArgs
|
||||
|
||||
img_settings := img.image_settings_from_grid(args.grid)
|
||||
|
||||
mut writer := img.ppm_writer_for_fname(args.filename, img_settings) ?
|
||||
mut writer := img.ppm_writer_for_fname(args.filename, img_settings)?
|
||||
|
||||
mut app := anim.new_app(args)
|
||||
mut workers := []thread{cap: args.workers + 1}
|
||||
|
|
|
@ -33,10 +33,10 @@ pub type SimArgs = ParallelArgs | SequentialArgs
|
|||
|
||||
pub fn parse_args(config ParserSettings) ?SimArgs {
|
||||
if config.sequential {
|
||||
args := parse_sequential_args() ?
|
||||
args := parse_sequential_args()?
|
||||
return SimArgs(args)
|
||||
} else {
|
||||
args := parse_parallel_args(config.extra_workers) ?
|
||||
args := parse_parallel_args(config.extra_workers)?
|
||||
return SimArgs(args)
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ fn parse_sequential_args() ?SequentialArgs {
|
|||
mut fp := flag.new_flag_parser(os.args)
|
||||
fp.application('vps')
|
||||
fp.version('v0.1.0')
|
||||
fp.limit_free_args(0, 0) ?
|
||||
fp.limit_free_args(0, 0)?
|
||||
fp.description('This is a pendulum simulation written in pure V')
|
||||
fp.skip_executable()
|
||||
|
||||
|
@ -96,7 +96,7 @@ fn parse_parallel_args(extra_workers int) ?ParallelArgs {
|
|||
mut fp := flag.new_flag_parser(os.args)
|
||||
fp.application('vps')
|
||||
fp.version('v0.1.0')
|
||||
fp.limit_free_args(0, 0) ?
|
||||
fp.limit_free_args(0, 0)?
|
||||
fp.description('This is a pendulum simulation written in pure V')
|
||||
fp.skip_executable()
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue