|
| 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 | + |
| 13 | +BUILD_CMD=`fc -nl -0` |
| 14 | +## remove whitespaces before/after the actual command: |
| 15 | +BUILD_CMD="$(echo "${BUILD_CMD}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" |
| 16 | + |
| 17 | +set -e |
| 18 | + |
| 19 | +if ! 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 |
| 22 | +fi |
| 23 | + |
| 24 | +export CFLAGS='-O3' |
| 25 | +export CURRENT_SCRIPT_PATH=$(realpath "$0") |
| 26 | + |
| 27 | +export TCC_COMMIT="${TCC_COMMIT:-mob}" |
| 28 | +export TCC_FOLDER="${TCC_FOLDER:-thirdparty/tcc.$TCC_COMMIT}" |
| 29 | +export CC="${CC:-gcc}" |
| 30 | + |
| 31 | +echo " BUILD_CMD: \`$BUILD_CMD\`" |
| 32 | +echo " CC: $CC" |
| 33 | +echo "TCC_COMMIT: $TCC_COMMIT" |
| 34 | +echo "TCC_FOLDER: \`$TCC_FOLDER\`" |
| 35 | +echo =============================================================== |
| 36 | + |
| 37 | +rm -rf tinycc/ |
| 38 | +rm -rf thirdparty/tcc.original/ |
| 39 | +rsync -a thirdparty/tcc/ thirdparty/tcc.original/ |
| 40 | +## rm -rf $TCC_FOLDER |
| 41 | + |
| 42 | +pushd . |
| 43 | + |
| 44 | +git clone git://repo.or.cz/tinycc.git |
| 45 | + |
| 46 | +cd tinycc |
| 47 | + |
| 48 | +git checkout $TCC_COMMIT |
| 49 | +export 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 | + |
| 65 | +gmake |
| 66 | +gmake install |
| 67 | + |
| 68 | +popd |
| 69 | + |
| 70 | +rsync -a --delete tinycc/$TCC_FOLDER/ $TCC_FOLDER/ |
| 71 | +rsync -a thirdparty/tcc.original/.git/ $TCC_FOLDER/.git/ |
| 72 | +rsync -a thirdparty/tcc.original/lib/libgc* $TCC_FOLDER/lib/ |
| 73 | +rsync -a thirdparty/tcc.original/lib/build* $TCC_FOLDER/lib/ |
| 74 | +rsync -a thirdparty/tcc.original/README.md $TCC_FOLDER/README.md |
| 75 | +rsync -a $CURRENT_SCRIPT_PATH $TCC_FOLDER/build.sh |
| 76 | +mv $TCC_FOLDER/tcc $TCC_FOLDER/tcc.exe |
| 77 | + |
| 78 | +date > $TCC_FOLDER/build_on_date.txt |
| 79 | +echo $TCC_COMMIT_FULL_HASH > $TCC_FOLDER/build_source_hash.txt |
| 80 | +$TCC_FOLDER/tcc.exe --version > $TCC_FOLDER/build_version.txt |
| 81 | +uname -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 | + |
| 86 | +pushd . |
| 87 | +cd $TCC_FOLDER |
| 88 | +git add . |
| 89 | +git commit -m "build with \`$BUILD_CMD\`" |
| 90 | +popd |
| 91 | + |
| 92 | +echo "tcc commit: $TCC_COMMIT , full hash: $TCC_COMMIT_FULL_HASH ." |
| 93 | +echo "The tcc executable is ready in $TCC_FOLDER/tcc.exe" |
| 94 | + |
0 commit comments