# Copyright (C) 2019 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") load("@protobuf//bazel:proto_library.bzl", "proto_library") load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_python//python:defs.bzl", "py_binary", "py_library") # Noop function used to override rules we don't want to support in standalone. def _noop_override(**kwargs): pass PERFETTO_CONFIG = struct( # This is used to refer to deps within perfetto's BUILD files. # In standalone and bazel-based embedders use '//', because perfetto has its # own repository, and //xxx would be relative to @perfetto//xxx. # In Google internal builds, instead, this is set to //third_party/perfetto, # because perfetto doesn't have its own repository there. root = "//", # These variables map dependencies to perfetto third-party projects. This is # to allow perfetto embedders (e.g. gapid) and google internal builds to # override paths and target names to their own third_party. deps = struct( # Target exposing the build config header. It should be a valid # cc_library dependency as it will become a dependency of every # perfetto_cc_library target. It needs to expose a # "perfetto_build_flags.h" file that can be included via: # #include "perfetto_build_flags.h". build_config = ["//:build_config_hdr"], # Target exposing the PERFETTO_VERSION_STRING() and # PERFETTO_VERSION_SCM_REVISION() macros. This is overridden in google # internal builds. version_header = ["//:cc_perfetto_version_header"], # Target exposing platform-specific functionality for base. This is # overridden in Google internal builds. base_platform = ["//:perfetto_base_default_platform"], zlib = ["@zlib//:zlib"], expat = ["@perfetto_dep_expat//:expat"], jsoncpp = ["@perfetto_dep_jsoncpp//:jsoncpp"], linenoise = ["@perfetto_dep_linenoise//:linenoise"], sqlite = ["@perfetto_dep_sqlite//:sqlite"], sqlite_ext_percentile = ["@perfetto_dep_sqlite_src//:percentile_ext"], protoc = ["@protobuf//:protoc"], protoc_lib = ["@protobuf//:protoc_lib"], protobuf_lite = ["@protobuf//:protobuf_lite"], protobuf_full = ["@protobuf//:protobuf"], protobuf_descriptor_proto = ["@protobuf//:descriptor_proto"], # The Python targets are empty on the standalone build because we assume # any relevant deps are installed on the system or are not applicable. protobuf_py = [], pandas_py = [], tp_vendor_py = [], tp_resolvers_py = [], # There are multiple configurations for the function name demangling # logic in trace processor: # (1) The following defaults include a subset of demangling sources # from llvm-project. This is the most complete implementation. # (2) You can avoid the llvm dependency by setting "llvm_demangle = []" # here and PERFETTO_LLVM_DEMANGLE to false in your # perfetto_build_flags.h. Then the implementation will use a # demangler from the c++ runtime, which will most likely handle # only itanium mangling, and is unavailable on some platforms (e.g. # Windows, where it becomes a nop). # (3) You can override the whole demangle_wrapper below, and provide # your own demangling implementation. demangle_wrapper = ["//:src_trace_processor_demangle"], llvm_demangle = ["@perfetto_dep_llvm_demangle//:llvm_demangle"], # no open csd support needed open_csd = [], android_test_common = [], ), # This struct allows embedders to customize the cc_opts for Perfetto # 3rd party dependencies. They only have an effect if the dependencies are # initialized with the Perfetto build files (i.e. via perfetto_deps()). deps_copts = struct( zlib = [], jsoncpp = [], linenoise = [], sqlite = [], llvm_demangle = [], ), # Allow Bazel embedders to change the visibility of "public" targets. # This variable has been introduced to limit the change to Bazel and avoid # making the targets fully public in the google internal tree. public_visibility = [ "//visibility:public", ], # Allow Bazel embedders to change the visibility of the proto targets. # This variable has been introduced to limit the change to Bazel and avoid # making the targets public in the google internal tree. proto_library_visibility = "//visibility:private", # Allow Bazel embedders to change the visibility of the Go protos. # Go protos have all sorts of strange behavior in Google3 so need special # handling as the rules for other languages do not work for Go. go_proto_library_visibility = "//visibility:private", # This struct allows the embedder to customize copts and other args passed # to rules like cc_binary. Prefixed rules (e.g. perfetto_cc_binary) will # look into this struct before falling back on native.cc_binary(). # This field is completely optional, the embedder can omit the whole # |rule_overrides| or individual keys. They are assigned to None or noop # actions here just for documentation purposes. # TODO: (cleanup): Drop all of these again once they are properly imported in perfetto. rule_overrides = struct( proto_library = proto_library, cc_binary = cc_binary, cc_library = cc_library, cc_proto_library = cc_proto_library, # Supporting java rules pulls in the JDK and generally is not something # we need for most embedders. java_proto_library = _noop_override, java_lite_proto_library = _noop_override, py_binary = py_binary, py_library = py_library, py_proto_library = None, go_proto_library = None, jspb_proto_library = None, ), # The default copts used to compile perfetto. The cfg example sets the C++ standard here, but # for now we shouldn't need any perfetto-specific compiler options, should already be set up # properly through .bazelrc. default_copts = [], default_cxxopts = [], )