| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | function show() { |
| 6 | printf "\u001b[35m$1\u001b[0m\n" |
| 7 | } |
| 8 | |
| 9 | show "Prepare" |
| 10 | rm -rf vtcc/ |
| 11 | |
| 12 | show "Clone vtcc" |
| 13 | .github/workflows/retry.sh git clone https://github.com/medvednikov/vtcc --branch stable --quiet vtcc/ |
| 14 | du -s vtcc/ |
| 15 | |
| 16 | show "Compile vtcc" |
| 17 | cd vtcc/ |
| 18 | v run make.vsh |
| 19 | cd .. |
| 20 | |
| 21 | ls -la vtcc/vtcc |
| 22 | ./vtcc/vtcc --version |
| 23 | |
| 24 | show "Generate the C file, for the current V version" |
| 25 | ./v -o vlang.c cmd/v |
| 26 | ls -la vlang.c |
| 27 | |
| 28 | if [[ "$(uname)" == "Darwin" ]]; then |
| 29 | show "Compile the C file with vtcc (object only, vtcc targets x86_64 ELF)" |
| 30 | SDK_PATH="$(xcrun --show-sdk-path)" |
| 31 | ./vtcc/vtcc -c vlang.c -o vlang.o -I"${SDK_PATH}/usr/include" |
| 32 | ls -la vlang.o |
| 33 | rm -rf vlang.o vlang.c vtcc/ |
| 34 | else |
| 35 | show "Compile the C file with vtcc" |
| 36 | ./vtcc/vtcc -o v_compiled_with_vtcc vlang.c -lpthread |
| 37 | ls -la v_compiled_with_vtcc |
| 38 | |
| 39 | show "Test the resulting V compiler" |
| 40 | ./v_compiled_with_vtcc version |
| 41 | |
| 42 | show "Compile and run hello with vtcc" |
| 43 | ./v_compiled_with_vtcc -cc vtcc/vtcc -showcc run examples/hello_world.v |
| 44 | |
| 45 | show "Remove the generated temporary files, so the script can be re-run cleanly" |
| 46 | rm -rf v_compiled_with_vtcc vlang.c vtcc/ |
| 47 | fi |
| 48 | |