blob: 178a00b659298b6bffd6cc124e0bf3468e874e71 [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/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
22set +e
23
24ROOT=`pwd`
25CPUS=`grep -c proc /proc/cpuinfo`
26LINK_JOBS=
Renato Golin9f393da2016-05-01 18:17:39 +010027GEN="Unix Makefiles"
28BUILD="make"
Renato Golin94cc1042016-04-26 11:02:23 +010029if ninja --version > /dev/null; then
30 LINK=`free -g | awk '/Mem/ {print $2}'`
31 LINK_JOBS="-DLLVM_PARALLEL_LINK_JOBS=$LINK"
Renato Golin9f393da2016-05-01 18:17:39 +010032 GEN="Ninja"
33 BUILD="ninja"
Renato Golin94cc1042016-04-26 11:02:23 +010034fi
35
36mkdir -p build
37if [ ! -d src ]; then
38 git clone http://llvm.org/git/llvm.git src
39fi
40if [ ! -d src/tools/clang ]; then
41 cd src/tools
42 git clone http://llvm.org/git/clang.git
43fi
44cd $ROOT/build
45if [ ! -f Makefile ]; then
Renato Golin9f393da2016-05-01 18:17:39 +010046 cmake ../src -G "$GEN" \
Renato Golin94cc1042016-04-26 11:02:23 +010047 -DCMAKE_BUILD_TYPE=Release \
48 -DLLVM_BUILD_TESTS=True \
49 -DLLVM_ENABLE_ASSERTIONS=True \
50 $LINK_JOBS
51fi
52
53while /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 Golin9f393da2016-05-01 18:17:39 +010063 $BUILD -j$CPUS clean
Renato Golin94cc1042016-04-26 11:02:23 +010064 echo -n "Building at "
65 date
Renato Golin9f393da2016-05-01 18:17:39 +010066 $BUILD -j$CPUS
Renato Golin94cc1042016-04-26 11:02:23 +010067 echo -n "Testing at "
68 date
Renato Golin9f393da2016-05-01 18:17:39 +010069 $BUILD -j$CPUS check-all
Renato Golin94cc1042016-04-26 11:02:23 +010070done