tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

clang_linux.star (4907B)


      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 
      7 load("@builtin//struct.star", "module")
      8 load("./android.star", "android")
      9 load("./clang_all.star", "clang_all")
     10 load("./clang_unix.star", "clang_unix")
     11 load("./fuchsia.star", "fuchsia")
     12 load("./win_sdk.star", "win_sdk")
     13 
     14 target_cpus = ["amd64", "i386", "arm64", "armhf"]
     15 
     16 def __filegroups(ctx):
     17     fg = {
     18         "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include:include": {
     19             "type": "glob",
     20             "includes": ["*"],
     21             # can't use "*.h", because c++ headers have no extension.
     22         },
     23         "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include:include": {
     24             "type": "glob",
     25             "includes": ["*"],
     26         },
     27         "third_party/llvm-build/Release+Asserts/bin:llddeps": {
     28             "type": "glob",
     29             "includes": [
     30                 "clang*",
     31                 "ld.lld",
     32                 "ld64.lld",
     33                 "lld",
     34                 "llvm-nm",
     35                 "llvm-objcopy",
     36                 "llvm-objdump",
     37                 "llvm-otool",
     38                 "llvm-readelf",
     39                 "llvm-readobj",
     40                 "llvm-strip",
     41             ],
     42         },
     43         "third_party/llvm-build/Release+Asserts/lib/clang:libs": {
     44             "type": "glob",
     45             "includes": ["*/lib/*/*", "*/lib/*", "*/share/*"],
     46         },
     47     }
     48 
     49     def __add_sysroot_for_target_cpu(fg, cpu):
     50         fg.update({
     51             # for precomputed subtrees
     52             "build/linux/debian_bullseye_%s-sysroot/usr/include:include" % cpu: {
     53                 "type": "glob",
     54                 "includes": ["*"],
     55                 # need bits/stab.def, c++/*
     56             },
     57             "build/linux/debian_bullseye_%s-sysroot/usr/lib:headers" % cpu: {
     58                 "type": "glob",
     59                 "includes": ["*.h", "crtbegin.o"],
     60             },
     61             "build/linux/debian_bullseye_%s-sysroot:libs" % cpu: {
     62                 "type": "glob",
     63                 "includes": ["*.so*", "*.o", "*.a"],
     64                 "excludes": [
     65                     "usr/lib/python*/*/*",
     66                     "systemd/*/*",
     67                     "usr/libexec/*/*",
     68                 ],
     69             },
     70         })
     71         return fg
     72 
     73     for cpu in target_cpus:
     74         fg = __add_sysroot_for_target_cpu(fg, cpu)
     75     if android.enabled(ctx):
     76         fg.update(android.filegroups(ctx))
     77     if fuchsia.enabled(ctx):
     78         fg.update(fuchsia.filegroups(ctx))
     79     fg.update(clang_all.filegroups(ctx))
     80     return fg
     81 
     82 __handlers = {}
     83 __handlers.update(clang_unix.handlers)
     84 __handlers.update(clang_all.handlers)
     85 
     86 def __step_config(ctx, step_config):
     87     step_config["input_deps"].update({
     88         "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot:headers": [
     89             "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include:include",
     90             "third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include:include",
     91         ],
     92         "third_party/llvm-build/Release+Asserts/bin/clang++:link": [
     93             "third_party/llvm-build/Release+Asserts/bin:llddeps",
     94         ],
     95         "third_party/llvm-build/Release+Asserts:link": [
     96             "third_party/llvm-build/Release+Asserts/bin:llddeps",
     97             "third_party/llvm-build/Release+Asserts/lib/clang:libs",
     98         ],
     99     })
    100 
    101     def __add_sysroot_for_target_cpu(step_config, cpu):
    102         step_config["input_deps"].update({
    103             # sysroot headers for precomputed subtrees
    104             "build/linux/debian_bullseye_%s-sysroot:headers" % cpu: [
    105                 "build/linux/debian_bullseye_%s-sysroot/usr/include:include" % cpu,
    106                 "build/linux/debian_bullseye_%s-sysroot/usr/lib:headers" % cpu,
    107             ],
    108             "build/linux/debian_bullseye_%s-sysroot:link" % cpu: [
    109                 "build/linux/debian_bullseye_%s-sysroot:libs" % cpu,
    110                 "third_party/llvm-build/Release+Asserts/bin:llddeps",
    111                 # The following inputs are used for sanitizer builds.
    112                 # It might be better to add them only for sanitizer builds if there is a performance issue.
    113                 "third_party/llvm-build/Release+Asserts/lib/clang:libs",
    114             ],
    115         })
    116 
    117     for cpu in target_cpus:
    118         __add_sysroot_for_target_cpu(step_config, cpu)
    119     step_config["input_deps"].update(clang_all.input_deps)
    120 
    121     step_config["rules"].extend(clang_unix.rules(ctx))
    122     if win_sdk.enabled(ctx):
    123         win_sdk.step_config(ctx, step_config)
    124     return step_config
    125 
    126 clang = module(
    127     "clang",
    128     step_config = __step_config,
    129     filegroups = __filegroups,
    130     handlers = __handlers,
    131 )