# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//gn/standalone/sanitizers/vars.gni")

declare_args() {
  is_hermetic_clang = is_clang && (is_linux_host || is_win_host)
}

assert(!is_hermetic_clang || is_clang, "is_hermetic_clang requires is_clang")

linux_llvm_objcopy = ""
if (is_linux_host) {
  if (is_hermetic_clang) {
    _hermetic_llvm_dir =
        rebase_path("//buildtools/linux64/clang", root_build_dir)
    linux_clang_bin = "$_hermetic_llvm_dir/bin/clang"
    linux_clangxx_bin = "$_hermetic_llvm_dir/bin/clang++"
    linux_llvm_objcopy = "$_hermetic_llvm_dir/bin/llvm-objcopy"
    linux_clang_linker = "lld"
  } else if (is_clang && !is_system_compiler) {
    # Guess the path for the system clang.
    # When is_system_compiler = true users neet to explicitly set cc / target_cc
    # vars in the GN args."
    _find_llvm_out = exec_script("linux_find_llvm.py", [], "list lines")
    _linux_llvm_dir = _find_llvm_out[0]
    linux_clang_bin = _find_llvm_out[1]
    linux_clangxx_bin = _find_llvm_out[2]
    linux_clang_linker = "gold"
  }
} else if (is_mac_host && is_clang && !is_system_compiler) {
  _mac_toolchain_dirs = exec_script("mac_find_llvm.py", [], "list lines")

  # _mac_toolchain_dirs[0] contains the mac toolchain dir.
  mac_clangrt_dir = _mac_toolchain_dirs[1]
} else if (is_win_host) {
  if (is_hermetic_clang) {
    # Use the toolchain pulled by //tools/install-build-deps. This tracks
    # chromium's llvm dist.
    _llvm_win_path = rebase_path("//buildtools/win/clang/bin", root_build_dir)
    win_clang_bin = "${_llvm_win_path}\clang-cl.exe"
    win_clangxx_bin = "${_llvm_win_path}\clang-cl.exe"
    win_clang_linker = "${_llvm_win_path}\lld-link.exe"
  } else {
    # Assume clang-cl.exe / lld-link.exe are on the PATH. The user can always
    # ovveride them by setting cc/cxx/linker GN variables.
    # See //gn/standalone/toolchain/BUILD.gn.
    win_clang_bin = "clang-cl.exe"
    win_clangxx_bin = "clang-cl.exe"
    win_clang_linker = "lld-link.exe"
  }
}
