xref: /aosp_15_r20/external/pigweed/pw_symbolizer/py/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2022 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
16load("@rules_python//python:defs.bzl", "py_library")
17load("//pw_build:python.bzl", "pw_py_test")
18
19package(default_visibility = ["//visibility:public"])
20
21# Path to the `llvm-symbolizer` binary for the toolchain being
22# decoded.
23#
24# This should be overriden for toolchains which don't use
25# `@llvm-toolchain`.
26label_flag(
27    name = "llvm-symbolizer",
28    build_setting_default = "@llvm_toolchain//:bin/llvm-symbolizer",
29)
30
31# Symlink the `llvm-symbolizer` binary (whose path may be different
32# based on the label flag above) into a common location.
33copy_file(
34    name = "llvm-symbolizer-symlink",
35    src = ":llvm-symbolizer",
36    out = "llvm-symbolizer-copy",
37    allow_symlink = True,
38    is_executable = True,
39)
40
41py_library(
42    name = "pw_symbolizer",
43    srcs = [
44        "pw_symbolizer/__init__.py",
45        "pw_symbolizer/llvm_symbolizer.py",
46        "pw_symbolizer/symbolizer.py",
47    ],
48    data = [":llvm-symbolizer-symlink"],
49    imports = ["."],
50    deps = ["@rules_python//python/runfiles"],
51)
52
53pw_py_test(
54    name = "symbolizer_test",
55    size = "small",
56    srcs = ["symbolizer_test.py"],
57    deps = [":pw_symbolizer"],
58)
59
60# This test attempts to run subprocesses directly in the source tree, which is
61# incompatible with sandboxing.
62# TODO: b/241307309 - Update this test to work with bazel.
63filegroup(
64    name = "llvm_symbolizer_test",
65    # size = "small",
66    srcs = [
67        "llvm_symbolizer_test.py",
68        "symbolizer_test.cc",
69    ],
70    # deps = [":pw_symbolizer"],
71)
72