Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 1 | // |
| 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 | |
| 17 | cc_defaults { |
| 18 | name: "libbacktrace_common", |
| 19 | |
| 20 | cflags: [ |
| 21 | "-Wall", |
| 22 | "-Werror", |
| 23 | ], |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 24 | |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 25 | // The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists. |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 26 | clang_cflags: ["-Wno-inline-asm"], |
| 27 | |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 28 | include_dirs: ["external/libunwind/include/tdep"], |
| 29 | |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 30 | |
| 31 | target: { |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 32 | darwin: { |
| 33 | enabled: false, |
| 34 | }, |
| 35 | }, |
| 36 | |
| 37 | multilib: { |
| 38 | lib32: { |
| 39 | suffix: "32", |
| 40 | }, |
| 41 | lib64: { |
| 42 | suffix: "64", |
| 43 | }, |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | libbacktrace_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", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 56 | "UnwindStack.cpp", |
| 57 | "UnwindStackMap.cpp", |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 58 | ] |
| 59 | |
Vijay Venkatraman | 8f2c28d | 2017-04-11 11:22:43 -0700 | [diff] [blame] | 60 | cc_library_headers { |
| 61 | name: "libbacktrace_headers", |
Steven Moreland | 4ad9d51 | 2017-04-13 21:01:40 -0700 | [diff] [blame] | 62 | vendor_available: true, |
Vijay Venkatraman | 8f2c28d | 2017-04-11 11:22:43 -0700 | [diff] [blame] | 63 | export_include_dirs: ["include"], |
| 64 | } |
| 65 | |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 66 | cc_library { |
| 67 | name: "libbacktrace", |
Jiyong Park | b7d92c4 | 2017-08-23 13:25:21 +0900 | [diff] [blame^] | 68 | vendor_available: false, |
Justin Yun | 9ca9245 | 2017-07-31 15:41:10 +0900 | [diff] [blame] | 69 | vndk: { |
| 70 | enabled: true, |
| 71 | support_system_process: true, |
| 72 | }, |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 73 | defaults: ["libbacktrace_common"], |
| 74 | host_supported: true, |
| 75 | |
| 76 | srcs: [ |
| 77 | "BacktraceMap.cpp", |
| 78 | ], |
| 79 | |
Vijay Venkatraman | 8f2c28d | 2017-04-11 11:22:43 -0700 | [diff] [blame] | 80 | export_include_dirs: ["include"], |
| 81 | |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 82 | target: { |
| 83 | darwin: { |
| 84 | enabled: true, |
| 85 | }, |
Dan Willemsen | 4852933 | 2017-10-02 10:38:16 -0700 | [diff] [blame] | 86 | linux_glibc: { |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 87 | srcs: libbacktrace_sources, |
| 88 | |
| 89 | shared_libs: [ |
| 90 | "libbase", |
| 91 | "liblog", |
| 92 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 93 | "libunwindstack", |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 94 | ], |
| 95 | |
| 96 | static_libs: ["libcutils"], |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 97 | }, |
Dan Willemsen | e0cd1e0 | 2017-03-15 15:23:36 -0700 | [diff] [blame] | 98 | linux_bionic: { |
| 99 | enabled: true, |
| 100 | srcs: libbacktrace_sources, |
| 101 | |
| 102 | shared_libs: [ |
| 103 | "libbase", |
| 104 | "liblog", |
| 105 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 106 | "libunwindstack", |
Dan Willemsen | e0cd1e0 | 2017-03-15 15:23:36 -0700 | [diff] [blame] | 107 | ], |
| 108 | |
| 109 | static_libs: ["libcutils"], |
| 110 | }, |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 111 | android: { |
| 112 | srcs: libbacktrace_sources, |
| 113 | |
| 114 | shared_libs: [ |
| 115 | "libbase", |
| 116 | "liblog", |
| 117 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 118 | "libunwindstack", |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 119 | ], |
| 120 | |
Christopher Ferris | f30a810 | 2017-05-03 17:22:24 -0700 | [diff] [blame] | 121 | static_libs: ["libasync_safe", "libcutils"], |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 122 | }, |
| 123 | }, |
Christopher Ferris | 7d0aea9 | 2017-06-01 14:15:09 -0700 | [diff] [blame] | 124 | whole_static_libs: ["libdemangle"], |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | cc_library_shared { |
| 128 | name: "libbacktrace_test", |
| 129 | defaults: ["libbacktrace_common"], |
| 130 | host_supported: true, |
| 131 | strip: { |
| 132 | none: true, |
| 133 | }, |
| 134 | cflags: ["-O0"], |
Christopher Ferris | 5ea2c1f | 2017-03-23 14:55:01 -0700 | [diff] [blame] | 135 | srcs: ["backtrace_testlib.cpp"], |
Yabin Cui | 5d991bc | 2016-11-15 17:47:09 -0800 | [diff] [blame] | 136 | |
| 137 | target: { |
Dan Willemsen | 4852933 | 2017-10-02 10:38:16 -0700 | [diff] [blame] | 138 | linux_glibc: { |
Yabin Cui | 5d991bc | 2016-11-15 17:47:09 -0800 | [diff] [blame] | 139 | shared_libs: [ |
| 140 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 141 | "libunwindstack", |
Yabin Cui | 5d991bc | 2016-11-15 17:47:09 -0800 | [diff] [blame] | 142 | ], |
| 143 | }, |
| 144 | android: { |
| 145 | shared_libs: [ |
| 146 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 147 | "libunwindstack", |
Yabin Cui | 5d991bc | 2016-11-15 17:47:09 -0800 | [diff] [blame] | 148 | ], |
| 149 | }, |
| 150 | } |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | //------------------------------------------------------------------------- |
| 154 | // The libbacktrace_offline static library. |
| 155 | //------------------------------------------------------------------------- |
| 156 | cc_library_static { |
| 157 | name: "libbacktrace_offline", |
| 158 | defaults: ["libbacktrace_common"], |
| 159 | host_supported: true, |
| 160 | srcs: ["BacktraceOffline.cpp"], |
| 161 | |
| 162 | cflags: [ |
| 163 | "-D__STDC_CONSTANT_MACROS", |
| 164 | "-D__STDC_LIMIT_MACROS", |
| 165 | "-D__STDC_FORMAT_MACROS", |
| 166 | ], |
| 167 | |
| 168 | header_libs: ["llvm-headers"], |
| 169 | |
| 170 | // Use shared libraries so their headers get included during build. |
| 171 | shared_libs = [ |
| 172 | "libbase", |
| 173 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 174 | "libunwindstack", |
Andreas Gampe | 8f0947c | 2017-07-03 13:02:33 -0700 | [diff] [blame] | 175 | "libziparchive", |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 176 | ], |
| 177 | } |
| 178 | |
| 179 | //------------------------------------------------------------------------- |
| 180 | // The backtrace_test executable. |
| 181 | //------------------------------------------------------------------------- |
| 182 | cc_test { |
| 183 | name: "backtrace_test", |
| 184 | defaults: ["libbacktrace_common"], |
| 185 | host_supported: true, |
| 186 | srcs: [ |
| 187 | "backtrace_offline_test.cpp", |
| 188 | "backtrace_test.cpp", |
| 189 | "GetPss.cpp", |
| 190 | "thread_utils.c", |
| 191 | ], |
| 192 | |
| 193 | cflags: [ |
| 194 | "-fno-builtin", |
| 195 | "-O0", |
| 196 | "-g", |
| 197 | ], |
| 198 | |
| 199 | shared_libs: [ |
| 200 | "libbacktrace_test", |
| 201 | "libbacktrace", |
| 202 | "libbase", |
| 203 | "libcutils", |
| 204 | "liblog", |
| 205 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 206 | "libunwindstack", |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 207 | ], |
| 208 | |
| 209 | group_static_libs: true, |
| 210 | |
| 211 | // Statically link LLVMlibraries to remove dependency on llvm shared library. |
| 212 | static_libs = [ |
| 213 | "libbacktrace_offline", |
| 214 | "libLLVMObject", |
| 215 | "libLLVMBitReader", |
| 216 | "libLLVMMC", |
| 217 | "libLLVMMCParser", |
| 218 | "libLLVMCore", |
| 219 | "libLLVMSupport", |
| 220 | |
| 221 | "libziparchive", |
| 222 | "libz", |
| 223 | ], |
| 224 | |
| 225 | header_libs: ["llvm-headers"], |
| 226 | |
| 227 | target: { |
| 228 | android: { |
| 229 | cflags: ["-DENABLE_PSS_TESTS"], |
| 230 | shared_libs: [ |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 231 | "libutils", |
| 232 | ], |
| 233 | }, |
Dan Willemsen | 4852933 | 2017-10-02 10:38:16 -0700 | [diff] [blame] | 234 | linux_glibc: { |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 235 | host_ldlibs: [ |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 236 | "-lncurses", |
| 237 | ], |
| 238 | static_libs: ["libutils"], |
| 239 | }, |
| 240 | }, |
Christopher Ferris | 458cc66 | 2017-08-28 16:31:18 -0700 | [diff] [blame] | 241 | |
| 242 | data: [ |
| 243 | "testdata/arm/*", |
| 244 | "testdata/arm64/*", |
| 245 | "testdata/x86/*", |
| 246 | "testdata/x86_64/*", |
| 247 | ], |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 248 | } |
Christopher Ferris | 60521c7 | 2017-08-18 15:10:53 -0700 | [diff] [blame] | 249 | |
| 250 | cc_benchmark { |
| 251 | name: "backtrace_benchmarks", |
| 252 | defaults: ["libbacktrace_common"], |
| 253 | |
| 254 | srcs: [ |
| 255 | "backtrace_benchmarks.cpp", |
| 256 | ], |
| 257 | |
| 258 | shared_libs: [ |
| 259 | "libbacktrace", |
| 260 | "libbase", |
| 261 | ], |
| 262 | } |