Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better build prep scripts #1248

Merged
merged 8 commits into from Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 8 additions & 15 deletions .gitlab-ci.yml
Expand Up @@ -51,8 +51,7 @@ Arch Linux:
FLAVOR: trusty

before_script:
- ./ci/ubuntu_prep.sh
- ./ci/bootstrap_boost.sh
- ./util/build_prep/ubuntu/prep.sh


Ubuntu Linux Artful:
Expand All @@ -63,8 +62,7 @@ Ubuntu Linux Artful:
FLAVOR: artful

before_script:
- ./ci/ubuntu_prep.sh
- ./ci/bootstrap_boost.sh
- ./util/build_prep/ubuntu/prep.sh

Ubuntu Linux Xenial:
<<: *linux_cfg
Expand All @@ -74,8 +72,7 @@ Ubuntu Linux Xenial:
FLAVOR: xenial

before_script:
- ./ci/ubuntu_prep.sh
- ./ci/bootstrap_boost.sh
- ./util/build_prep/ubuntu/prep.sh

Ubuntu Linux Xenial Beta:
<<: *linux_cfg
Expand All @@ -86,8 +83,7 @@ Ubuntu Linux Xenial Beta:
BETA: 1

before_script:
- ./ci/ubuntu_prep.sh
- ./ci/bootstrap_boost.sh
- ./util/build_prep/ubuntu/prep.sh

Xenial OPTIMIZED:
<<: *linux_cfg
Expand All @@ -98,8 +94,7 @@ Xenial OPTIMIZED:
SIMD: 1

before_script:
- ./ci/ubuntu_prep.sh
- ./ci/bootstrap_boost.sh
- ./util/build_prep/ubuntu/prep.sh

Artful OPTIMIZED:
<<: *linux_cfg
Expand All @@ -110,8 +105,7 @@ Artful OPTIMIZED:
SIMD: 1

before_script:
- ./ci/ubuntu_prep.sh
- ./ci/bootstrap_boost.sh
- ./util/build_prep/ubuntu/prep.sh


# DISABLED for now
Expand All @@ -123,8 +117,7 @@ Artful OPTIMIZED:
FLAVOR: zesty_asan

before_script:
- ./ci/ubuntu_prep.sh
- ./ci/bootstrap_boost.sh
- ./util/build_prep/ubuntu/prep.sh



Expand All @@ -137,7 +130,7 @@ Artful OPTIMIZED:
FLAVOR: zesty_tsan

before_script:
- ./ci/ubuntu_prep.sh
- ./util/build_prep/ubuntu/prep.sh



Expand Down
36 changes: 0 additions & 36 deletions ci/bootstrap_boost.sh

This file was deleted.

14 changes: 0 additions & 14 deletions ci/ubuntu_prep.sh

This file was deleted.

3 changes: 2 additions & 1 deletion docker/node/Dockerfile
Expand Up @@ -5,13 +5,14 @@ ARG NETWORK=live
ENV BOOST_ROOT=/tmp/boost_install

ADD ci /tmp/ci
ADD util /tmp/util

RUN apt-get update -qq && apt-get install -yqq \
build-essential \
cmake \
g++ \
wget && \
/tmp/ci/bootstrap_boost.sh -m
/tmp/util/build_prep/bootstrap_boost.sh -m

ADD ./ /tmp/src

Expand Down
57 changes: 57 additions & 0 deletions util/build_prep/bootstrap_boost.sh
@@ -0,0 +1,57 @@
#!/usr/bin/env bash

set -o errexit
set -o xtrace

bootstrapArgs=()
useClang='false'
while getopts 'mc' OPT; do
case "${OPT}" in
m)
bootstrapArgs+=('--with-libraries=thread,log,filesystem,program_options')
;;
c)
useClang='true'
;;
esac
done

if ! c++ --version >/dev/null 2>/dev/null; then
useClang='true'

if ! clang++ --version >/dev/null 2>/dev/null; then
echo "Unable to find a usable toolset" >&2

exit 1
fi
fi

if [ "${useClang}" = 'true' ]; then
bootstrapArgs+=(--with-toolset=clang)
fi

BOOST_BASENAME=boost_1_66_0
BOOST_ROOT=${BOOST_ROOT-/usr/local/boost}
BOOST_URL=https://downloads.sourceforge.net/project/boost/boost/1.66.0/${BOOST_BASENAME}.tar.bz2
BOOST_ARCHIVE="${BOOST_BASENAME}.tar.bz2"
BOOST_ARCHIVE_SHA256='5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9'

if [ ! -f "${BOOST_ARCHIVE}" ]; then
wget --quiet -O "${BOOST_ARCHIVE}.new" "${BOOST_URL}"
checkHash="$(openssl dgst -sha256 "${BOOST_ARCHIVE}.new" | sed 's@^.*= *@@')"
if [ "${checkHash}" != "${BOOST_ARCHIVE_SHA256}" ]; then
echo "Checksum mismatch. Expected ${BOOST_ARCHIVE_SHA256}, got ${checkHash}" >&2

exit 1
fi
mv "${BOOST_ARCHIVE}.new" "${BOOST_ARCHIVE}" || exit 1
fi

rm -rf ${BOOST_BASENAME}
tar xf "${BOOST_ARCHIVE}"
cd ${BOOST_BASENAME}
./bootstrap.sh "${bootstrapArgs[@]}"
./b2 -d0 --prefix=${BOOST_ROOT} link=static install
cd ..
rm -rf ${BOOST_BASENAME}
rm -f "${BOOST_ARCHIVE}"
77 changes: 77 additions & 0 deletions util/build_prep/common.sh
@@ -0,0 +1,77 @@
scriptDirectory="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit 1

function boost_version () {
local boost_version
boost_version="$(
set -o pipefail
echo $'#include <boost/version.hpp>\nBOOST_LIB_VERSION' | cc -I/usr/local/boost/include -E - 2>/dev/null | tail -n 1 | sed 's@"@@g;s@_@.@g'
)" || boost_version=''

echo "${boost_version}"
}

function check_create_boost () {
local boost_version
boost_version="$(boost_version)"

if [ -n "${boost_version}" ]; then
function boost () {
local arg
local version

arg="$1"

version="$(boost_version)"
if [ -z "${version}" ]; then
return 1
fi

case "${arg}" in
'')
return 0
;;
'--version')
echo "${version}"
return 0
;;
'--install-prefix')
echo '#include <boost/version.hpp>' | cc -v -E - 2>/dev/null | grep '/version.hpp' | sed 's@^[^"]*"@@;s@/version\.hpp".*$@@'
return 0
;;
esac

return 1
}
fi
}

function have () {
local program

program="$1"

check_create_boost

type -t "${program}" >/dev/null 2>/dev/null
}

function version_min () {
local version_command below_min_version
local check_version

version_command="$1"
below_min_version="$2"

check_version="$(
(
eval "${version_command}" | awk '{ print $NF }' | grep '^[0-9]'
echo "${below_min_version}"
) | sort -rV | head -n 1
)"

if [ "${check_version}" = "${below_min_version}" ]; then
return 1
fi

return 0
}