• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import("//gn/standalone/sanitizers/vars.gni")
16
17declare_args() {
18  is_hermetic_clang = is_clang && (is_linux_host || is_win_host)
19}
20
21assert(!is_hermetic_clang || is_clang, "is_hermetic_clang requires is_clang")
22
23if (is_linux_host) {
24  if (is_hermetic_clang) {
25    _hermetic_llvm_dir =
26        rebase_path("//buildtools/linux64/clang", root_build_dir)
27    linux_clang_bin = "$_hermetic_llvm_dir/bin/clang"
28    linux_clangxx_bin = "$_hermetic_llvm_dir/bin/clang++"
29    linux_clang_linker = "lld"
30  } else if (is_clang && !is_system_compiler) {
31    # Guess the path for the system clang.
32    # When is_system_compiler = true users neet to explicitly set cc / target_cc
33    # vars in the GN args."
34    _find_llvm_out = exec_script("linux_find_llvm.py", [], "list lines")
35    _linux_llvm_dir = _find_llvm_out[0]
36    linux_clang_bin = _find_llvm_out[1]
37    linux_clangxx_bin = _find_llvm_out[2]
38    linux_clang_linker = "gold"
39  }
40} else if (is_mac_host && is_clang && !is_system_compiler) {
41  _mac_toolchain_dirs = exec_script("mac_find_llvm.py", [], "list lines")
42
43  # _mac_toolchain_dirs[0] contains the mac toolchain dir.
44  mac_clangrt_dir = _mac_toolchain_dirs[1]
45} else if (is_win_host) {
46  if (is_hermetic_clang) {
47    # Use the toolchain pulled by //tools/install-build-deps. This tracks
48    # chromium's llvm dist.
49    _llvm_win_path = rebase_path("//buildtools/win/clang/bin", root_build_dir)
50    win_clang_bin = "${_llvm_win_path}\clang-cl.exe"
51    win_clangxx_bin = "${_llvm_win_path}\clang-cl.exe"
52    win_clang_linker = "${_llvm_win_path}\lld-link.exe"
53  } else {
54    # Assume clang-cl.exe / lld-link.exe are on the PATH. The user can always
55    # ovveride them by setting cc/cxx/linker GN variables.
56    # See //gn/standalone/toolchain/BUILD.gn.
57    win_clang_bin = "clang-cl.exe"
58    win_clangxx_bin = "clang-cl.exe"
59    win_clang_linker = "lld-link.exe"
60  }
61}
62