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