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