From 1fcd5d1067254c40921df17b8de906c81934077a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 20 Oct 2017 13:31:52 +0200 Subject: Add support for parallel bootstrap on Linux, Mac OS, and FreeBSD --- etc/bootstrap/bbot-bootstrap-freebsd.sh | 17 +++++++++++++++++ etc/bootstrap/bbot-bootstrap-linux.sh | 14 ++++++++++++++ etc/bootstrap/bbot-bootstrap-macos.sh | 19 ++++++++++++++++--- etc/bootstrap/bbot-bootstrap-mingw.bat | 6 +++++- etc/bootstrap/bbot-bootstrap.service | 2 +- etc/bootstrap/bbot-bootstrap.sh | 6 +++--- etc/bootstrap/bbot-rc-d | 9 +++++++-- 7 files changed, 63 insertions(+), 10 deletions(-) create mode 100755 etc/bootstrap/bbot-bootstrap-freebsd.sh create mode 100755 etc/bootstrap/bbot-bootstrap-linux.sh (limited to 'etc') diff --git a/etc/bootstrap/bbot-bootstrap-freebsd.sh b/etc/bootstrap/bbot-bootstrap-freebsd.sh new file mode 100755 index 0000000..8a86696 --- /dev/null +++ b/etc/bootstrap/bbot-bootstrap-freebsd.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# file : etc/bootstrap/bbot-bootstrap-freebsd.sh +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : TBC; see accompanying LICENSE file + +# Note: install GNU make with 'pkg install gmake'. +# + +if ! jobs="$(sysctl -n hw.ncpu)"; then + jobs=1 +fi + +"$(dirname "$0")/bbot-bootstrap.sh" \ + --make gmake \ + --make "-j$jobs" \ + "$@" diff --git a/etc/bootstrap/bbot-bootstrap-linux.sh b/etc/bootstrap/bbot-bootstrap-linux.sh new file mode 100755 index 0000000..0aa408d --- /dev/null +++ b/etc/bootstrap/bbot-bootstrap-linux.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# file : etc/bootstrap/bbot-bootstrap-linux.sh +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : TBC; see accompanying LICENSE file + +if ! jobs="$(nproc)"; then + jobs=1 +fi + +"$(dirname "$0")/bbot-bootstrap.sh" \ + --make make \ + --make "-j$jobs" \ + "$@" diff --git a/etc/bootstrap/bbot-bootstrap-macos.sh b/etc/bootstrap/bbot-bootstrap-macos.sh index 039e802..e7f7be8 100755 --- a/etc/bootstrap/bbot-bootstrap-macos.sh +++ b/etc/bootstrap/bbot-bootstrap-macos.sh @@ -1,6 +1,19 @@ -#!/bin/bash +#!/bin/sh + +# file : etc/bootstrap/bbot-bootstrap-macos.sh +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : TBC; see accompanying LICENSE file # open -a Terminal -n -F ~/bbot-bootstrap-macos.sh -~/bbot-bootstrap.sh --cxx clang++ --build /tmp \ - --environments "$HOME/environments" +if ! jobs="$(sysctl -n hw.ncpu)"; then + jobs=1 +fi + +"$(dirname "$0")/bbot-bootstrap.sh" \ + --cxx clang++ \ + --build /tmp \ + --environments "$HOME/environments" \ + --make make \ + --make "-j$jobs" \ + "$@" diff --git a/etc/bootstrap/bbot-bootstrap-mingw.bat b/etc/bootstrap/bbot-bootstrap-mingw.bat index 9db41c8..a3ffa04 100644 --- a/etc/bootstrap/bbot-bootstrap-mingw.bat +++ b/etc/bootstrap/bbot-bootstrap-mingw.bat @@ -131,9 +131,13 @@ del trust @for /D %%d in (build2-toolchain-*) do set "bstrap=%%d" cd %bstrap% +@rem Bootstrap in parallel using GNU make (which is part of our mingw +@rem toolchain). +@rem @rem Note: executing in a separate cmd.exe to preserve the echo mode. @rem -cmd /C build-mingw.bat --timeout %TIMEOUT% g++ %INSTALL% %trust% +cmd /C build-mingw.bat --make mingw32-make --make -j%NUMBER_OF_PROCESSORS%^ + --timeout %TIMEOUT% g++ %INSTALL% %trust% @if errorlevel 1 goto error cd .. diff --git a/etc/bootstrap/bbot-bootstrap.service b/etc/bootstrap/bbot-bootstrap.service index 8879c72..3e4cba0 100644 --- a/etc/bootstrap/bbot-bootstrap.service +++ b/etc/bootstrap/bbot-bootstrap.service @@ -17,7 +17,7 @@ Environment=CXX=g++ Environment=BUILD=/tmp Environment=ENVIRONMENTS=/home/build/environments -ExecStart=/usr/local/bin/bbot-bootstrap.sh \ +ExecStart=/usr/local/bin/bbot-bootstrap-linux.sh \ --cxx ${CXX} \ --build ${BUILD} \ --environments ${ENVIRONMENTS} diff --git a/etc/bootstrap/bbot-bootstrap.sh b/etc/bootstrap/bbot-bootstrap.sh index e5ffe80..5908fe1 100755 --- a/etc/bootstrap/bbot-bootstrap.sh +++ b/etc/bootstrap/bbot-bootstrap.sh @@ -4,7 +4,7 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : TBC; see accompanying LICENSE file -usage="Usage: $0 []" +usage="Usage: $0 [] []" set -e # Exit on errors. @@ -66,7 +66,7 @@ while test $# -ne 0; do shift ;; *) - error "unexpected argument '$1'" + break ;; esac done @@ -121,7 +121,7 @@ run rm trust # bstrap="$(echo build2-toolchain-*)" run cd "$bstrap" -run ./build.sh --timeout "$timeout" --trust "$trust" $build_options "$cxx" +run ./build.sh --timeout "$timeout" --trust "$trust" $build_options "$@" "$cxx" run cd .. run rm -r "$bstrap" diff --git a/etc/bootstrap/bbot-rc-d b/etc/bootstrap/bbot-rc-d index 12fadcd..bbde152 100644 --- a/etc/bootstrap/bbot-rc-d +++ b/etc/bootstrap/bbot-rc-d @@ -5,10 +5,15 @@ . /etc/rc.subr name=bbot -command=/home/build/bbot-bootstrap.sh +command=/home/build/bbot-bootstrap-freebsd.sh command_interpreter=/bin/sh + bbot_user=build -start_cmd="/usr/sbin/daemon -u $bbot_user -t $name $command --environments /home/build/environments 2>&1 | /usr/bin/logger -p local1.info" +bbot_cxx=clang++ +bbot_build=/tmp +bbot_environments="/home/$bbot_user/environments" + +start_cmd="/usr/sbin/daemon -u $bbot_user -t $name $command --cxx $bbot_cxx --build $bbot_build --environments $bbot_environments 2>&1 | /usr/bin/logger -p local1.info" load_rc_config $name run_rc_command "$1" -- cgit v1.1