Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Builds and installs all tools needed for developing and testing P4 support in |
| 4 | # ONOS. |
| 5 | # |
| 6 | # Tested on Ubuntu 14.04 and 16.04. |
| 7 | # |
| 8 | # Recommended minimum system requirements: |
| 9 | # 4 GB of RAM |
| 10 | # 2 cores |
| 11 | # 8 GB free hard drive space (~4 GB to build everything) |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 12 | # |
| 13 | # To execute up to a given step, pass the step name as the first argument. For |
| 14 | # example, to install PI, but not BMv2, p4c, etc: |
| 15 | # ./install-p4-tools.sh PI |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 16 | # ----------------------------------------------------------------------------- |
| 17 | |
| 18 | # Exit on errors. |
| 19 | set -e |
| 20 | |
| 21 | BUILD_DIR=~/p4tools |
Esin Karaman | 971fb7f | 2017-12-28 13:44:52 +0000 | [diff] [blame] | 22 | # in case BMV2_COMMIT value is updated, the same variable in |
| 23 | # protocols/bmv2/thrift-api/BUCK file should also be updated |
Carmelo Cascone | a52c880 | 2018-12-18 13:30:45 -0800 | [diff] [blame] | 24 | BMV2_COMMIT="7fd3b39519ca892c2e160b8be358d3f487b1b00e" |
| 25 | PI_COMMIT="a95222eca9b039f6398c048d7e1a1bf7f49b7235" |
| 26 | P4C_COMMIT="264da2c524c849df0d9ba478cdd1d61b29d64722" |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 27 | PROTOBUF_COMMIT="tags/v3.2.0" |
| 28 | GRPC_COMMIT="tags/v1.3.2" |
| 29 | LIBYANG_COMMIT="v0.14-r1" |
| 30 | SYSREPO_COMMIT="v0.7.2" |
| 31 | |
| 32 | NUM_CORES=`grep -c ^processor /proc/cpuinfo` |
| 33 | |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 34 | # If false, build tools without debug features to improve throughput of BMv2 and |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 35 | # reduce CPU/memory footprint. Default is true. |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 36 | DEBUG_FLAGS=${DEBUG_FLAGS:-true} |
| 37 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 38 | # Execute up to the given step (first argument), or all if not defined. |
| 39 | LAST_STEP=${1:-all} |
| 40 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 41 | function do_requirements { |
| 42 | sudo apt update |
| 43 | sudo apt-get install -y --no-install-recommends \ |
| 44 | autoconf \ |
| 45 | automake \ |
| 46 | bison \ |
| 47 | build-essential \ |
| 48 | cmake \ |
| 49 | cpp \ |
| 50 | curl \ |
| 51 | flex \ |
| 52 | git \ |
Carmelo Cascone | b0c6665 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 53 | graphviz \ |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 54 | libavl-dev \ |
| 55 | libboost-dev \ |
Carmelo Cascone | b0c6665 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 56 | libboost-graph-dev \ |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 57 | libboost-program-options-dev \ |
| 58 | libboost-system-dev \ |
| 59 | libboost-filesystem-dev \ |
| 60 | libboost-thread-dev \ |
| 61 | libboost-filesystem-dev \ |
| 62 | libboost-program-options-dev \ |
| 63 | libboost-system-dev \ |
| 64 | libboost-test-dev \ |
| 65 | libboost-thread-dev \ |
| 66 | libc6-dev \ |
| 67 | libev-dev \ |
| 68 | libevent-dev \ |
| 69 | libffi-dev \ |
| 70 | libfl-dev \ |
| 71 | libgc-dev \ |
| 72 | libgc1c2 \ |
| 73 | libgflags-dev \ |
| 74 | libgmp-dev \ |
| 75 | libgmp10 \ |
| 76 | libgmpxx4ldbl \ |
| 77 | libjudy-dev \ |
| 78 | libpcap-dev \ |
| 79 | libpcre3-dev \ |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 80 | libreadline6 \ |
| 81 | libreadline6-dev \ |
| 82 | libssl-dev \ |
| 83 | libtool \ |
| 84 | make \ |
| 85 | mktemp \ |
| 86 | pkg-config \ |
| 87 | protobuf-c-compiler \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 88 | python2.7 \ |
| 89 | python2.7-dev \ |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 90 | tcpdump \ |
| 91 | wget \ |
| 92 | unzip |
| 93 | |
Charles Chan | 87dc82e | 2018-08-05 16:27:10 -0700 | [diff] [blame] | 94 | sudo -H pip install setuptools cffi ipaddr ipaddress pypcap |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | function do_requirements_1404 { |
| 98 | sudo apt install -y python-software-properties software-properties-common |
| 99 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test |
| 100 | sudo add-apt-repository -y ppa:george-edison55/cmake-3.x |
| 101 | sudo apt update |
| 102 | sudo apt install -y \ |
| 103 | dpkg-dev \ |
| 104 | g++-4.9 \ |
| 105 | gcc-4.9 \ |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 106 | cmake \ |
| 107 | libbz2-dev |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 108 | |
| 109 | # Needed for p4c. |
| 110 | sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50 |
| 111 | sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50 |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 112 | |
| 113 | if [ -z "$(ldconfig -p | grep libboost_iostreams.so.1.58.0)" ]; then |
| 114 | do_boost |
| 115 | fi |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | function do_requirements_1604 { |
| 119 | sudo apt-get update |
| 120 | sudo apt-get install -y --no-install-recommends \ |
| 121 | ca-certificates \ |
| 122 | g++ \ |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 123 | libboost-iostreams1.58-dev \ |
| 124 | libprotobuf-c-dev |
| 125 | } |
| 126 | |
| 127 | function do_boost { |
| 128 | cd ${BUILD_DIR} |
| 129 | wget https://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2/download -O boost_1_58_0.tar.bz2 |
| 130 | tar --bzip2 -xf boost_1_58_0.tar.bz2 |
| 131 | cd boost_1_58_0 |
| 132 | |
| 133 | ./bootstrap.sh --with-libraries=iostreams |
| 134 | sudo ./b2 install |
| 135 | sudo ldconfig |
| 136 | |
| 137 | cd .. |
| 138 | sudo rm -rf boost_1_58_0 |
| 139 | } |
| 140 | |
| 141 | function do_protobuf-c { |
| 142 | cd ${BUILD_DIR} |
| 143 | git clone https://github.com/protobuf-c/protobuf-c.git |
| 144 | cd protobuf-c |
| 145 | |
| 146 | ./autogen.sh |
| 147 | ./configure --prefix=/usr |
| 148 | make -j${NUM_CORES} |
| 149 | sudo make install |
| 150 | sudo ldconfig |
| 151 | |
| 152 | cd .. |
| 153 | sudo rm -rf protobuf-c |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | function do_protobuf { |
Carmelo Cascone | a52c880 | 2018-12-18 13:30:45 -0800 | [diff] [blame] | 157 | if check_lib libprotobuf; then |
| 158 | return |
| 159 | fi |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 160 | cd ${BUILD_DIR} |
| 161 | if [ ! -d protobuf ]; then |
| 162 | git clone https://github.com/google/protobuf.git |
| 163 | fi |
| 164 | cd protobuf |
| 165 | git fetch |
| 166 | git checkout ${PROTOBUF_COMMIT} |
| 167 | |
| 168 | export CFLAGS="-Os" |
| 169 | export CXXFLAGS="-Os" |
| 170 | export LDFLAGS="-Wl,-s" |
| 171 | ./autogen.sh |
| 172 | ./configure --prefix=/usr |
| 173 | make -j${NUM_CORES} |
| 174 | sudo make install |
| 175 | sudo ldconfig |
| 176 | unset CFLAGS CXXFLAGS LDFLAGS |
Carmelo Cascone | f645e84 | 2018-07-16 18:31:52 +0200 | [diff] [blame] | 177 | |
| 178 | cd python |
| 179 | sudo python setup.py install --cpp_implementation |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | function do_grpc { |
Carmelo Cascone | a52c880 | 2018-12-18 13:30:45 -0800 | [diff] [blame] | 183 | if check_lib libgrpc; then |
| 184 | return |
| 185 | fi |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 186 | cd ${BUILD_DIR} |
| 187 | if [ ! -d grpc ]; then |
| 188 | git clone https://github.com/grpc/grpc.git |
| 189 | fi |
| 190 | cd grpc |
| 191 | git fetch |
| 192 | git checkout ${GRPC_COMMIT} |
| 193 | git submodule update --init |
| 194 | |
| 195 | export LDFLAGS="-Wl,-s" |
| 196 | make -j${NUM_CORES} |
| 197 | sudo make install |
| 198 | sudo ldconfig |
| 199 | unset LDFLAGS |
Carmelo Cascone | f645e84 | 2018-07-16 18:31:52 +0200 | [diff] [blame] | 200 | |
| 201 | sudo pip install -r requirements.txt |
| 202 | sudo pip install . |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | function do_libyang { |
| 206 | cd ${BUILD_DIR} |
| 207 | if [ ! -d libyang ]; then |
| 208 | git clone https://github.com/CESNET/libyang.git |
| 209 | fi |
| 210 | cd libyang |
| 211 | git fetch |
| 212 | git checkout ${LIBYANG_COMMIT} |
| 213 | |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 214 | mkdir -p build |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 215 | cd build |
| 216 | cmake .. |
| 217 | make -j${NUM_CORES} |
| 218 | sudo make install |
| 219 | sudo ldconfig |
| 220 | } |
| 221 | |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 222 | function do_sysrepo_deps { |
| 223 | RELEASE=`lsb_release -rs` |
| 224 | if version_ge $RELEASE 14.04 && [ -z "$(ldconfig -p | grep libprotobuf-c)" ]; then |
| 225 | do_protobuf-c |
| 226 | fi |
| 227 | } |
| 228 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 229 | function do_sysrepo { |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 230 | do_sysrepo_deps |
| 231 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 232 | cd ${BUILD_DIR} |
| 233 | if [ ! -d sysrepo ]; then |
| 234 | git clone https://github.com/sysrepo/sysrepo.git |
| 235 | fi |
| 236 | cd sysrepo |
| 237 | git fetch |
| 238 | git checkout ${SYSREPO_COMMIT} |
| 239 | |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 240 | mkdir -p build |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 241 | cd build |
| 242 | cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=Off \ |
| 243 | -DCALL_TARGET_BINS_DIRECTLY=Off .. |
| 244 | make -j${NUM_CORES} |
| 245 | sudo make install |
| 246 | sudo ldconfig |
| 247 | } |
| 248 | |
| 249 | function checkout_bmv2 { |
| 250 | cd ${BUILD_DIR} |
| 251 | if [ ! -d bmv2 ]; then |
| 252 | git clone https://github.com/p4lang/behavioral-model.git bmv2 |
| 253 | fi |
| 254 | cd bmv2 |
| 255 | git fetch |
| 256 | git checkout ${BMV2_COMMIT} |
| 257 | } |
| 258 | |
| 259 | function do_pi_bmv2_deps { |
| 260 | checkout_bmv2 |
| 261 | # From bmv2's install_deps.sh. |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 262 | # Nanomsg is required also by PI. |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 263 | tmpdir=`mktemp -d -p .` |
| 264 | cd ${tmpdir} |
| 265 | bash ../travis/install-thrift.sh |
| 266 | bash ../travis/install-nanomsg.sh |
| 267 | sudo ldconfig |
| 268 | bash ../travis/install-nnpy.sh |
| 269 | cd .. |
| 270 | sudo rm -rf $tmpdir |
| 271 | } |
| 272 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 273 | function do_PI { |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 274 | cd ${BUILD_DIR} |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 275 | if [ ! -d PI ]; then |
| 276 | git clone https://github.com/p4lang/PI.git |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 277 | fi |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 278 | cd PI |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 279 | git fetch |
| 280 | git checkout ${PI_COMMIT} |
| 281 | git submodule update --init --recursive |
| 282 | |
| 283 | ./autogen.sh |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 284 | # FIXME: re-enable --with-sysrepo when gNMI support becomes more stable |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 285 | # ./configure --with-proto --with-sysrepo |
| 286 | ./configure --with-proto --without-internal-rpc --without-cli |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 287 | make -j${NUM_CORES} |
| 288 | sudo make install |
| 289 | sudo ldconfig |
| 290 | |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 291 | # FIXME: re-enable when gNMI support becomes more stable |
| 292 | # sudo proto/sysrepo/install_yangs.sh |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | function do_bmv2 { |
| 296 | checkout_bmv2 |
| 297 | |
| 298 | ./autogen.sh |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 299 | if [ "${DEBUG_FLAGS}" = true ] ; then |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 300 | ./configure --with-pi --disable-elogger --without-nanomsg |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 301 | else |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 302 | ./configure --with-pi --disable-elogger --without-nanomsg --disable-logging-macros |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 303 | fi |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 304 | make -j${NUM_CORES} |
| 305 | sudo make install |
| 306 | sudo ldconfig |
| 307 | |
| 308 | # Simple_switch_grpc target |
| 309 | cd targets/simple_switch_grpc |
| 310 | ./autogen.sh |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 311 | ./configure --with-thrift |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 312 | # FIXME: re-enable --with-sysrepo when gNMI support becomes more stable |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 313 | # ./configure --with-sysrepo --with-thrift |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 314 | make -j${NUM_CORES} |
| 315 | sudo make install |
| 316 | sudo ldconfig |
| 317 | } |
| 318 | |
| 319 | function do_p4c { |
| 320 | cd ${BUILD_DIR} |
| 321 | if [ ! -d p4c ]; then |
| 322 | git clone https://github.com/p4lang/p4c.git |
| 323 | fi |
| 324 | cd p4c |
| 325 | git fetch |
| 326 | git checkout ${P4C_COMMIT} |
| 327 | git submodule update --init --recursive |
| 328 | |
| 329 | mkdir -p build |
| 330 | cd build |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 331 | cmake .. -DENABLE_EBPF=OFF |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 332 | make -j${NUM_CORES} |
| 333 | sudo make install |
| 334 | sudo ldconfig |
| 335 | } |
| 336 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 337 | function do_scapy-vxlan { |
Carmelo Cascone | 76b3ee6 | 2018-01-30 15:45:27 -0800 | [diff] [blame] | 338 | cd ${BUILD_DIR} |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 339 | if [ ! -d scapy-vxlan ]; then |
| 340 | git clone https://github.com/p4lang/scapy-vxlan.git |
Carmelo Cascone | 76b3ee6 | 2018-01-30 15:45:27 -0800 | [diff] [blame] | 341 | fi |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 342 | cd scapy-vxlan |
| 343 | |
Carmelo Cascone | 76b3ee6 | 2018-01-30 15:45:27 -0800 | [diff] [blame] | 344 | git pull origin master |
| 345 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 346 | sudo python setup.py install |
| 347 | } |
| 348 | |
| 349 | function do_ptf { |
| 350 | cd ${BUILD_DIR} |
| 351 | if [ ! -d ptf ]; then |
| 352 | git clone https://github.com/p4lang/ptf.git |
| 353 | fi |
| 354 | cd ptf |
| 355 | git pull origin master |
| 356 | |
| 357 | sudo python setup.py install |
Carmelo Cascone | 76b3ee6 | 2018-01-30 15:45:27 -0800 | [diff] [blame] | 358 | } |
| 359 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 360 | function check_commit { |
| 361 | if [ ! -e $2 ]; then |
| 362 | return 0 # true |
| 363 | fi |
| 364 | if [[ $(< $2) != "$1" ]]; then |
| 365 | return 0 # true |
| 366 | fi |
| 367 | return 1 # false |
| 368 | } |
| 369 | |
| 370 | # The following is borrowed from Mininet's util/install.sh |
| 371 | function version_ge { |
| 372 | # sort -V sorts by *version number* |
| 373 | latest=`printf "$1\n$2" | sort -V | tail -1` |
| 374 | # If $1 is latest version, then $1 >= $2 |
| 375 | [ "$1" == "$latest" ] |
| 376 | } |
| 377 | |
Carmelo Cascone | a52c880 | 2018-12-18 13:30:45 -0800 | [diff] [blame] | 378 | function check_lib { |
| 379 | ldconfig -p | grep $1 &> /dev/null |
| 380 | if [ $? == 0 ]; then |
| 381 | echo "$1 found!" |
| 382 | return 0 # true |
| 383 | fi |
| 384 | return 1 # false |
| 385 | } |
| 386 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 387 | MUST_DO_ALL=false |
| 388 | DID_REQUIREMENTS=false |
| 389 | function check_and_do { |
| 390 | # Check if the latest built commit is the same we are trying to build now, |
| 391 | # or if all projects must be built. If true builds this project. |
| 392 | commit_id="$1" |
| 393 | proj_dir="$2" |
| 394 | func_name="$3" |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 395 | step_name="$4" |
| 396 | commit_file=${BUILD_DIR}/${proj_dir}/.last_built_commit_${step_name} |
Carmelo Cascone | 0535467 | 2018-04-10 13:24:03 -0700 | [diff] [blame] | 397 | if [ ${MUST_DO_ALL} = true ] \ |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 398 | || check_commit ${commit_id} ${commit_file}; then |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 399 | echo "#" |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 400 | echo "# Building ${step_name} (${commit_id})" |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 401 | echo "#" |
| 402 | # Print commands used to install to aid debugging |
| 403 | set -x |
| 404 | if ! ${DID_REQUIREMENTS} = true; then |
| 405 | do_requirements |
| 406 | # TODO consider other Linux distros; presently this script assumes |
| 407 | # that it is running on Ubuntu. |
| 408 | RELEASE=`lsb_release -rs` |
| 409 | if version_ge $RELEASE 16.04; then |
| 410 | do_requirements_1604 |
| 411 | elif version_ge $RELEASE 14.04; then |
| 412 | do_requirements_1404 |
| 413 | else |
| 414 | echo "Ubuntu version $RELEASE is not supported" |
| 415 | exit 1 |
| 416 | fi |
| 417 | DID_REQUIREMENTS=true |
| 418 | fi |
| 419 | eval ${func_name} |
Carmelo Cascone | a52c880 | 2018-12-18 13:30:45 -0800 | [diff] [blame] | 420 | if [[ -d ${BUILD_DIR}/${proj_dir} ]]; then |
| 421 | # If project was built, we expect its dir. Otherwise, we assume |
| 422 | # build was skipped. |
| 423 | echo ${commit_id} > ${commit_file} |
| 424 | # Build all next projects as they might depend on this one. |
| 425 | MUST_DO_ALL=true |
| 426 | fi |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 427 | # Disable printing to reduce output |
| 428 | set +x |
| 429 | else |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 430 | echo "${step_name} is up to date (commit ${commit_id})" |
| 431 | fi |
| 432 | # Exit if last step. |
| 433 | if [ ${step_name} = ${LAST_STEP} ]; then |
| 434 | exit |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 435 | fi |
| 436 | } |
| 437 | |
| 438 | mkdir -p ${BUILD_DIR} |
| 439 | cd ${BUILD_DIR} |
| 440 | # In dependency order. |
| 441 | check_and_do ${PROTOBUF_COMMIT} protobuf do_protobuf protobuf |
| 442 | check_and_do ${GRPC_COMMIT} grpc do_grpc grpc |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 443 | # FIXME: re-enable when gNMI support becomes more stable |
| 444 | # check_and_do ${LIBYANG_COMMIT} libyang do_libyang libyang |
| 445 | # check_and_do ${SYSREPO_COMMIT} sysrepo do_sysrepo sysrepo |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 446 | check_and_do ${BMV2_COMMIT} bmv2 do_pi_bmv2_deps bmv2-deps |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 447 | check_and_do ${PI_COMMIT} PI do_PI PI |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 448 | check_and_do ${BMV2_COMMIT} bmv2 do_bmv2 bmv2 |
| 449 | check_and_do ${P4C_COMMIT} p4c do_p4c p4c |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 450 | check_and_do master scapy-vxlan do_scapy-vxlan scapy-vxlan |
| 451 | check_and_do master ptf do_ptf ptf |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 452 | |
| 453 | echo "Done!" |