blob: 4a525be97a20cf3cf7f937539057126ce983eae1 [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",
60 export_include_dirs: ["include"],
61}
62
Dan Willemsen2e1591b2016-07-12 17:20:18 -070063cc_library {
64 name: "libbacktrace",
Steven Morelandbb11af82017-04-13 23:35:06 -070065 vendor_available: true,
Dan Willemsen2e1591b2016-07-12 17:20:18 -070066 defaults: ["libbacktrace_common"],
67 host_supported: true,
68
69 srcs: [
70 "BacktraceMap.cpp",
71 ],
72
Vijay Venkatraman8f2c28d2017-04-11 11:22:43 -070073 export_include_dirs: ["include"],
74
Dan Willemsen2e1591b2016-07-12 17:20:18 -070075 target: {
76 darwin: {
77 enabled: true,
78 },
79 linux: {
80 srcs: libbacktrace_sources,
81
82 shared_libs: [
83 "libbase",
84 "liblog",
85 "libunwind",
86 ],
87
88 static_libs: ["libcutils"],
Colin Cross53783b12016-10-20 10:39:51 -070089 host_ldlibs: ["-lrt"],
Dan Willemsen2e1591b2016-07-12 17:20:18 -070090 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070091 linux_bionic: {
92 enabled: true,
93 srcs: libbacktrace_sources,
94
95 shared_libs: [
96 "libbase",
97 "liblog",
98 "libunwind",
99 ],
100
101 static_libs: ["libcutils"],
102 },
Dan Willemsen2e1591b2016-07-12 17:20:18 -0700103 android: {
104 srcs: libbacktrace_sources,
105
106 shared_libs: [
107 "libbase",
108 "liblog",
109 "libunwind",
110 ],
111
112 static_libs: ["libcutils"],
113 },
114 },
115}
116
117cc_library_shared {
118 name: "libbacktrace_test",
119 defaults: ["libbacktrace_common"],
120 host_supported: true,
121 strip: {
122 none: true,
123 },
124 cflags: ["-O0"],
Christopher Ferris5ea2c1f2017-03-23 14:55:01 -0700125 srcs: ["backtrace_testlib.cpp"],
Yabin Cui5d991bc2016-11-15 17:47:09 -0800126
127 target: {
128 linux: {
129 shared_libs: [
130 "libunwind",
131 ],
132 },
133 android: {
134 shared_libs: [
135 "libunwind",
136 ],
137 },
138 }
Colin Crossda9bd592016-12-14 17:24:46 -0800139}
140
141//-------------------------------------------------------------------------
142// The libbacktrace_offline static library.
143//-------------------------------------------------------------------------
144cc_library_static {
145 name: "libbacktrace_offline",
146 defaults: ["libbacktrace_common"],
147 host_supported: true,
148 srcs: ["BacktraceOffline.cpp"],
149
150 cflags: [
151 "-D__STDC_CONSTANT_MACROS",
152 "-D__STDC_LIMIT_MACROS",
153 "-D__STDC_FORMAT_MACROS",
154 ],
155
156 header_libs: ["llvm-headers"],
157
158 // Use shared libraries so their headers get included during build.
159 shared_libs = [
160 "libbase",
161 "libunwind",
162 ],
163}
164
165//-------------------------------------------------------------------------
166// The backtrace_test executable.
167//-------------------------------------------------------------------------
168cc_test {
169 name: "backtrace_test",
170 defaults: ["libbacktrace_common"],
171 host_supported: true,
172 srcs: [
173 "backtrace_offline_test.cpp",
174 "backtrace_test.cpp",
175 "GetPss.cpp",
176 "thread_utils.c",
177 ],
178
179 cflags: [
180 "-fno-builtin",
181 "-O0",
182 "-g",
183 ],
184
185 shared_libs: [
186 "libbacktrace_test",
187 "libbacktrace",
188 "libbase",
189 "libcutils",
190 "liblog",
191 "libunwind",
192 ],
193
194 group_static_libs: true,
195
196 // Statically link LLVMlibraries to remove dependency on llvm shared library.
197 static_libs = [
198 "libbacktrace_offline",
199 "libLLVMObject",
200 "libLLVMBitReader",
201 "libLLVMMC",
202 "libLLVMMCParser",
203 "libLLVMCore",
204 "libLLVMSupport",
205
206 "libziparchive",
207 "libz",
208 ],
209
210 header_libs: ["llvm-headers"],
211
212 target: {
213 android: {
214 cflags: ["-DENABLE_PSS_TESTS"],
215 shared_libs: [
216 "libdl",
217 "libutils",
218 ],
219 },
220 linux: {
221 host_ldlibs: [
222 "-lpthread",
223 "-lrt",
224 "-ldl",
225 "-lncurses",
226 ],
227 static_libs: ["libutils"],
228 },
229 },
230}