about summary refs log tree commit diff homepage
path: root/scripts/build/p-clang-linux-ubuntu-16.04.inc
blob: 750236282ccb925ff5ffc170047ac5658eb58ccd (plain) (blame)
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
install_binary_artifact_clang() {
  local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
  local LLVM_VERSION_MINOR="${LLVM_VERSION/*./}"

  # Check versions: no support for LLVM < 3.5
  [[ "${LLVM_VERSION_MAJOR}" -eq 3 ]] && [[ "${LLVM_VERSION_MINOR}" -lt 5 ]] && return 1


  local version=""
  [[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="-${LLVM_VERSION}"
  [[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="-${LLVM_VERSION_MAJOR}"


  if [[ "${LLVM_VERSION_MAJOR}" -eq 3 && "${LLVM_VERSION_MINOR}" -gt 7 ]]; then
    # Add certificate
    apt update -y
    dependencies=(
      ca-certificates
      wget
    )

    apt -y --no-install-recommends install "${dependencies[@]}"
    wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add -

    # Add repository
    echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial${version} main" >> /etc/apt/sources.list
  fi

  apt update -y
  dependencies=(
    "llvm${version}"
    "clang${version}"
  )

  #Install essential dependencies
  apt -y --no-install-recommends install "${dependencies[@]}"
}

setup_artifact_variables_clang() {
  local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
  local LLVM_VERSION_MINOR="${LLVM_VERSION/*./}"
  local version=""
  [[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="-${LLVM_VERSION}"
  [[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="-${LLVM_VERSION_MAJOR}"

  # Only set LLVM_CONFIG if not set yet
  if [[ -z ${LLVM_CONFIG+x} ]]; then
    LLVM_CONFIG=$(which "llvm-config${version}")
  fi

  BITCODE_CC=$(which "clang${version}")
  BITCODE_CXX=$(which "clang++${version}")

  SANITIZER_C_COMPILER="${BITCODE_CC}"
  SANITIZER_CXX_COMPILER="${BITCODE_CXX}"
}

# Check if the binary artifact is installed
is_installed_clang() {
    # Check if llvm-config with the right version exists    
    which "llvm-config-${LLVM_VERSION}"
}

get_docker_config_id_clang() {
  return 0
}