• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- bazel-starlark -*-
2# Copyright 2023 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Siso configuration for clang/linux."""
6
7load("@builtin//path.star", "path")
8load("@builtin//struct.star", "module")
9load("./clang_all.star", "clang_all")
10load("./clang_code_coverage_wrapper.star", "clang_code_coverage_wrapper")
11
12def __filegroups(ctx):
13    fg = {
14        # for precomputed subtrees
15        "build/linux/debian_bullseye_amd64-sysroot/usr/include:include": {
16            "type": "glob",
17            "includes": ["*"],
18            # need bits/stab.def, c++/*
19        },
20        "build/linux/debian_bullseye_amd64-sysroot/usr/lib:headers": {
21            "type": "glob",
22            "includes": ["*.h", "crtbegin.o"],
23        },
24        "build/linux/debian_bullseye_i386-sysroot/usr/include:include": {
25            "type": "glob",
26            "includes": ["*"],
27            # need bits/stab.def, c++/*
28        },
29        "build/linux/debian_bullseye_i386-sysroot/usr/lib:headers": {
30            "type": "glob",
31            "includes": ["*.h", "crtbegin.o"],
32        },
33        "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include:include": {
34            "type": "glob",
35            "includes": ["*"],
36            # can't use "*.h", because c++ headers have no extension.
37        },
38        "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include:include": {
39            "type": "glob",
40            "includes": ["*"],
41        },
42    }
43    fg.update(clang_all.filegroups(ctx))
44    return fg
45
46def __clang_compile_coverage(ctx, cmd):
47    clang_command = clang_code_coverage_wrapper.run(ctx, list(cmd.args))
48    ctx.actions.fix(args = clang_command)
49
50__handlers = {
51    "clang_compile_coverage": __clang_compile_coverage,
52}
53
54def __step_config(ctx, step_config):
55    step_config["input_deps"].update({
56        # sysroot headers for precomputed subtrees
57        "build/linux/debian_bullseye_amd64-sysroot:headers": [
58            "build/linux/debian_bullseye_amd64-sysroot/usr/include:include",
59            "build/linux/debian_bullseye_amd64-sysroot/usr/lib:headers",
60        ],
61        "build/linux/debian_bullseye_i386-sysroot:headers": [
62            "build/linux/debian_bullseye_i386-sysroot/usr/include:include",
63            "build/linux/debian_bullseye_i386-sysroot/usr/lib:headers",
64        ],
65        "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot:headers": [
66            "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include:include",
67            "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include:include",
68        ],
69    })
70    step_config["input_deps"].update(clang_all.input_deps)
71    step_config["rules"].extend([
72        {
73            "name": "clang/cxx",
74            "action": "(.*_)?cxx",
75            "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang++ ",
76            "inputs": [
77                "third_party/llvm-build/Release+Asserts/bin/clang++",
78            ],
79            "remote": True,
80            "canonicalize_dir": True,
81            "timeout": "2m",
82        },
83        {
84            "name": "clang/cc",
85            "action": "(.*_)?cc",
86            "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang ",
87            "inputs": [
88                "third_party/llvm-build/Release+Asserts/bin/clang",
89            ],
90            "remote": True,
91            "canonicalize_dir": True,
92            "timeout": "2m",
93        },
94        {
95            "name": "clang-coverage/cxx",
96            "action": "(.*_)?cxx",
97            "command_prefix": "\"python3\" ../../build/toolchain/clang_code_coverage_wrapper.py",
98            "inputs": [
99                "third_party/llvm-build/Release+Asserts/bin/clang++",
100            ],
101            "handler": "clang_compile_coverage",
102            "remote": True,
103            "canonicalize_dir": True,
104            "timeout": "2m",
105        },
106        {
107            "name": "clang-coverage/cc",
108            "action": "(.*_)?cc",
109            "command_prefix": "\"python3\" ../../build/toolchain/clang_code_coverage_wrapper.py",
110            "inputs": [
111                "third_party/llvm-build/Release+Asserts/bin/clang",
112            ],
113            "handler": "clang_compile_coverage",
114            "remote": True,
115            "canonicalize_dir": True,
116            "timeout": "2m",
117        },
118    ])
119    return step_config
120
121clang = module(
122    "clang",
123    step_config = __step_config,
124    filegroups = __filegroups,
125    handlers = __handlers,
126)
127