1*6dbdd20aSAndroid Build Coastguard Worker# Copyright (C) 2020 The Android Open Source Project 2*6dbdd20aSAndroid Build Coastguard Worker# 3*6dbdd20aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*6dbdd20aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*6dbdd20aSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*6dbdd20aSAndroid Build Coastguard Worker# 7*6dbdd20aSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*6dbdd20aSAndroid Build Coastguard Worker# 9*6dbdd20aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*6dbdd20aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*6dbdd20aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*6dbdd20aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*6dbdd20aSAndroid Build Coastguard Worker# limitations under the License. 14*6dbdd20aSAndroid Build Coastguard Worker 15*6dbdd20aSAndroid Build Coastguard Workerimport("perfetto.gni") 16*6dbdd20aSAndroid Build Coastguard Worker 17*6dbdd20aSAndroid Build Coastguard Worker# This template is used when generating build files via tools/gen_android_bp 18*6dbdd20aSAndroid Build Coastguard Worker# and tools/gen_bazel. This is to solve the problem that other build systems 19*6dbdd20aSAndroid Build Coastguard Worker# don't have a similar concept to GN's source_set and dependencies can only 20*6dbdd20aSAndroid Build Coastguard Worker# happen between static libraries (or shared, but we don't use them). 21*6dbdd20aSAndroid Build Coastguard Worker 22*6dbdd20aSAndroid Build Coastguard Worker# In future this could be used for chromium component builds, where each 23*6dbdd20aSAndroid Build Coastguard Worker# component becomes its own shared library (see b/159411946). This alone isn't 24*6dbdd20aSAndroid Build Coastguard Worker# enough for that use case as it will require splitting also the various 25*6dbdd20aSAndroid Build Coastguard Worker# export.h files. 26*6dbdd20aSAndroid Build Coastguard Worker 27*6dbdd20aSAndroid Build Coastguard Worker# TODO(primiano): we cannot split components as static libraries in Android 28*6dbdd20aSAndroid Build Coastguard Worker# because heapprofd_client rebuilds base with 29*6dbdd20aSAndroid Build Coastguard Worker# -DPERFETTO_ANDROID_ASYNC_SAFE_LOG. Once this is fixed re-enable the 30*6dbdd20aSAndroid Build Coastguard Worker# ODRChecker in tools/gen_android_bp. 31*6dbdd20aSAndroid Build Coastguard Worker 32*6dbdd20aSAndroid Build Coastguard Worker# The condition below really means: "is Bazel generator". 33*6dbdd20aSAndroid Build Coastguard Workerif (is_perfetto_build_generator && !perfetto_build_with_android) { 34*6dbdd20aSAndroid Build Coastguard Worker perfetto_component_type = "static_library" 35*6dbdd20aSAndroid Build Coastguard Worker} else { 36*6dbdd20aSAndroid Build Coastguard Worker perfetto_component_type = "source_set" 37*6dbdd20aSAndroid Build Coastguard Worker} 38*6dbdd20aSAndroid Build Coastguard Worker 39*6dbdd20aSAndroid Build Coastguard Workertemplate("perfetto_component") { 40*6dbdd20aSAndroid Build Coastguard Worker target(perfetto_component_type, target_name) { 41*6dbdd20aSAndroid Build Coastguard Worker forward_variables_from(invoker, "*") 42*6dbdd20aSAndroid Build Coastguard Worker if (perfetto_component_type == "static_library") { 43*6dbdd20aSAndroid Build Coastguard Worker # Mangle the name of the library putting the full path in it. In component 44*6dbdd20aSAndroid Build Coastguard Worker # builds we don't care about file names, as nobody depends from the 45*6dbdd20aSAndroid Build Coastguard Worker # outside on the internal component libraries. 46*6dbdd20aSAndroid Build Coastguard Worker # This is because library targets are stored in the root output folder 47*6dbdd20aSAndroid Build Coastguard Worker # (not in a subfolder that matches their path). This mangling avoid file 48*6dbdd20aSAndroid Build Coastguard Worker # avoid name clashes when the target is called "common" or similar, so we 49*6dbdd20aSAndroid Build Coastguard Worker # use src_ipc_common.a rather than common.a. 50*6dbdd20aSAndroid Build Coastguard Worker _name = get_label_info(target_name, "label_no_toolchain") 51*6dbdd20aSAndroid Build Coastguard Worker _name = string_replace(_name, "//", "") 52*6dbdd20aSAndroid Build Coastguard Worker _name = string_replace(_name, "/", "_") 53*6dbdd20aSAndroid Build Coastguard Worker _name = string_replace(_name, ":", "_") 54*6dbdd20aSAndroid Build Coastguard Worker output_name = _name 55*6dbdd20aSAndroid Build Coastguard Worker complete_static_lib = true 56*6dbdd20aSAndroid Build Coastguard Worker } 57*6dbdd20aSAndroid Build Coastguard Worker } 58*6dbdd20aSAndroid Build Coastguard Worker} 59