blob: 285aa6edf63be8978e9d25326806ba86673dd5a1 [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
113 static_libs: ["libcutils"],
114 },
115 },
116}
117
118cc_library_shared {
119 name: "libbacktrace_test",
120 defaults: ["libbacktrace_common"],
121 host_supported: true,
122 strip: {
123 none: true,
124 },
125 cflags: ["-O0"],
Christopher Ferris5ea2c1f2017-03-23 14:55:01 -0700126 srcs: ["backtrace_testlib.cpp"],
Yabin Cui5d991bc2016-11-15 17:47:09 -0800127
128 target: {
129 linux: {
130 shared_libs: [
131 "libunwind",
132 ],
133 },
134 android: {
135 shared_libs: [
136 "libunwind",
137 ],
138 },
139 }
Colin Crossda9bd592016-12-14 17:24:46 -0800140}
141
142//-------------------------------------------------------------------------
143// The libbacktrace_offline static library.
144//-------------------------------------------------------------------------
145cc_library_static {
146 name: "libbacktrace_offline",
147 defaults: ["libbacktrace_common"],
148 host_supported: true,
149 srcs: ["BacktraceOffline.cpp"],
150
151 cflags: [
152 "-D__STDC_CONSTANT_MACROS",
153 "-D__STDC_LIMIT_MACROS",
154 "-D__STDC_FORMAT_MACROS",
155 ],
156
157 header_libs: ["llvm-headers"],
158
159 // Use shared libraries so their headers get included during build.
160 shared_libs = [
161 "libbase",
162 "libunwind",
163 ],
164}
165
166//-------------------------------------------------------------------------
167// The backtrace_test executable.
168//-------------------------------------------------------------------------
169cc_test {
170 name: "backtrace_test",
171 defaults: ["libbacktrace_common"],
172 host_supported: true,
173 srcs: [
174 "backtrace_offline_test.cpp",
175 "backtrace_test.cpp",
176 "GetPss.cpp",
177 "thread_utils.c",
178 ],
179
180 cflags: [
181 "-fno-builtin",
182 "-O0",
183 "-g",
184 ],
185
186 shared_libs: [
187 "libbacktrace_test",
188 "libbacktrace",
189 "libbase",
190 "libcutils",
191 "liblog",
192 "libunwind",
193 ],
194
195 group_static_libs: true,
196
197 // Statically link LLVMlibraries to remove dependency on llvm shared library.
198 static_libs = [
199 "libbacktrace_offline",
200 "libLLVMObject",
201 "libLLVMBitReader",
202 "libLLVMMC",
203 "libLLVMMCParser",
204 "libLLVMCore",
205 "libLLVMSupport",
206
207 "libziparchive",
208 "libz",
209 ],
210
211 header_libs: ["llvm-headers"],
212
213 target: {
214 android: {
215 cflags: ["-DENABLE_PSS_TESTS"],
216 shared_libs: [
217 "libdl",
218 "libutils",
219 ],
220 },
221 linux: {
222 host_ldlibs: [
223 "-lpthread",
224 "-lrt",
225 "-ldl",
226 "-lncurses",
227 ],
228 static_libs: ["libutils"],
229 },
230 },
231}