summaryrefslogtreecommitdiff
path: root/src/third_party/scripts/boost_get_sources.sh
blob: f8715b408fbd6097fd3c94533c02f503276fb5c6 (plain)
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
#!/bin/bash
# This script downloads and imports boost via the boost bcp utility.
# It can be run on Linux or Mac OS X.
# Actual integration into the build system is not done by this script.
#
# Turn on strict error checking, like perl use 'strict'
set -euo pipefail
IFS=$'\n\t'

if [ "$#" -ne 0 ]; then
    echo "This script does not take any arguments"
    exit 1
fi

NAME=boost
VERSION=1.70.0
VERSION_UNDERSCORE=$(echo $VERSION | tr . _)
SRC_ROOT=$(mktemp -d /tmp/boost.XXXXXX)
trap "rm -rf $SRC_ROOT" EXIT
TARBALL=${NAME}_${VERSION_UNDERSCORE}.tar.gz
SRC=${SRC_ROOT}/${NAME}_${VERSION_UNDERSCORE}
DEST_DIR=$(git rev-parse --show-toplevel)/src/third_party/$NAME-$VERSION

cd $SRC_ROOT

if [ ! -f $TARBALL ]; then
    wget http://downloads.sourceforge.net/project/boost/boost/$VERSION/$TARBALL
fi

if [ ! -d $SRC ]; then
    tar -zxf $TARBALL
fi

# Build the bcp tool
# The bcp tool is a boost specific tool that allows importing a subset of boost
# The downside is that it copies a lot of unnecessary stuff in libs
# and does not understand #ifdefs
#
cd $SRC

./bootstrap.sh

./b2 tools/bcp

test -d $DEST_DIR || mkdir $DEST_DIR
$SRC/dist/bin/bcp --boost=$SRC/ algorithm align array asio bind iostreams config container date_time filesystem function integer intrusive multi_index noncopyable optional program_options random smart_ptr static_assert unordered utility $DEST_DIR

# Trim files
cd $DEST_DIR

rm -f Jamroot boost.png
rm -rf doc

# Trim misc directories from libs that bcp pulled in
find libs -type d -name test -print0 | xargs -0 rm -rf
find libs -type d -name doc -print0 | xargs -0 rm -rf
find libs -type d -name build -print0 | xargs -0 rm -rf
find libs -type d -name examples -print0 | xargs -0 rm -rf
find libs -type d -name example -print0 | xargs -0 rm -rf
find libs -type d -name meta -print0 | xargs -0 rm -rf
find libs -type d -name tutorial -print0 | xargs -0 rm -rf
find libs -type d -name performance -print0 | xargs -0 rm -rf
find libs -type d -name bench -print0 | xargs -0 rm -rf
find libs -type d -name perf -print0 | xargs -0 rm -rf
find libs -type d -name proj -print0 | xargs -0 rm -rf
find libs -type d -name xmldoc -print0 | xargs -0 rm -rf
find libs -type d -name tools -print0 | xargs -0 rm -rf
find libs -type d -name extra -print0 | xargs -0 rm -rf
find libs -type d -name bug -print0 | xargs -0 rm -rf

find libs -name "*.html" -print0 | xargs -0 rm -f
find libs -name "*.htm" -print0 | xargs -0 rm -f
find libs -name "*.zip" -print0 | xargs -0 rm -f
find libs -name "*.gif" -print0 | xargs -0 rm -f

# Full of unneeded code
rm -rf libs/algorithm
rm -rf libs/config
rm -rf libs/static_assert

# Trim the include directory for the stuff bcp dragged in and we do not need
# since they are 1+ MB each
rm -f boost/typeof/vector100.hpp
rm -f boost/typeof/vector150.hpp
rm -f boost/typeof/vector200.hpp

# Remove compat files for compilers we do not support
find boost -type d -name dmc -print0 | xargs -0 rm -rf
find boost -type d -name "bcc*" -print0 | xargs -0 rm -rf
find boost -type d -name mwcw -print0 | xargs -0 rm -rf
find boost -type d -name msvc60 -print0 | xargs -0 rm -rf
find boost -type d -name msvc70 -print0 | xargs -0 rm -rf

find . -type d -empty -print0 | xargs -0 rmdir