blob: c58d7773357e750daebad4d6898d0b64976438f4 [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,
Dan Willemsen2e1591b2016-07-12 17:20:18 -070069 defaults: ["libbacktrace_common"],
70 host_supported: true,
71
72 srcs: [
73 "BacktraceMap.cpp",
74 ],
75
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070076 export_include_dirs: ["include"],
77
Dan Willemsen2e1591b2016-07-12 17:20:18 -070078 target: {
79 darwin: {
80 enabled: true,
81 },
82 linux: {
83 srcs: libbacktrace_sources,
84
85 shared_libs: [
86 "libbase",
87 "liblog",
88 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -070089 "libunwindstack",
Dan Willemsen2e1591b2016-07-12 17:20:18 -070090 ],
91
92 static_libs: ["libcutils"],
Colin Cross53783b12016-10-20 10:39:51 -070093 host_ldlibs: ["-lrt"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -070094 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070095 linux_bionic: {
96 enabled: true,
97 srcs: libbacktrace_sources,
98
99 shared_libs: [
100 "libbase",
101 "liblog",
102 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700103 "libunwindstack",
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700104 ],
105
106 static_libs: ["libcutils"],
107 },
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700108 android: {
109 srcs: libbacktrace_sources,
110
111 shared_libs: [
112 "libbase",
113 "liblog",
114 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700115 "libunwindstack",
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700116 ],
117
Christopher Ferrisf30a8102017-05-03 17:22:24 -0700118 static_libs: ["libasync_safe", "libcutils"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700119 },
120 },
Christopher Ferris7d0aea92017-06-01 14:15:09 -0700121 whole_static_libs: ["libdemangle"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700122}
123
124cc_library_shared {
125 name: "libbacktrace_test",
126 defaults: ["libbacktrace_common"],
127 host_supported: true,
128 strip: {
129 none: true,
130 },
131 cflags: ["-O0"],
Christopher Ferris5ea2c1f2017-03-23 14:55:01 -0700132 srcs: ["backtrace_testlib.cpp"],
Yabin Cui5d991bc2016-11-15 17:47:09 -0800133
134 target: {
135 linux: {
136 shared_libs: [
137 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700138 "libunwindstack",
Yabin Cui5d991bc2016-11-15 17:47:09 -0800139 ],
140 },
141 android: {
142 shared_libs: [
143 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700144 "libunwindstack",
Yabin Cui5d991bc2016-11-15 17:47:09 -0800145 ],
146 },
147 }
Colin Crossda9bd592016-12-14 17:24:46 -0800148}
149
150//-------------------------------------------------------------------------
151// The libbacktrace_offline static library.
152//-------------------------------------------------------------------------
153cc_library_static {
154 name: "libbacktrace_offline",
155 defaults: ["libbacktrace_common"],
156 host_supported: true,
157 srcs: ["BacktraceOffline.cpp"],
158
159 cflags: [
160 "-D__STDC_CONSTANT_MACROS",
161 "-D__STDC_LIMIT_MACROS",
162 "-D__STDC_FORMAT_MACROS",
163 ],
164
165 header_libs: ["llvm-headers"],
166
167 // Use shared libraries so their headers get included during build.
168 shared_libs = [
169 "libbase",
170 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700171 "libunwindstack",
Andreas Gampe8f0947c2017-07-03 13:02:33 -0700172 "libziparchive",
Colin Crossda9bd592016-12-14 17:24:46 -0800173 ],
174}
175
176//-------------------------------------------------------------------------
177// The backtrace_test executable.
178//-------------------------------------------------------------------------
179cc_test {
180 name: "backtrace_test",
181 defaults: ["libbacktrace_common"],
182 host_supported: true,
183 srcs: [
184 "backtrace_offline_test.cpp",
185 "backtrace_test.cpp",
186 "GetPss.cpp",
187 "thread_utils.c",
188 ],
189
190 cflags: [
191 "-fno-builtin",
192 "-O0",
193 "-g",
194 ],
195
196 shared_libs: [
197 "libbacktrace_test",
198 "libbacktrace",
199 "libbase",
200 "libcutils",
201 "liblog",
202 "libunwind",
Christopher Ferris6f3981c2017-07-27 09:29:18 -0700203 "libunwindstack",
Colin Crossda9bd592016-12-14 17:24:46 -0800204 ],
205
206 group_static_libs: true,
207
208 // Statically link LLVMlibraries to remove dependency on llvm shared library.
209 static_libs = [
210 "libbacktrace_offline",
211 "libLLVMObject",
212 "libLLVMBitReader",
213 "libLLVMMC",
214 "libLLVMMCParser",
215 "libLLVMCore",
216 "libLLVMSupport",
217
218 "libziparchive",
219 "libz",
220 ],
221
222 header_libs: ["llvm-headers"],
223
224 target: {
225 android: {
226 cflags: ["-DENABLE_PSS_TESTS"],
227 shared_libs: [
228 "libdl",
229 "libutils",
230 ],
231 },
232 linux: {
233 host_ldlibs: [
234 "-lpthread",
235 "-lrt",
236 "-ldl",
237 "-lncurses",
238 ],
239 static_libs: ["libutils"],
240 },
241 },
242}