blob: 03bd12824da012281fa76ca63b01995cf76669ae [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",
53 "UnwindCurrent.cpp",
54 "UnwindMap.cpp",
55 "UnwindPtrace.cpp",
Christopher Ferris6f3981c2017-07-27 09:29:18 -070056 "UnwindStack.cpp",
57 "UnwindStackMap.cpp",
Dan Willemsen2e1591b2016-07-12 17:20:18 -070058]
59
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070060cc_library_headers {
61 name: "libbacktrace_headers",
Steven Moreland4ad9d512017-04-13 21:01:40 -070062 vendor_available: true,
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070063 export_include_dirs: ["include"],
64}
65
Dan Willemsen2e1591b2016-07-12 17:20:18 -070066cc_library {
67 name: "libbacktrace",
Steven Morelandbb11af82017-04-13 23:35:06 -070068 vendor_available: true,
Justin Yun9ca92452017-07-31 15:41:10 +090069 vndk: {
70 enabled: true,
71 support_system_process: true,
72 },
Dan Willemsen2e1591b2016-07-12 17:20:18 -070073 defaults: ["libbacktrace_common"],
74 host_supported: true,
75
76 srcs: [
77 "BacktraceMap.cpp",
78 ],
79
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070080 export_include_dirs: ["include"],
81
Dan Willemsen2e1591b2016-07-12 17:20:18 -070082 target: {
83 darwin: {
84 enabled: true,
85 },
Dan Willemsenbdddcab2017-10-03 14:17:31 -070086 linux: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -070087 srcs: libbacktrace_sources,
88
89 shared_libs: [
90 "libbase",
91 "liblog",
92 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -070093 "libunwindstack",
Dan Willemsene0cd1e02017-03-15 15:23:36 -070094 ],
95
96 static_libs: ["libcutils"],
97 },
Dan Willemsen2e1591b2016-07-12 17:20:18 -070098 android: {
Dan Willemsenbdddcab2017-10-03 14:17:31 -070099 static_libs: ["libasync_safe"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700100 },
101 },
Christopher Ferris7d0aea92017-06-01 14:15:09 -0700102 whole_static_libs: ["libdemangle"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700103}
104
105cc_library_shared {
106 name: "libbacktrace_test",
107 defaults: ["libbacktrace_common"],
108 host_supported: true,
109 strip: {
110 none: true,
111 },
112 cflags: ["-O0"],
Christopher Ferris5ea2c1f2017-03-23 14:55:01 -0700113 srcs: ["backtrace_testlib.cpp"],
Yabin Cui5d991bc2016-11-15 17:47:09 -0800114
115 target: {
Dan Willemsenbdddcab2017-10-03 14:17:31 -0700116 linux: {
Yabin Cui5d991bc2016-11-15 17:47:09 -0800117 shared_libs: [
118 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700119 "libunwindstack",
Yabin Cui5d991bc2016-11-15 17:47:09 -0800120 ],
121 },
122 }
Colin Crossda9bd592016-12-14 17:24:46 -0800123}
124
125//-------------------------------------------------------------------------
126// The libbacktrace_offline static library.
127//-------------------------------------------------------------------------
128cc_library_static {
129 name: "libbacktrace_offline",
130 defaults: ["libbacktrace_common"],
131 host_supported: true,
132 srcs: ["BacktraceOffline.cpp"],
133
134 cflags: [
135 "-D__STDC_CONSTANT_MACROS",
136 "-D__STDC_LIMIT_MACROS",
137 "-D__STDC_FORMAT_MACROS",
138 ],
139
140 header_libs: ["llvm-headers"],
141
142 // Use shared libraries so their headers get included during build.
143 shared_libs = [
144 "libbase",
145 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700146 "libunwindstack",
Andreas Gampe8f0947c2017-07-03 13:02:33 -0700147 "libziparchive",
Colin Crossda9bd592016-12-14 17:24:46 -0800148 ],
149}
150
151//-------------------------------------------------------------------------
152// The backtrace_test executable.
153//-------------------------------------------------------------------------
154cc_test {
155 name: "backtrace_test",
156 defaults: ["libbacktrace_common"],
157 host_supported: true,
158 srcs: [
159 "backtrace_offline_test.cpp",
160 "backtrace_test.cpp",
161 "GetPss.cpp",
162 "thread_utils.c",
163 ],
164
165 cflags: [
166 "-fno-builtin",
167 "-O0",
168 "-g",
169 ],
170
171 shared_libs: [
172 "libbacktrace_test",
173 "libbacktrace",
174 "libbase",
175 "libcutils",
176 "liblog",
177 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700178 "libunwindstack",
Colin Crossda9bd592016-12-14 17:24:46 -0800179 ],
180
181 group_static_libs: true,
182
183 // Statically link LLVMlibraries to remove dependency on llvm shared library.
184 static_libs = [
185 "libbacktrace_offline",
186 "libLLVMObject",
187 "libLLVMBitReader",
188 "libLLVMMC",
189 "libLLVMMCParser",
190 "libLLVMCore",
191 "libLLVMSupport",
192
193 "libziparchive",
194 "libz",
195 ],
196
197 header_libs: ["llvm-headers"],
198
199 target: {
200 android: {
201 cflags: ["-DENABLE_PSS_TESTS"],
202 shared_libs: [
Colin Crossda9bd592016-12-14 17:24:46 -0800203 "libutils",
204 ],
205 },
Dan Willemsen48529332017-10-02 10:38:16 -0700206 linux_glibc: {
Colin Crossda9bd592016-12-14 17:24:46 -0800207 host_ldlibs: [
Colin Crossda9bd592016-12-14 17:24:46 -0800208 "-lncurses",
209 ],
210 static_libs: ["libutils"],
211 },
212 },
Christopher Ferris458cc662017-08-28 16:31:18 -0700213
214 data: [
215 "testdata/arm/*",
216 "testdata/arm64/*",
217 "testdata/x86/*",
218 "testdata/x86_64/*",
219 ],
Colin Crossda9bd592016-12-14 17:24:46 -0800220}
Christopher Ferris60521c72017-08-18 15:10:53 -0700221
222cc_benchmark {
223 name: "backtrace_benchmarks",
224 defaults: ["libbacktrace_common"],
225
226 srcs: [
227 "backtrace_benchmarks.cpp",
228 ],
229
230 shared_libs: [
231 "libbacktrace",
232 "libbase",
233 ],
234}