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