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