1# Copyright (C) 2017 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") 16import("proto_library.gni") 17if (perfetto_build_standalone || perfetto_build_with_android) { 18 import("//gn/standalone/sanitizers/vars.gni") 19} else { 20 import("//build/config/sanitizers/sanitizers.gni") 21} 22 23config("asan_instrumentation") { 24 if (use_sanitizer_configs_without_instrumentation) { 25 defines = [ "ADDRESS_SANITIZER_WITHOUT_INSTRUMENTATION" ] 26 } 27} 28 29# Used by base/gtest_prod_util.h for the FRIEND_TEST_* macros. Note that other 30# production targets (i.e. testonly == false) should use base/gtest_prod_util.h 31# instead. 32group("gtest_prod_config") { 33 if (perfetto_build_standalone || perfetto_build_with_android) { 34 public_configs = [ "//buildtools:googletest_prod_config" ] 35 } else { 36 public_configs = [ ":gtest_config" ] 37 } 38} 39 40config("gtest_config") { 41 if (perfetto_build_with_embedder) { 42 include_dirs = [ "//testing/gtest/include" ] 43 } 44} 45 46config("gmock_config") { 47 if (perfetto_build_with_embedder) { 48 include_dirs = [ "//testing/gmock/include" ] 49 } 50} 51 52group("gtest_deps") { 53 testonly = true 54 55 public_configs = [ 56 ":gtest_config", 57 ":gmock_config", 58 ] 59 60 if (perfetto_build_standalone || perfetto_build_with_android) { 61 public_deps = [ 62 "//buildtools:gmock", 63 "//buildtools:gtest", 64 ] 65 } else { 66 public_deps = [ 67 "//testing/gmock", 68 "//testing/gtest", 69 ] 70 } 71} 72 73group("gtest_main") { 74 testonly = true 75 76 if (perfetto_build_standalone || perfetto_build_with_android) { 77 public_deps = [ 78 "//buildtools:gtest_main", 79 ] 80 } else if (build_with_chromium) { 81 public_deps = [ 82 "//base/test:run_all_unittests", 83 ] 84 } else { 85 public_deps = [ 86 "//testing/gtest:gtest_main", 87 ] 88 } 89} 90 91# protoc compiler library, for building protoc plugins on the host. 92if (current_toolchain == host_toolchain) { 93 group("protoc_lib_deps") { 94 public_deps = [ 95 "${perfetto_protobuf_target_prefix}:protoc_lib", 96 ] 97 } 98} 99 100group("protobuf_full_deps") { 101 testonly = true 102 public_deps = [ 103 "${perfetto_protobuf_target_prefix}:protobuf_full", 104 ] 105} 106 107# All targets should depend on this target to inherit the right flags and 108# include directories. 109group("default_deps") { 110 public_configs = [ ":default_config" ] 111 if (perfetto_build_standalone || perfetto_build_with_android) { 112 public_deps = [ 113 "//gn/standalone/libc++:deps", 114 "//gn/standalone/sanitizers:deps", 115 ] 116 } 117} 118 119# The config that all targets in the perfetto codebase inherit by virtue of 120# having explicit deps on //gn:default_deps. This config is NOT propagated up to 121# embedders that depend on perfetto (e.g. chrome). :public_config (see below) is 122# used for that. 123config("default_config") { 124 configs = [ ":public_config" ] 125 126 defines = [ "PERFETTO_IMPLEMENTATION" ] 127 128 if (build_with_chromium && is_android) { 129 # Included for __android_log_print 130 libs = [ "log" ] 131 } 132 133 include_dirs = [ ".." ] 134} 135 136# This config is propagated to embedders via libperfetto. It's also included in 137# the default_config above. 138config("public_config") { 139 include_dirs = [ 140 "../include", 141 142 # The below are needed due to generated protobuf headers including other 143 # headers with a path relative to the perfetto root. 144 "${root_gen_dir}/${perfetto_root_path}/protos", 145 ] 146 147 defines = [] 148 149 if (perfetto_build_with_android) { 150 defines += [ "PERFETTO_BUILD_WITH_ANDROID" ] 151 } else if (perfetto_build_with_embedder) { 152 defines += [ "PERFETTO_BUILD_WITH_EMBEDDER" ] 153 154 if (build_with_chromium) { 155 defines += [ "PERFETTO_BUILD_WITH_CHROMIUM" ] 156 157 if (is_component_build) { 158 defines += [ "PERFETTO_SHARED_LIBRARY" ] 159 } 160 } # if (build_with_chromium) 161 } # if (build_with_embedder) 162 163 if (perfetto_force_dlog == "on") { 164 defines += [ "PERFETTO_FORCE_DLOG=1" ] 165 } else if (perfetto_force_dlog == "off") { 166 defines += [ "PERFETTO_FORCE_DLOG=0" ] 167 } 168} 169 170# For now JsonCpp is supported only in standalone builds outside of Android or 171# Chromium. 172group("jsoncpp_deps") { 173 if (perfetto_build_standalone) { 174 public_configs = [ "//buildtools:jsoncpp_config" ] 175 public_deps = [ 176 "//buildtools:jsoncpp", 177 ] 178 } 179} 180 181group("zlib_deps") { 182 if (perfetto_build_standalone || perfetto_build_with_android) { 183 public_configs = [ "//buildtools:zlib_config" ] 184 public_deps = [ 185 "//buildtools:zlib", 186 ] 187 } 188} 189