Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # This script prepares and builds LLVM+Clang in a cycle |
| 4 | # There are two purposes: |
| 5 | # 1. Make sure the board can cope with sequential builds |
| 6 | # for as long as you wish (at least 2 days non-stop) |
| 7 | # 2. Make sure the builds take reasonably the same time |
| 8 | # |
| 9 | # That's why the script has the following features: |
| 10 | # |
| 11 | # * "set +e" to not fail even if the build fails, as a |
| 12 | # subsequent commit can fix that, or even if the build |
| 13 | # fails, we're still stressing the hardware, not the build |
| 14 | # * `date` before each step, so that you can compare |
| 15 | # multiple runs without having to find the `time` output |
| 16 | # * Use -jCPUS, since we're not trying to get it faster, but |
| 17 | # reliable, and that tells us more than -jCPUS+2, etc. |
| 18 | # * Time builds and tests separately, since tests tend to be |
| 19 | # more stable |
| 20 | # * Don't use CCACHE, since that will defeat the purpose |
| 21 | |
| 22 | set +e |
| 23 | |
| 24 | ROOT=`pwd` |
| 25 | CPUS=`grep -c proc /proc/cpuinfo` |
| 26 | LINK_JOBS= |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame^] | 27 | GEN="Unix Makefiles" |
| 28 | BUILD="make" |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 29 | if ninja --version > /dev/null; then |
| 30 | LINK=`free -g | awk '/Mem/ {print $2}'` |
| 31 | LINK_JOBS="-DLLVM_PARALLEL_LINK_JOBS=$LINK" |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame^] | 32 | GEN="Ninja" |
| 33 | BUILD="ninja" |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 34 | fi |
| 35 | |
| 36 | mkdir -p build |
| 37 | if [ ! -d src ]; then |
| 38 | git clone http://llvm.org/git/llvm.git src |
| 39 | fi |
| 40 | if [ ! -d src/tools/clang ]; then |
| 41 | cd src/tools |
| 42 | git clone http://llvm.org/git/clang.git |
| 43 | fi |
| 44 | cd $ROOT/build |
| 45 | if [ ! -f Makefile ]; then |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame^] | 46 | cmake ../src -G "$GEN" \ |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 47 | -DCMAKE_BUILD_TYPE=Release \ |
| 48 | -DLLVM_BUILD_TESTS=True \ |
| 49 | -DLLVM_ENABLE_ASSERTIONS=True \ |
| 50 | $LINK_JOBS |
| 51 | fi |
| 52 | |
| 53 | while /bin/true; do |
| 54 | echo -n "Updating sources at " |
| 55 | date |
| 56 | cd $ROOT/src |
| 57 | git fetch origin; git pull |
| 58 | cd tools/clang |
| 59 | git fetch origin; git pull |
| 60 | cd $ROOT/build |
| 61 | echo -n "Cleaning at " |
| 62 | date |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame^] | 63 | $BUILD -j$CPUS clean |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 64 | echo -n "Building at " |
| 65 | date |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame^] | 66 | $BUILD -j$CPUS |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 67 | echo -n "Testing at " |
| 68 | date |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame^] | 69 | $BUILD -j$CPUS check-all |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 70 | done |