From 847c49dd01f984ac10e195569b49c7f1bdf33335 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 11 Dec 2019 08:33:58 +0300 Subject: refactor build/boost/build_travis.sh --- build/boost/build_travis.sh | 61 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/build/boost/build_travis.sh b/build/boost/build_travis.sh index 1491bc8..267262d 100755 --- a/build/boost/build_travis.sh +++ b/build/boost/build_travis.sh @@ -15,35 +15,66 @@ set -o errexit -o nounset -o pipefail -o xtrace readonly base_dir="$HOME" -readonly boost_fs="boost_${travis_boost_version//\./_}" -readonly boost_url="https://dl.bintray.com/boostorg/release/$travis_boost_version/source/$boost_fs.tar.gz" -readonly boost_dir="$base_dir/$boost_fs" +readonly script_name="$( basename -- "${BASH_SOURCE[0]}" )" -address_model=32 -[ "$platform" = x64 ] && address_model=64 -readonly address_model +dump() { + local msg + for msg; do + echo "$script_name: $msg" + done +} + +set_paths() { + local boost_fs="boost_${travis_boost_version//\./_}" + + readonly boost_archive="$boost_fs.tar.gz" + readonly boost_url="https://dl.bintray.com/boostorg/release/$travis_boost_version/source/$boost_archive" + readonly boost_dir="$base_dir/$boost_fs" +} + +set_address_model() { + if [ "$platform" = x64 ]; then + readonly address_model=64 + elif [ "$platform" = x86 ]; then + readonly address_model=32 + else + dump "unsupported platform: $platform" >&2 + exit 1 + fi +} -configuration="${configuration,,}" -readonly configuration +set_configuration() { + configuration="${configuration,,}" + readonly configuration +} + +set_parameters() { + set_paths + set_address_model + set_configuration +} download() { - cd -- "$base_dir" - wget --quiet -- "$boost_url" - tar xzvf "$boost_fs.tar.gz" > /dev/null + wget --quiet -O "$boost_archive" -- "$boost_url" + tar xzvf "$boost_archive" > /dev/null } build() { cd -- "$boost_dir" + ./bootstrap.sh - ./b2 \ - "address-model=$address_model" \ - variant="$configuration" \ - "--stagedir=stage/$platform/$configuration" \ + ./b2 \ + "address-model=$address_model" \ + variant="$configuration" \ + "--stagedir=$boost_dir/stage/$platform/$configuration" \ "$@" } main() { + pushd -- "$base_dir" + trap 'popd' EXIT + set_parameters download build "$@" } -- cgit v1.2.3