blob: 7d4bf5e58267806fcddfc9824af83b40ec9d6343 [file] [log] [blame]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -08001# 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")
Primiano Tucci4c5efa42018-10-23 13:15:13 +010016import("proto_library.gni")
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080017
Eric Seckler57c89d92018-10-26 15:11:55 +010018# Used by base/gtest_prod_util.h for the FRIEND_TEST_* macros. Note that other
19# production targets (i.e. testonly == false) should use base/gtest_prod_util.h
20# instead.
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000021group("gtest_prod_config") {
Primiano Tucci4c5efa42018-10-23 13:15:13 +010022 if (perfetto_build_standalone || perfetto_build_with_android) {
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000023 public_configs = [ "//buildtools:googletest_prod_config" ]
24 } else {
25 public_configs = [ ":gtest_config" ]
26 }
27}
28
29config("gtest_config") {
Primiano Tucci4c5efa42018-10-23 13:15:13 +010030 if (perfetto_build_with_embedder) {
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000031 include_dirs = [ "//testing/gtest/include" ]
32 }
33}
34
Eric Seckler57c89d92018-10-26 15:11:55 +010035config("gmock_config") {
36 if (perfetto_build_with_embedder) {
37 include_dirs = [ "//testing/gmock/include" ]
38 }
39}
40
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080041group("gtest_deps") {
42 testonly = true
43
Eric Seckler57c89d92018-10-26 15:11:55 +010044 public_configs = [
45 ":gtest_config",
46 ":gmock_config",
47 ]
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000048
Primiano Tucci4c5efa42018-10-23 13:15:13 +010049 if (perfetto_build_standalone || perfetto_build_with_android) {
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080050 public_deps = [
51 "//buildtools:gmock",
52 "//buildtools:gtest",
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080053 ]
54 } else {
55 public_deps = [
56 "//testing/gmock",
57 "//testing/gtest",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000058 ]
59 }
60}
61
62group("gtest_main") {
63 testonly = true
64
Primiano Tucci4c5efa42018-10-23 13:15:13 +010065 if (perfetto_build_standalone || perfetto_build_with_android) {
Florian Mayerd8bd81b2018-01-25 12:49:15 +000066 public_deps = [
67 "//buildtools:gtest_main",
68 ]
Eric Secklera6ba1792019-01-02 12:51:00 +000069 } else if (build_with_chromium) {
70 public_deps = [
71 "//base/test:run_all_unittests",
72 ]
Florian Mayerd8bd81b2018-01-25 12:49:15 +000073 } else {
74 public_deps = [
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080075 "//testing/gtest:gtest_main",
76 ]
77 }
78}
79
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000080# protoc compiler library, for building protoc plugins on the host.
81if (current_toolchain == host_toolchain) {
82 group("protoc_lib_deps") {
Primiano Tucci4c5efa42018-10-23 13:15:13 +010083 public_deps = [
84 "${perfetto_protobuf_target_prefix}:protoc_lib",
85 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080086 }
87}
88
89group("protobuf_full_deps") {
Primiano Tucci20dc8f72018-10-23 12:28:29 +010090 testonly = true
Primiano Tucci4c5efa42018-10-23 13:15:13 +010091 public_deps = [
92 "${perfetto_protobuf_target_prefix}:protobuf_full",
93 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080094}
95
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000096# All targets should depend on this target to inherit the right flags and
97# include directories.
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080098group("default_deps") {
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000099 public_configs = [ ":default_config" ]
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100100 if (perfetto_build_standalone || perfetto_build_with_android) {
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800101 public_deps = [
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000102 "//gn/standalone/libc++:deps",
103 "//gn/standalone/sanitizers:deps",
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800104 ]
105 }
106}
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000107
108config("default_config") {
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700109 defines = [ "PERFETTO_IMPLEMENTATION" ]
110
Oystein Eftevaagf7a0d7e2018-01-12 13:02:43 -0800111 if (build_with_chromium) {
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700112 if (is_component_build) {
113 defines += [ "PERFETTO_SHARED_LIBRARY" ]
114 }
115
116 defines += [ "PERFETTO_BUILD_WITH_CHROMIUM" ]
Oystein Eftevaagf7a0d7e2018-01-12 13:02:43 -0800117
118 if (is_android) {
119 # Included for __android_log_print
120 libs = [ "log" ]
121 }
122 }
123
Sami Kyostilab16cb472018-11-13 16:10:02 +0000124 # Disable debug log spam if we're embedded in a third-party project.
125 if (!perfetto_build_with_embedder) {
126 defines += [ "PERFETTO_ENABLE_DLOG" ]
127 }
128
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000129 include_dirs = [
130 "..",
131 "../include",
132 ]
133}
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800134
135config("public_config") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000136 include_dirs = [
137 "../include",
138
139 # The below are needed due to generated protobuf headers including other
140 # headers with a path relative to the perfetto root.
141 "${root_gen_dir}/${perfetto_root_path}/protos",
142 ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800143}
Florian Mayer3a3974e2018-01-24 11:37:29 +0000144
Primiano Tucci0d72a312018-08-07 14:42:45 +0100145# For now JsonCpp is supported only in standalone builds outside of Android or
146# Chromium.
147group("jsoncpp_deps") {
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100148 if (perfetto_build_standalone) {
Primiano Tucci0d72a312018-08-07 14:42:45 +0100149 public_configs = [ "//buildtools:jsoncpp_config" ]
150 public_deps = [
151 "//buildtools:jsoncpp",
152 ]
153 }
154}