#!/usr/bin/env bash # This script helps you build LLVM. It can update the repositories first, # run the check-all after and even install it in your system. Since the # LLVM tree changes constantly, it's recommended that you run this script # with update+check at least once a week, and most importantly, before you # begin a big change, to make sure the repos are current and stable. . llvm-common safe_run verify_env ## CMD line options and defaults CPUs=`grep -c proc /proc/cpuinfo` build_dir=$LLVM_BLD install_dir=$LLVM_BLD/../../install build_type=Release shared= targets= prog=`basename $0` syntax="Syntax: $prog [targets]" update=false check=false master=false inst=false if [ "$1" = "-h" ]; then echo $syntax exit 0 fi ## Choose between make and ninja make=make generator="Unix Makefiles" if which ninja 2>&1 > /dev/null; then make=ninja generator="Ninja" fi ## Debug mode, make it lighter if [ "$LLVM_DEBUG" = true ]; then build_type=Debug shared=-DBUILD_SHARED_LIBS=True targets=-DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64" fi ## Make sure sure build dir is there if [ ! -d $build_dir ]; then safe_run mkdir -p $build_dir fi cd $build_dir ## Re-run CMake if files are damaged / not there if [ ! -f build.ninja ] && [ ! -f Makefile ]; then echo " + Configuring Build" safe_run cmake -G "$generator" $LLVM_SRC \ -DCMAKE_BUILD_TYPE=$build_type \ -DLLVM_BUILD_TESTS=True \ -DLLVM_ENABLE_ASSERTIONS=True \ -DPYTHON_EXECUTABLE=/usr/bin/python2 \ -DCMAKE_INSTALL_PREFIX=$install_dir \ $targets $shared fi ## Build if [ "$1" == "" ]; then echo " + Building LLVM" safe_run $make -j$CPUs else for target in "$@"; do echo " + Running $target" safe_run $make -j$CPUs $target done fi