File: cc_configure_clang.bzl

package info (click to toggle)
tensorflow 2.14.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 359,396 kB
  • sloc: cpp: 2,418,453; python: 736,954; java: 20,254; ansic: 18,962; sh: 9,279; pascal: 7,941; objc: 1,584; xml: 988; ada: 727; cs: 273; perl: 150; makefile: 92
file content (27 lines) | stat: -rw-r--r-- 878 bytes parent folder | download | duplicates (13)
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
""" Downloads clang and configures the crosstool using bazel's autoconf."""

load("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_autoconf_impl")
load(":download_clang.bzl", "download_clang")

_TF_DOWNLOAD_CLANG = "TF_DOWNLOAD_CLANG"
_TF_NEED_CUDA = "TF_NEED_CUDA"

def _cc_clang_autoconf(repo_ctx):
    if repo_ctx.os.environ.get(_TF_DOWNLOAD_CLANG) != "1":
        return
    if repo_ctx.os.environ.get(_TF_NEED_CUDA) == "1":
        # Clang is handled separately for CUDA configs.
        # See cuda_configure.bzl for more details.
        return

    download_clang(repo_ctx, out_folder = "extra_tools")
    overridden_tools = {"gcc": "extra_tools/bin/clang"}
    cc_autoconf_impl(repo_ctx, overridden_tools)

cc_download_clang_toolchain = repository_rule(
    environ = [
        _TF_DOWNLOAD_CLANG,
        _TF_NEED_CUDA,
    ],
    implementation = _cc_clang_autoconf,
)