Eric Fiselier | 9c97ca1 | 2018-11-19 18:43:31 +0000 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | #===- libcxx/utils/docker/scripts/install_clang_package.sh -----------------===// |
| 3 | # |
| 4 | # The LLVM Compiler Infrastructure |
| 5 | # |
| 6 | # This file is distributed under the University of Illinois Open Source |
| 7 | # License. See LICENSE.TXT for details. |
| 8 | # |
| 9 | #===-----------------------------------------------------------------------===// |
| 10 | |
| 11 | set -e |
| 12 | |
| 13 | function show_usage() { |
| 14 | cat << EOF |
| 15 | Usage: install_clang_package.sh [options] |
| 16 | |
| 17 | Install |
| 18 | Available options: |
| 19 | -h|--help show this help message |
| 20 | --version the numeric version of the package to use. |
| 21 | EOF |
| 22 | } |
| 23 | |
| 24 | VERSION="" |
| 25 | |
| 26 | while [[ $# -gt 0 ]]; do |
| 27 | case "$1" in |
| 28 | --version) |
| 29 | shift |
| 30 | VERSION="$1" |
| 31 | shift |
| 32 | ;; |
| 33 | -h|--help) |
| 34 | show_usage |
| 35 | exit 0 |
| 36 | ;; |
| 37 | *) |
| 38 | echo "Unknown option: $1" |
| 39 | exit 1 |
| 40 | esac |
| 41 | done |
| 42 | |
| 43 | |
| 44 | |
| 45 | curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - |
| 46 | add-apt-repository -s "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs) main" |
| 47 | apt-get update |
| 48 | apt-get install -y --no-install-recommends clang |
| 49 | |
| 50 | echo "Testing clang version..." |
| 51 | clang --version |
| 52 | |
| 53 | echo "Testing clang++ version..." |
| 54 | clang++ --version |
| 55 | |
| 56 | # Figure out the libc++ and libc++abi package versions that we want. |
| 57 | if [ "$VERSION" == "" ]; then |
| 58 | VERSION="$(apt-cache search 'libc\+\+-[0-9]-dev' | awk '{print $1}' | awk -F- '{print $2}')" |
| 59 | echo "Installing version '$VERSION'" |
| 60 | fi |
| 61 | |
| 62 | apt-get install -y --no-install-recommends "libc++-$VERSION-dev" "libc++abi-$VERSION-dev" |
| 63 | |
| 64 | echo "Done" |