-
Notifications
You must be signed in to change notification settings - Fork 19
/
install.sh
executable file
·127 lines (117 loc) · 4.54 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#! /bin/bash
#
# Copyright 2017 - 2019 James E. King III
# Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Executes the install phase for Azure Pipelines (AzP)
#
# This was ported from ci/travis/install.sh following
# this official guide:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/migrate/from-travis
#
# If your repository has additional directories beyond
# "example", "examples", "tools", and "test" then you
# can add them in the environment variable DEPINST.
# i.e. - DEPINST="--include dirname1 --include dirname2"
#
# AzP requires to run special task in order to export
# SELF and BOOST_ROOT as job-scoped variable from a script.
# Follow invocation of this install.sh in .azure-pipelines.yaml
# with these two lines:
#
# set +x
# echo "##vso[task.setvariable variable=SELF]$SELF"
# echo "##vso[task.setvariable variable=BOOST_ROOT]$BOOST_ROOT"
# set -x
#
# NOTE: The set +x is required! See the troubleshooting guide:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/troubleshooting#variables-having--single-quote-appended
#
set -ex
if [ "$AGENT_OS" == "Darwin" ]; then
unset -f cd
fi
. $(dirname "${BASH_SOURCE[0]}")/enforce.sh
function show_bootstrap_log
{
cat bootstrap.log
}
# AzP does not clone into folder named after repository,
# but into one named something like /home/vsts/work/1/s
# SELF needs to be derived from the name of the repository
# that this build is configured for.
export SELF=`basename $BUILD_REPOSITORY_NAME`
# e.g. BUILD_SOURCESDIRECTORY=/home/vsts/work/1/s
# change from /home/vsts/work/1/s to /home/vsts/work/1
cd ..
if [ "$SELF" == "interval" ]; then
export SELF=numeric/interval
fi
# CI builds set BUILD_SOURCEBRANCHNAME
# Pull request builds set SYSTEM_PULLREQUEST_TARGETBRANCH.
# We want to build PRs against develop branch anyway.
if [ "$BUILD_SOURCEBRANCHNAME" == "master" ]; then
export BOOST_BRANCH="master"
else
export BOOST_BRANCH="develop"
fi
# e.g. clone into /home/vsts/work/1/boost-root
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update -q --init libs/headers
git submodule update -q --init tools/boost_install
git submodule update -q --init tools/boostdep
git submodule update -q --init tools/build
mkdir -p libs/$SELF
cp -r $BUILD_SOURCESDIRECTORY/* libs/$SELF
# e.g. move /home/vsts/work/1/boost-root
# back inside BUILD_SOURCESDIRECTORY=/home/vsts/work/1/s
cd ..
mv boost-root $BUILD_SOURCESDIRECTORY/
cd $BUILD_SOURCESDIRECTORY/boost-root
# NOTE: AzP images come with predefined BOOST_ROOT that can not be overwritten
# https://gitlab.kitware.com/cmake/cmake/issues/19056
# Set custom variable here, then export as
export BOOST_ROOT="`pwd`"
export PATH="`pwd`":$PATH
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools $DEPINST $SELF
# If clang was installed from LLVM APT it will not have a /usr/bin/clang++
# so we need to add the correctly versioned llvm bin path to the PATH
if [ "${B2_TOOLSET%%-*}" == "clang" ]; then
ver="${B2_TOOLSET#*-}"
export PATH=/usr/lib/llvm-${ver}/bin:$PATH
ls -ls /usr/lib/llvm-${ver}/bin || true
hash -r || true
command -v clang || true
command -v clang++ || true
# Additionally, if B2_TOOLSET is clang variant but CXX is set to g++
# (it is on Linux images) then boost build silently ignores B2_TOOLSET and
# uses CXX instead
if [[ "${CXX}" != "clang"* ]]; then
echo "CXX is set to ${CXX} in this environment which would override"
echo "the setting of B2_TOOLSET=clang, therefore we clear CXX here."
export CXX=
fi
fi
trap show_bootstrap_log ERR
./bootstrap.sh --with-toolset=${B2_TOOLSET%%-*}
trap - ERR
./b2 headers
# AzP official images of Ubuntu 16.04 behave differently to Travis CI.
# The gcc and clang variants are being installed somewhat weirdly
# and, unlike on linux images on Travis CI, b2 fails with:
#
# /home/vsts/work/1/s/boost-root/tools/build/src/tools/gcc.jam:230: in gcc.init from module gcc
# error: toolset gcc initialization:
# error: no command provided, default command 'g++' not found
# error: initialized from ../../project-config.jam:12
#
# Hence, we work around this issue with user-config.jam
if ! command -v ${CXX}; then
echo "WARNING: Compiler ${CXX} was not installed properly"
#exit 1
fi
echo "using ${B2_TOOLSET} : : $(command -v ${CXX}) : ${B2_CXXFLAGS} ;" > ${HOME}/user-config.jam