Skip to content
File

Blob: build/perfetto/perfetto_cfg.bzl

6.8 KB
1# Copyright (C) 2019 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://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,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14 
15load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
16load("@protobuf//bazel:proto_library.bzl", "proto_library")
17load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
18load("@rules_cc//cc:cc_library.bzl", "cc_library")
19load("@rules_python//python:defs.bzl", "py_binary", "py_library")
20 
21# Noop function used to override rules we don't want to support in standalone.
22def _noop_override(**kwargs):
23 pass
24 
25PERFETTO_CONFIG = struct(
26 # This is used to refer to deps within perfetto's BUILD files.
27 # In standalone and bazel-based embedders use '//', because perfetto has its
28 # own repository, and //xxx would be relative to @perfetto//xxx.
29 # In Google internal builds, instead, this is set to //third_party/perfetto,
30 # because perfetto doesn't have its own repository there.
31 root = "//",
32 
33 # These variables map dependencies to perfetto third-party projects. This is
34 # to allow perfetto embedders (e.g. gapid) and google internal builds to
35 # override paths and target names to their own third_party.
36 deps = struct(
37 # Target exposing the build config header. It should be a valid
38 # cc_library dependency as it will become a dependency of every
39 # perfetto_cc_library target. It needs to expose a
40 # "perfetto_build_flags.h" file that can be included via:
41 # #include "perfetto_build_flags.h".
42 build_config = ["//:build_config_hdr"],
43 
44 # Target exposing the PERFETTO_VERSION_STRING() and
45 # PERFETTO_VERSION_SCM_REVISION() macros. This is overridden in google
46 # internal builds.
47 version_header = ["//:cc_perfetto_version_header"],
48 
49 # Target exposing platform-specific functionality for base. This is
50 # overridden in Google internal builds.
51 base_platform = ["//:perfetto_base_default_platform"],
52 zlib = ["@zlib//:zlib"],
53 expat = ["@perfetto_dep_expat//:expat"],
54 jsoncpp = ["@perfetto_dep_jsoncpp//:jsoncpp"],
55 linenoise = ["@perfetto_dep_linenoise//:linenoise"],
56 sqlite = ["@perfetto_dep_sqlite//:sqlite"],
57 sqlite_ext_percentile = ["@perfetto_dep_sqlite_src//:percentile_ext"],
58 protoc = ["@protobuf//:protoc"],
59 protoc_lib = ["@protobuf//:protoc_lib"],
60 protobuf_lite = ["@protobuf//:protobuf_lite"],
61 protobuf_full = ["@protobuf//:protobuf"],
62 protobuf_descriptor_proto = ["@protobuf//:descriptor_proto"],
63 
64 # The Python targets are empty on the standalone build because we assume
65 # any relevant deps are installed on the system or are not applicable.
66 protobuf_py = [],
67 pandas_py = [],
68 tp_vendor_py = [],
69 tp_resolvers_py = [],
70 
71 # There are multiple configurations for the function name demangling
72 # logic in trace processor:
73 # (1) The following defaults include a subset of demangling sources
74 # from llvm-project. This is the most complete implementation.
75 # (2) You can avoid the llvm dependency by setting "llvm_demangle = []"
76 # here and PERFETTO_LLVM_DEMANGLE to false in your
77 # perfetto_build_flags.h. Then the implementation will use a
78 # demangler from the c++ runtime, which will most likely handle
79 # only itanium mangling, and is unavailable on some platforms (e.g.
80 # Windows, where it becomes a nop).
81 # (3) You can override the whole demangle_wrapper below, and provide
82 # your own demangling implementation.
83 demangle_wrapper = ["//:src_trace_processor_demangle"],
84 llvm_demangle = ["@perfetto_dep_llvm_demangle//:llvm_demangle"],
85 
86 # no open csd support needed
87 open_csd = [],
88 android_test_common = [],
89 ),
90 
91 # This struct allows embedders to customize the cc_opts for Perfetto
92 # 3rd party dependencies. They only have an effect if the dependencies are
93 # initialized with the Perfetto build files (i.e. via perfetto_deps()).
94 deps_copts = struct(
95 zlib = [],
96 jsoncpp = [],
97 linenoise = [],
98 sqlite = [],
99 llvm_demangle = [],
100 ),
101 
102 # Allow Bazel embedders to change the visibility of "public" targets.
103 # This variable has been introduced to limit the change to Bazel and avoid
104 # making the targets fully public in the google internal tree.
105 public_visibility = [
106 "//visibility:public",
107 ],
108 
109 # Allow Bazel embedders to change the visibility of the proto targets.
110 # This variable has been introduced to limit the change to Bazel and avoid
111 # making the targets public in the google internal tree.
112 proto_library_visibility = "//visibility:private",
113 
114 # Allow Bazel embedders to change the visibility of the Go protos.
115 # Go protos have all sorts of strange behavior in Google3 so need special
116 # handling as the rules for other languages do not work for Go.
117 go_proto_library_visibility = "//visibility:private",
118 
119 # This struct allows the embedder to customize copts and other args passed
120 # to rules like cc_binary. Prefixed rules (e.g. perfetto_cc_binary) will
121 # look into this struct before falling back on native.cc_binary().
122 # This field is completely optional, the embedder can omit the whole
123 # |rule_overrides| or individual keys. They are assigned to None or noop
124 # actions here just for documentation purposes.
125 # TODO: (cleanup): Drop all of these again once they are properly imported in perfetto.
126 rule_overrides = struct(
127 proto_library = proto_library,
128 cc_binary = cc_binary,
129 cc_library = cc_library,
130 cc_proto_library = cc_proto_library,
131 
132 # Supporting java rules pulls in the JDK and generally is not something
133 # we need for most embedders.
134 java_proto_library = _noop_override,
135 java_lite_proto_library = _noop_override,
136 py_binary = py_binary,
137 py_library = py_library,
138 py_proto_library = None,
139 go_proto_library = None,
140 jspb_proto_library = None,
141 ),
142 
143 # The default copts used to compile perfetto. The cfg example sets the C++ standard here, but
144 # for now we shouldn't need any perfetto-specific compiler options, should already be set up
145 # properly through .bazelrc.
146 default_copts = [],
147 default_cxxopts = [],
148)