v2 / thirdparty / build_scripts / thirdparty-freebsd-amd64_tcc.sh
94 lines · 72 sloc · 3.21 KB · 308c9a51dda16ca97f511db166263f74a614cf59
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-freebsd-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:-gcc}"
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## rm -rf $TCC_FOLDER
41
42pushd .
43
44git clone git://repo.or.cz/tinycc.git
45
46cd tinycc
47
48git checkout $TCC_COMMIT
49export TCC_COMMIT_FULL_HASH=$(git rev-parse HEAD)
50
51./configure \
52 --prefix=$TCC_FOLDER \
53 --bindir=$TCC_FOLDER \
54 --crtprefix=$TCC_FOLDER/lib:/usr/lib:/usr/lib64 \
55 --sysincludepaths=$TCC_FOLDER/lib/tcc/include:/usr/local/include:/usr/include \
56 --libpaths=$TCC_FOLDER/lib/tcc:$TCC_FOLDER/lib:/usr/lib64:/usr/lib:/lib:/usr/local/lib \
57 --cc="$CC" \
58 --extra-cflags="$CFLAGS" \
59 --config-backtrace=yes \
60 --config-bcheck=yes \
61 --debug
62
63## --extra-ldflags="-L/usr/home/ec2-user/v/tinycc -ltcc" \
64
65gmake
66gmake install
67
68popd
69
70rsync -a --delete tinycc/$TCC_FOLDER/ $TCC_FOLDER/
71rsync -a thirdparty/tcc.original/.git/ $TCC_FOLDER/.git/
72rsync -a thirdparty/tcc.original/lib/libgc* $TCC_FOLDER/lib/
73rsync -a thirdparty/tcc.original/lib/build* $TCC_FOLDER/lib/
74rsync -a thirdparty/tcc.original/README.md $TCC_FOLDER/README.md
75rsync -a $CURRENT_SCRIPT_PATH $TCC_FOLDER/build.sh
76mv $TCC_FOLDER/tcc $TCC_FOLDER/tcc.exe
77
78date > $TCC_FOLDER/build_on_date.txt
79echo $TCC_COMMIT_FULL_HASH > $TCC_FOLDER/build_source_hash.txt
80$TCC_FOLDER/tcc.exe --version > $TCC_FOLDER/build_version.txt
81uname -a > $TCC_FOLDER/build_machine_uname.txt
82
83## show the builtin search paths for sanity checking:
84$TCC_FOLDER/tcc.exe -v -v
85
86pushd .
87cd $TCC_FOLDER
88git add .
89git commit -m "build with \`$BUILD_CMD\`"
90popd
91
92echo "tcc commit: $TCC_COMMIT , full hash: $TCC_COMMIT_FULL_HASH ."
93echo "The tcc executable is ready in $TCC_FOLDER/tcc.exe"
94
95