v2 / thirdparty / build_scripts / thirdparty-openbsd-amd64_tcc.sh
90 lines · 70 sloc · 3.12 KB · 967a4a2d0a9e2e2e5da714c17fe5a8536fae53a8
Raw
1## NOTE: this script does *not* use a shebang **deliberately**, in order to
2## access the same shell, to capture its own launching command with `fc`,
3## and to record it later in the new commit message in thirdpart/tcc.
4
5## WARNING: THE ORIGINAL OF THIS SCRIPT IS IN:
6## https://github.com/vlang/v/blob/master/thirdparty/build_scripts/thirdparty-openbsd-amd64_tcc.sh ,
7## I.E. IN THE MAIN V REPOSITORY. IF YOU NEED TO MAKE CHANGES, CHANGE THAT.
8##
9## THE `build.sh` FILE IN `vlang/tccbin` REPO IS A COPY, RECORDED AT THE TIME
10## OF REBUILDING, FOR EASIER/RELIABLE REPRODUCTION OF HISTORIC VERSIONS.
11## IT IS NOT INTENDED TO BE MODIFIED.
12
13BUILD_CMD=`fc -nl -0`
14## remove whitespaces before/after the actual command:
15BUILD_CMD="$(echo "${BUILD_CMD}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
16
17set -e
18
19if ! test -f vlib/v/compiler_errors_test.v; then
20 echo "this script should be run in V's main repo folder!"
21 exit 1
22fi
23
24export CFLAGS='-O3'
25export CURRENT_SCRIPT_PATH=$(realpath "$0")
26
27export TCC_COMMIT="${TCC_COMMIT:-mob}"
28export TCC_FOLDER="${TCC_FOLDER:-thirdparty/tcc.$TCC_COMMIT}"
29export CC="${CC:-clang}"
30
31echo " BUILD_CMD: \`$BUILD_CMD\`"
32echo " CC: $CC"
33echo "TCC_COMMIT: $TCC_COMMIT"
34echo "TCC_FOLDER: \`$TCC_FOLDER\`"
35echo ===============================================================
36
37rm -rf tinycc/
38rm -rf thirdparty/tcc.original/
39rsync -a thirdparty/tcc/ thirdparty/tcc.original/
40
41pushd .
42
43git clone git://repo.or.cz/tinycc.git
44
45cd tinycc
46
47git checkout $TCC_COMMIT
48export TCC_COMMIT_FULL_HASH=$(git rev-parse HEAD)
49
50./configure \
51 --prefix=$TCC_FOLDER \
52 --bindir=$TCC_FOLDER \
53 --crtprefix=$TCC_FOLDER/lib:/usr/lib \
54 --sysincludepaths=$TCC_FOLDER/lib/tcc/include:/usr/local/include:/usr/include \
55 --libpaths=$TCC_FOLDER/lib/tcc:$TCC_FOLDER/lib:/usr/lib:/usr/local/lib \
56 --cc="$CC" \
57 --extra-cflags="$CFLAGS" \
58 --config-backtrace=yes \
59 --config-bcheck=yes \
60 --debug
61
62gmake
63gmake install
64
65popd
66
67rsync -a --delete tinycc/$TCC_FOLDER/ $TCC_FOLDER/
68rsync -a thirdparty/tcc.original/.git/ $TCC_FOLDER/.git/
69# rsync -a thirdparty/tcc.original/lib/libgc* $TCC_FOLDER/lib/
70# rsync -a thirdparty/tcc.original/lib/build* $TCC_FOLDER/lib/
71rsync -a thirdparty/tcc.original/README.md $TCC_FOLDER/README.md
72rsync -a $CURRENT_SCRIPT_PATH $TCC_FOLDER/build.sh
73mv $TCC_FOLDER/tcc $TCC_FOLDER/tcc.exe
74
75date > $TCC_FOLDER/build_on_date.txt
76echo $TCC_COMMIT_FULL_HASH > $TCC_FOLDER/build_source_hash.txt
77$TCC_FOLDER/tcc.exe --version > $TCC_FOLDER/build_version.txt
78uname -a > $TCC_FOLDER/build_machine_uname.txt
79
80## show the builtin search paths for sanity checking:
81$TCC_FOLDER/tcc.exe -v -v
82
83pushd .
84cd $TCC_FOLDER
85git add .
86git commit -m "build with \`$BUILD_CMD\`"
87popd
88
89echo "tcc commit: $TCC_COMMIT , full hash: $TCC_COMMIT_FULL_HASH ."
90echo "The tcc executable is ready in $TCC_FOLDER/tcc.exe"
91