From 998e2421c9dde806e9bef7c5d140238606d267cf Mon Sep 17 00:00:00 2001 From: nsubiron Date: Tue, 8 May 2018 20:03:48 +0200 Subject: [PATCH] Speed up setup script --- Docs/how_to_build_on_linux.md | 3 +- Jenkinsfile | 2 +- Setup.sh | 61 +++++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/Docs/how_to_build_on_linux.md b/Docs/how_to_build_on_linux.md index ffdd28a4f..5d880a3fd 100644 --- a/Docs/how_to_build_on_linux.md +++ b/Docs/how_to_build_on_linux.md @@ -47,7 +47,8 @@ Note that the `master` branch contains the latest fixes and features, for the latest stable code may be best to switch to the latest release tag. Run the setup script to download the content and build all dependencies. It -takes a while +takes a while (you can speed up the process by parallelizing the script with the +`--jobs=8` flag) $ ./Setup.sh diff --git a/Jenkinsfile b/Jenkinsfile index e6249f736..c16ff0fdd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { stage('Setup') { steps { - sh './Setup.sh' + sh './Setup.sh --jobs=12' } } diff --git a/Setup.sh b/Setup.sh index ea30b09e1..9a6a29e0d 100755 --- a/Setup.sh +++ b/Setup.sh @@ -16,6 +16,43 @@ set -e +DOC_STRING="Download and compile CARLA content and dependencies." + +USAGE_STRING="Usage: $0 [-h|--help] [-s|--skip-download] [--jobs=N]" + +# ============================================================================== +# -- Parse arguments ----------------------------------------------------------- +# ============================================================================== + +UPDATE_SCRIPT_FLAGS= +NUMBER_OF_ASYNC_JOBS=1 + +OPTS=`getopt -o hs --long help,skip-download,jobs:: -n 'parse-options' -- "$@"` + +if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi + +eval set -- "$OPTS" + +while true; do + case "$1" in + -s | --skip-download ) + UPDATE_SCRIPT_FLAGS=--skip-download; + shift ;; + --jobs) + case "$2" in + "") NUMBER_OF_ASYNC_JOBS=4 ; shift 2 ;; + *) NUMBER_OF_ASYNC_JOBS=$2 ; shift 2 ;; + esac ;; + -h | --help ) + echo "$DOC_STRING" + echo "$USAGE_STRING" + exit 1 + ;; + * ) + break ;; + esac +done + # ============================================================================== # -- Set up environment -------------------------------------------------------- # ============================================================================== @@ -61,10 +98,10 @@ cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="../llvm-install" \ ../llvm-source -make cxx +make -j $NUMBER_OF_ASYNC_JOBS cxx #install libc++ locally in llvm-install folder -make install-libcxx install-libcxxabi +make -j $NUMBER_OF_ASYNC_JOBS install-libcxx install-libcxxabi popd >/dev/null @@ -89,10 +126,13 @@ BOOST_TOOLSET="clang-3.9" BOOST_CFLAGS="-fPIC -std=c++1y -stdlib=libc++ -I../llvm-install/include/c++/v1" BOOST_LFLAGS="-stdlib=libc++ -L../llvm-install/lib" -./bootstrap.sh --with-toolset=clang --prefix=../boost-install +./bootstrap.sh \ + --with-toolset=clang \ + --prefix=../boost-install \ + --with-libraries=system ./b2 clean -./b2 toolset="${BOOST_TOOLSET}" cxxflags="${BOOST_CFLAGS}" linkflags="${BOOST_LFLAGS}" --prefix="../boost-install" -j 4 stage release -./b2 install toolset="${BOOST_TOOLSET}" cxxflags="${BOOST_CFLAGS}" linkflags="${BOOST_LFLAGS}" --prefix="../boost-install" +./b2 toolset="${BOOST_TOOLSET}" cxxflags="${BOOST_CFLAGS}" linkflags="${BOOST_LFLAGS}" --prefix="../boost-install" -j $NUMBER_OF_ASYNC_JOBS stage release +./b2 install toolset="${BOOST_TOOLSET}" cxxflags="${BOOST_CFLAGS}" linkflags="${BOOST_LFLAGS}" --prefix="../boost-install" -j $NUMBER_OF_ASYNC_JOBS popd >/dev/null @@ -103,7 +143,7 @@ popd >/dev/null # Get protobuf source if [[ ! -d "protobuf-source" ]]; then echo "Retrieving protobuf..." - git clone --depth=1 -b v3.3.0 https://github.com/google/protobuf.git protobuf-source + git clone --depth=1 -b v3.3.0 --recurse-submodules https://github.com/google/protobuf.git protobuf-source else echo "Folder protobuf-source already exists, skipping git clone..." fi @@ -118,9 +158,10 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/../llvm-install/lib/" CXX="clang++-3.9" \ CXXFLAGS="-fPIC -stdlib=libc++ -I$PWD/../llvm-install/include/c++/v1" \ LDFLAGS="-stdlib=libc++ -L$PWD/../llvm-install/lib/" \ - --prefix="$PWD/../protobuf-install" -make -make install + --prefix="$PWD/../protobuf-install" \ + --disable-shared +make -j $NUMBER_OF_ASYNC_JOBS +make -j $NUMBER_OF_ASYNC_JOBS install popd >/dev/null @@ -171,7 +212,7 @@ fi # ============================================================================== echo -./Update.sh $@ +./Update.sh $UPDATE_SCRIPT_FLAGS # ============================================================================== # -- ...and we are done --------------------------------------------------------