|
a |
|
b/tools/build_absl.sh |
|
|
1 |
#!/bin/bash |
|
|
2 |
# Copyright 2020 Google LLC. |
|
|
3 |
# |
|
|
4 |
# Redistribution and use in source and binary forms, with or without |
|
|
5 |
# modification, are permitted provided that the following conditions |
|
|
6 |
# are met: |
|
|
7 |
# |
|
|
8 |
# 1. Redistributions of source code must retain the above copyright notice, |
|
|
9 |
# this list of conditions and the following disclaimer. |
|
|
10 |
# |
|
|
11 |
# 2. Redistributions in binary form must reproduce the above copyright |
|
|
12 |
# notice, this list of conditions and the following disclaimer in the |
|
|
13 |
# documentation and/or other materials provided with the distribution. |
|
|
14 |
# |
|
|
15 |
# 3. Neither the name of the copyright holder nor the names of its |
|
|
16 |
# contributors may be used to endorse or promote products derived from this |
|
|
17 |
# software without specific prior written permission. |
|
|
18 |
# |
|
|
19 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
|
20 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
|
21 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
|
22 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
|
23 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
|
24 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
|
25 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
|
26 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
|
27 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
|
28 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
|
29 |
# POSSIBILITY OF SUCH DAMAGE. |
|
|
30 |
# |
|
|
31 |
# |
|
|
32 |
|
|
|
33 |
set -eux -o pipefail |
|
|
34 |
|
|
|
35 |
echo ========== This script has been tested on Ubuntu22.04. |
|
|
36 |
echo ========== Run this script in root mode. |
|
|
37 |
|
|
|
38 |
ABSL_PIN="${ABSL_PIN-29bf8085f3bf17b84d30e34b3d7ff8248fda404e}" |
|
|
39 |
|
|
|
40 |
APT_ARGS=( |
|
|
41 |
"-y" |
|
|
42 |
) |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
apt-get update "${APT_ARGS[@]}" |
|
|
46 |
NEEDRESTART_MODE=a apt-get install "${APT_ARGS[@]}" --no-install-recommends \ |
|
|
47 |
autoconf \ |
|
|
48 |
automake \ |
|
|
49 |
cmake \ |
|
|
50 |
curl \ |
|
|
51 |
gpg-agent \ |
|
|
52 |
g++ \ |
|
|
53 |
libtool \ |
|
|
54 |
make \ |
|
|
55 |
pkg-config \ |
|
|
56 |
software-properties-common \ |
|
|
57 |
wget \ |
|
|
58 |
unzip |
|
|
59 |
|
|
|
60 |
# Install dependencies |
|
|
61 |
apt-get update "${APT_ARGS[@]}" |
|
|
62 |
NEEDRESTART_MODE=a apt-get install "${APT_ARGS[@]}" \ |
|
|
63 |
clang-11 \ |
|
|
64 |
libclang-11-dev \ |
|
|
65 |
libgoogle-glog-dev \ |
|
|
66 |
libgtest-dev \ |
|
|
67 |
libllvm11 \ |
|
|
68 |
llvm-11 \ |
|
|
69 |
llvm-11-dev \ |
|
|
70 |
llvm-11-linker-tools \ |
|
|
71 |
python3-dev \ |
|
|
72 |
zlib1g-dev |
|
|
73 |
|
|
|
74 |
# Compile and install absl-cpp from source |
|
|
75 |
git clone https://github.com/abseil/abseil-cpp.git |
|
|
76 |
cd abseil-cpp |
|
|
77 |
if [[ ! -z ${ABSL_PIN} ]]; then |
|
|
78 |
git checkout "${ABSL_PIN}" |
|
|
79 |
fi |
|
|
80 |
mkdir build && cd build |
|
|
81 |
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=true |
|
|
82 |
make install |
|
|
83 |
cd ../.. |
|
|
84 |
rm -rf abseil-cpp |
|
|
85 |
|
|
|
86 |
curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py |
|
|
87 |
python3 get-pip.py --force-reinstall --user |
|
|
88 |
rm -f get-pip.py |
|
|
89 |
|
|
|
90 |
export PATH="$HOME/.local/bin":$PATH |
|
|
91 |
echo "$(pip3 --version)" |
|
|
92 |
|
|
|
93 |
# Install python runtime and test dependencies |
|
|
94 |
pip3 install \ |
|
|
95 |
absl-py \ |
|
|
96 |
parameterized |
|
|
97 |
|
|
|
98 |
# On GPU machines, this might be necessary because of the reason mentioned in: |
|
|
99 |
# https://stackoverflow.com/a/74605488 |
|
|
100 |
NEEDRESTART_MODE=a apt-get install "${APT_ARGS[@]}" libstdc++-12-dev |