blob: d9eed7638f9f22a7f1b7459f1cd760b621b5cafb [file] [log] [blame]
Dan Willemsen2e1591b2016-07-12 17:20:18 -07001//
2// Copyright (C) 2014 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "libbacktrace_common",
19
20 cflags: [
21 "-Wall",
22 "-Werror",
23 ],
Dan Willemsen2e1591b2016-07-12 17:20:18 -070024
Colin Crossda9bd592016-12-14 17:24:46 -080025 // The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists.
Dan Willemsen2e1591b2016-07-12 17:20:18 -070026 clang_cflags: ["-Wno-inline-asm"],
27
Dan Willemsen2e1591b2016-07-12 17:20:18 -070028 include_dirs: ["external/libunwind/include/tdep"],
29
Dan Willemsen2e1591b2016-07-12 17:20:18 -070030
31 target: {
Dan Willemsen2e1591b2016-07-12 17:20:18 -070032 darwin: {
33 enabled: false,
34 },
35 },
36
37 multilib: {
38 lib32: {
39 suffix: "32",
40 },
41 lib64: {
42 suffix: "64",
43 },
44 }
45}
46
47libbacktrace_sources = [
48 "Backtrace.cpp",
49 "BacktraceCurrent.cpp",
50 "BacktracePtrace.cpp",
51 "thread_utils.c",
52 "ThreadEntry.cpp",
Christopher Ferris6f3981c2017-07-27 09:29:18 -070053 "UnwindStack.cpp",
54 "UnwindStackMap.cpp",
Dan Willemsen2e1591b2016-07-12 17:20:18 -070055]
56
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070057cc_library_headers {
58 name: "libbacktrace_headers",
Steven Moreland4ad9d512017-04-13 21:01:40 -070059 vendor_available: true,
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070060 export_include_dirs: ["include"],
61}
62
Dan Willemsen2e1591b2016-07-12 17:20:18 -070063cc_library {
64 name: "libbacktrace",
Jiyong Parkb7d92c42017-08-23 13:25:21 +090065 vendor_available: false,
Justin Yun9ca92452017-07-31 15:41:10 +090066 vndk: {
67 enabled: true,
68 support_system_process: true,
69 },
Dan Willemsen2e1591b2016-07-12 17:20:18 -070070 defaults: ["libbacktrace_common"],
71 host_supported: true,
72
Josh Gaoe22701e2017-10-23 14:25:08 -070073 cflags: [
74 "-Wexit-time-destructors",
75 ],
76
Dan Willemsen2e1591b2016-07-12 17:20:18 -070077 srcs: [
78 "BacktraceMap.cpp",
79 ],
80
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070081 export_include_dirs: ["include"],
82
Dan Willemsen2e1591b2016-07-12 17:20:18 -070083 target: {
84 darwin: {
85 enabled: true,
86 },
Dan Willemsenbdddcab2017-10-03 14:17:31 -070087 linux: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -070088 srcs: libbacktrace_sources,
89
90 shared_libs: [
91 "libbase",
92 "liblog",
93 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -070094 "libunwindstack",
Dan Willemsene0cd1e02017-03-15 15:23:36 -070095 ],
96
97 static_libs: ["libcutils"],
98 },
Dan Willemsen2e1591b2016-07-12 17:20:18 -070099 android: {
Dan Willemsenbdddcab2017-10-03 14:17:31 -0700100 static_libs: ["libasync_safe"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700101 },
102 },
Christopher Ferris7d0aea92017-06-01 14:15:09 -0700103 whole_static_libs: ["libdemangle"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700104}
105
106cc_library_shared {
107 name: "libbacktrace_test",
108 defaults: ["libbacktrace_common"],
109 host_supported: true,
110 strip: {
111 none: true,
112 },
113 cflags: ["-O0"],
Christopher Ferris5ea2c1f2017-03-23 14:55:01 -0700114 srcs: ["backtrace_testlib.cpp"],
Yabin Cui5d991bc2016-11-15 17:47:09 -0800115
116 target: {
Dan Willemsenbdddcab2017-10-03 14:17:31 -0700117 linux: {
Yabin Cui5d991bc2016-11-15 17:47:09 -0800118 shared_libs: [
119 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700120 "libunwindstack",
Yabin Cui5d991bc2016-11-15 17:47:09 -0800121 ],
122 },
123 }
Colin Crossda9bd592016-12-14 17:24:46 -0800124}
125
126//-------------------------------------------------------------------------
127// The libbacktrace_offline static library.
128//-------------------------------------------------------------------------
129cc_library_static {
130 name: "libbacktrace_offline",
131 defaults: ["libbacktrace_common"],
132 host_supported: true,
133 srcs: ["BacktraceOffline.cpp"],
134
135 cflags: [
136 "-D__STDC_CONSTANT_MACROS",
137 "-D__STDC_LIMIT_MACROS",
138 "-D__STDC_FORMAT_MACROS",
139 ],
140
141 header_libs: ["llvm-headers"],
142
143 // Use shared libraries so their headers get included during build.
144 shared_libs = [
145 "libbase",
146 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700147 "libunwindstack",
Andreas Gampe8f0947c2017-07-03 13:02:33 -0700148 "libziparchive",
Colin Crossda9bd592016-12-14 17:24:46 -0800149 ],
150}
151
152//-------------------------------------------------------------------------
153// The backtrace_test executable.
154//-------------------------------------------------------------------------
155cc_test {
156 name: "backtrace_test",
157 defaults: ["libbacktrace_common"],
158 host_supported: true,
159 srcs: [
160 "backtrace_offline_test.cpp",
161 "backtrace_test.cpp",
162 "GetPss.cpp",
163 "thread_utils.c",
164 ],
165
166 cflags: [
167 "-fno-builtin",
168 "-O0",
169 "-g",
170 ],
171
172 shared_libs: [
173 "libbacktrace_test",
174 "libbacktrace",
175 "libbase",
176 "libcutils",
177 "liblog",
178 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700179 "libunwindstack",
Colin Crossda9bd592016-12-14 17:24:46 -0800180 ],
181
182 group_static_libs: true,
183
184 // Statically link LLVMlibraries to remove dependency on llvm shared library.
185 static_libs = [
186 "libbacktrace_offline",
187 "libLLVMObject",
188 "libLLVMBitReader",
189 "libLLVMMC",
190 "libLLVMMCParser",
191 "libLLVMCore",
192 "libLLVMSupport",
193
194 "libziparchive",
195 "libz",
196 ],
197
198 header_libs: ["llvm-headers"],
199
200 target: {
201 android: {
202 cflags: ["-DENABLE_PSS_TESTS"],
203 shared_libs: [
Colin Crossda9bd592016-12-14 17:24:46 -0800204 "libutils",
205 ],
206 },
Dan Willemsen48529332017-10-02 10:38:16 -0700207 linux_glibc: {
Colin Crossda9bd592016-12-14 17:24:46 -0800208 host_ldlibs: [
Colin Crossda9bd592016-12-14 17:24:46 -0800209 "-lncurses",
210 ],
211 static_libs: ["libutils"],
212 },
213 },
Christopher Ferris458cc662017-08-28 16:31:18 -0700214
215 data: [
216 "testdata/arm/*",
217 "testdata/arm64/*",
218 "testdata/x86/*",
219 "testdata/x86_64/*",
220 ],
Colin Crossda9bd592016-12-14 17:24:46 -0800221}
Christopher Ferris60521c72017-08-18 15:10:53 -0700222
223cc_benchmark {
224 name: "backtrace_benchmarks",
225 defaults: ["libbacktrace_common"],
226
227 srcs: [
228 "backtrace_benchmarks.cpp",
Christopher Ferrise3286732017-12-07 17:41:18 -0800229 "backtrace_read_benchmarks.cpp",
Christopher Ferris60521c72017-08-18 15:10:53 -0700230 ],
231
232 shared_libs: [
233 "libbacktrace",
234 "libbase",
Josh Gaob9670bb2017-10-25 15:12:24 -0700235 "libunwindstack",
Christopher Ferris60521c72017-08-18 15:10:53 -0700236 ],
237}