• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2020 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
15import("perfetto.gni")
16
17# This template is used when generating build files via tools/gen_android_bp
18# and tools/gen_bazel. This is to solve the problem that other build systems
19# don't have a similar concept to GN's source_set and dependencies can only
20# happen between static libraries (or shared, but we don't use them).
21
22# In future this could be used for chromium component builds, where each
23# component becomes its own shared library (see b/159411946). This alone isn't
24# enough for that use case as it will require splitting also the various
25# export.h files.
26
27# TODO(primiano): we cannot split components as static libraries in Android
28# because heapprofd_client rebuilds base with
29# -DPERFETTO_ANDROID_ASYNC_SAFE_LOG. Once this is fixed re-enable the
30# ODRChecker in tools/gen_android_bp.
31
32# The condition below really means: "is Bazel generator".
33if (is_perfetto_build_generator && !perfetto_build_with_android) {
34  perfetto_component_type = "static_library"
35} else {
36  perfetto_component_type = "source_set"
37}
38
39template("perfetto_component") {
40  target(perfetto_component_type, target_name) {
41    forward_variables_from(invoker, "*")
42    if (perfetto_component_type == "static_library") {
43      # Mangle the name of the library putting the full path in it. In component
44      # builds we don't care about file names, as nobody depends from the
45      # outside on the internal component libraries.
46      # This is because library targets are stored in the root output folder
47      # (not in a subfolder that matches their path). This mangling avoid file
48      # avoid name clashes when the target is called "common" or similar, so we
49      # use src_ipc_common.a rather than common.a.
50      _name = get_label_info(target_name, "label_no_toolchain")
51      _name = string_replace(_name, "//", "")
52      _name = string_replace(_name, "/", "_")
53      _name = string_replace(_name, ":", "_")
54      output_name = _name
55      complete_static_lib = true
56    }
57  }
58}
59