github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/third_party/clang_toolchain/cc_configure_clang.bzl (about)

     1  """ Downloads clang and configures the crosstool using bazel's autoconf."""
     2  
     3  load("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_autoconf_impl")
     4  load(":download_clang.bzl", "download_clang")
     5  
     6  _TF_DOWNLOAD_CLANG = "TF_DOWNLOAD_CLANG"
     7  _TF_NEED_CUDA = "TF_NEED_CUDA"
     8  
     9  def _cc_clang_autoconf(repo_ctx):
    10      if repo_ctx.os.environ.get(_TF_DOWNLOAD_CLANG) != "1":
    11          return
    12      if repo_ctx.os.environ.get(_TF_NEED_CUDA) == "1":
    13          # Clang is handled separately for CUDA configs.
    14          # See cuda_configure.bzl for more details.
    15          return
    16  
    17      download_clang(repo_ctx, out_folder = "extra_tools")
    18      overriden_tools = {"gcc": "extra_tools/bin/clang"}
    19      cc_autoconf_impl(repo_ctx, overriden_tools)
    20  
    21  cc_download_clang_toolchain = repository_rule(
    22      environ = [
    23          _TF_DOWNLOAD_CLANG,
    24          _TF_NEED_CUDA,
    25      ],
    26      implementation = _cc_clang_autoconf,
    27  )