v / .github / workflows / compile_v_with_vtcc.sh
47 lines · 36 sloc · 1.1 KB · 0ef6ddd8ee75712532e900197304693f6d1496b5
Raw
1#!/usr/bin/env bash
2
3set -ex
4
5function show() {
6 printf "\u001b[35m$1\u001b[0m\n"
7}
8
9show "Prepare"
10rm -rf vtcc/
11
12show "Clone vtcc"
13.github/workflows/retry.sh git clone https://github.com/medvednikov/vtcc --branch stable --quiet vtcc/
14du -s vtcc/
15
16show "Compile vtcc"
17cd vtcc/
18v run make.vsh
19cd ..
20
21ls -la vtcc/vtcc
22./vtcc/vtcc --version
23
24show "Generate the C file, for the current V version"
25./v -o vlang.c cmd/v
26ls -la vlang.c
27
28if [[ "$(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/
34else
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/
47fi
48