blob: 7eefc95afbc4c22ac9d40a383df3fffe196b0413 [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",
56]
57
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070058cc_library_headers {
59 name: "libbacktrace_headers",
Steven Moreland4ad9d512017-04-13 21:01:40 -070060 vendor_available: true,
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070061 export_include_dirs: ["include"],
62}
63
Dan Willemsen2e1591b2016-07-12 17:20:18 -070064cc_library {
65 name: "libbacktrace",
Steven Morelandbb11af82017-04-13 23:35:06 -070066 vendor_available: true,
Justin Yunaeb68e82017-07-31 15:41:10 +090067 vndk: {
68 enabled: true,
69 support_system_process: true,
70 },
Dan Willemsen2e1591b2016-07-12 17:20:18 -070071 defaults: ["libbacktrace_common"],
72 host_supported: true,
73
74 srcs: [
75 "BacktraceMap.cpp",
76 ],
77
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070078 export_include_dirs: ["include"],
79
Dan Willemsen2e1591b2016-07-12 17:20:18 -070080 target: {
81 darwin: {
82 enabled: true,
83 },
84 linux: {
85 srcs: libbacktrace_sources,
86
87 shared_libs: [
88 "libbase",
89 "liblog",
90 "libunwind",
91 ],
92
93 static_libs: ["libcutils"],
Colin Cross53783b12016-10-20 10:39:51 -070094 host_ldlibs: ["-lrt"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -070095 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070096 linux_bionic: {
97 enabled: true,
98 srcs: libbacktrace_sources,
99
100 shared_libs: [
101 "libbase",
102 "liblog",
103 "libunwind",
104 ],
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",
115 ],
116
Christopher Ferrisf30a8102017-05-03 17:22:24 -0700117 static_libs: ["libasync_safe", "libcutils"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700118 },
119 },
Christopher Ferris7d0aea92017-06-01 14:15:09 -0700120 whole_static_libs: ["libdemangle"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700121}
122
123cc_library_shared {
124 name: "libbacktrace_test",
125 defaults: ["libbacktrace_common"],
126 host_supported: true,
127 strip: {
128 none: true,
129 },
130 cflags: ["-O0"],
Christopher Ferris5ea2c1f2017-03-23 14:55:01 -0700131 srcs: ["backtrace_testlib.cpp"],
Yabin Cui5d991bc2016-11-15 17:47:09 -0800132
133 target: {
134 linux: {
135 shared_libs: [
136 "libunwind",
137 ],
138 },
139 android: {
140 shared_libs: [
141 "libunwind",
142 ],
143 },
144 }
Colin Crossda9bd592016-12-14 17:24:46 -0800145}
146
147//-------------------------------------------------------------------------
148// The libbacktrace_offline static library.
149//-------------------------------------------------------------------------
150cc_library_static {
151 name: "libbacktrace_offline",
152 defaults: ["libbacktrace_common"],
153 host_supported: true,
154 srcs: ["BacktraceOffline.cpp"],
155
156 cflags: [
157 "-D__STDC_CONSTANT_MACROS",
158 "-D__STDC_LIMIT_MACROS",
159 "-D__STDC_FORMAT_MACROS",
160 ],
161
162 header_libs: ["llvm-headers"],
163
164 // Use shared libraries so their headers get included during build.
165 shared_libs = [
166 "libbase",
167 "libunwind",
Andreas Gampe8f0947c2017-07-03 13:02:33 -0700168 "libziparchive",
Colin Crossda9bd592016-12-14 17:24:46 -0800169 ],
170}
171
172//-------------------------------------------------------------------------
173// The backtrace_test executable.
174//-------------------------------------------------------------------------
175cc_test {
176 name: "backtrace_test",
177 defaults: ["libbacktrace_common"],
178 host_supported: true,
179 srcs: [
180 "backtrace_offline_test.cpp",
181 "backtrace_test.cpp",
182 "GetPss.cpp",
183 "thread_utils.c",
184 ],
185
186 cflags: [
187 "-fno-builtin",
188 "-O0",
189 "-g",
190 ],
191
192 shared_libs: [
193 "libbacktrace_test",
194 "libbacktrace",
195 "libbase",
196 "libcutils",
197 "liblog",
198 "libunwind",
199 ],
200
201 group_static_libs: true,
202
203 // Statically link LLVMlibraries to remove dependency on llvm shared library.
204 static_libs = [
205 "libbacktrace_offline",
206 "libLLVMObject",
207 "libLLVMBitReader",
208 "libLLVMMC",
209 "libLLVMMCParser",
210 "libLLVMCore",
211 "libLLVMSupport",
212
213 "libziparchive",
214 "libz",
215 ],
216
217 header_libs: ["llvm-headers"],
218
219 target: {
220 android: {
221 cflags: ["-DENABLE_PSS_TESTS"],
222 shared_libs: [
223 "libdl",
224 "libutils",
225 ],
226 },
227 linux: {
228 host_ldlibs: [
229 "-lpthread",
230 "-lrt",
231 "-ldl",
232 "-lncurses",
233 ],
234 static_libs: ["libutils"],
235 },
236 },
237}