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", |
Steven Moreland | bb11af8 | 2017-04-13 23:35:06 -0700 | [diff] [blame] | 68 | vendor_available: true, |
Justin Yun | aeb68e8 | 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 | }, |
| 86 | linux: { |
| 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"], |
Colin Cross | 53783b1 | 2016-10-20 10:39:51 -0700 | [diff] [blame] | 97 | host_ldlibs: ["-lrt"], |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 98 | }, |
Dan Willemsen | e0cd1e0 | 2017-03-15 15:23:36 -0700 | [diff] [blame] | 99 | linux_bionic: { |
| 100 | enabled: true, |
| 101 | srcs: libbacktrace_sources, |
| 102 | |
| 103 | shared_libs: [ |
| 104 | "libbase", |
| 105 | "liblog", |
| 106 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 107 | "libunwindstack", |
Dan Willemsen | e0cd1e0 | 2017-03-15 15:23:36 -0700 | [diff] [blame] | 108 | ], |
| 109 | |
| 110 | static_libs: ["libcutils"], |
| 111 | }, |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 112 | android: { |
| 113 | srcs: libbacktrace_sources, |
| 114 | |
| 115 | shared_libs: [ |
| 116 | "libbase", |
| 117 | "liblog", |
| 118 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 119 | "libunwindstack", |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 120 | ], |
| 121 | |
Christopher Ferris | f30a810 | 2017-05-03 17:22:24 -0700 | [diff] [blame] | 122 | static_libs: ["libasync_safe", "libcutils"], |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 123 | }, |
| 124 | }, |
Christopher Ferris | 7d0aea9 | 2017-06-01 14:15:09 -0700 | [diff] [blame] | 125 | whole_static_libs: ["libdemangle"], |
Dan Willemsen | 2e1591b | 2016-07-12 17:20:18 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | cc_library_shared { |
| 129 | name: "libbacktrace_test", |
| 130 | defaults: ["libbacktrace_common"], |
| 131 | host_supported: true, |
| 132 | strip: { |
| 133 | none: true, |
| 134 | }, |
| 135 | cflags: ["-O0"], |
Christopher Ferris | 5ea2c1f | 2017-03-23 14:55:01 -0700 | [diff] [blame] | 136 | srcs: ["backtrace_testlib.cpp"], |
Yabin Cui | 5d991bc | 2016-11-15 17:47:09 -0800 | [diff] [blame] | 137 | |
| 138 | target: { |
| 139 | linux: { |
| 140 | shared_libs: [ |
| 141 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 142 | "libunwindstack", |
Yabin Cui | 5d991bc | 2016-11-15 17:47:09 -0800 | [diff] [blame] | 143 | ], |
| 144 | }, |
| 145 | android: { |
| 146 | shared_libs: [ |
| 147 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 148 | "libunwindstack", |
Yabin Cui | 5d991bc | 2016-11-15 17:47:09 -0800 | [diff] [blame] | 149 | ], |
| 150 | }, |
| 151 | } |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | //------------------------------------------------------------------------- |
| 155 | // The libbacktrace_offline static library. |
| 156 | //------------------------------------------------------------------------- |
| 157 | cc_library_static { |
| 158 | name: "libbacktrace_offline", |
| 159 | defaults: ["libbacktrace_common"], |
| 160 | host_supported: true, |
| 161 | srcs: ["BacktraceOffline.cpp"], |
| 162 | |
| 163 | cflags: [ |
| 164 | "-D__STDC_CONSTANT_MACROS", |
| 165 | "-D__STDC_LIMIT_MACROS", |
| 166 | "-D__STDC_FORMAT_MACROS", |
| 167 | ], |
| 168 | |
| 169 | header_libs: ["llvm-headers"], |
| 170 | |
| 171 | // Use shared libraries so their headers get included during build. |
| 172 | shared_libs = [ |
| 173 | "libbase", |
| 174 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 175 | "libunwindstack", |
Andreas Gampe | 8f0947c | 2017-07-03 13:02:33 -0700 | [diff] [blame] | 176 | "libziparchive", |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 177 | ], |
| 178 | } |
| 179 | |
| 180 | //------------------------------------------------------------------------- |
| 181 | // The backtrace_test executable. |
| 182 | //------------------------------------------------------------------------- |
| 183 | cc_test { |
| 184 | name: "backtrace_test", |
| 185 | defaults: ["libbacktrace_common"], |
| 186 | host_supported: true, |
| 187 | srcs: [ |
| 188 | "backtrace_offline_test.cpp", |
| 189 | "backtrace_test.cpp", |
| 190 | "GetPss.cpp", |
| 191 | "thread_utils.c", |
| 192 | ], |
| 193 | |
| 194 | cflags: [ |
| 195 | "-fno-builtin", |
| 196 | "-O0", |
| 197 | "-g", |
| 198 | ], |
| 199 | |
| 200 | shared_libs: [ |
| 201 | "libbacktrace_test", |
| 202 | "libbacktrace", |
| 203 | "libbase", |
| 204 | "libcutils", |
| 205 | "liblog", |
| 206 | "libunwind", |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 207 | "libunwindstack", |
Colin Cross | da9bd59 | 2016-12-14 17:24:46 -0800 | [diff] [blame] | 208 | ], |
| 209 | |
| 210 | group_static_libs: true, |
| 211 | |
| 212 | // Statically link LLVMlibraries to remove dependency on llvm shared library. |
| 213 | static_libs = [ |
| 214 | "libbacktrace_offline", |
| 215 | "libLLVMObject", |
| 216 | "libLLVMBitReader", |
| 217 | "libLLVMMC", |
| 218 | "libLLVMMCParser", |
| 219 | "libLLVMCore", |
| 220 | "libLLVMSupport", |
| 221 | |
| 222 | "libziparchive", |
| 223 | "libz", |
| 224 | ], |
| 225 | |
| 226 | header_libs: ["llvm-headers"], |
| 227 | |
| 228 | target: { |
| 229 | android: { |
| 230 | cflags: ["-DENABLE_PSS_TESTS"], |
| 231 | shared_libs: [ |
| 232 | "libdl", |
| 233 | "libutils", |
| 234 | ], |
| 235 | }, |
| 236 | linux: { |
| 237 | host_ldlibs: [ |
| 238 | "-lpthread", |
| 239 | "-lrt", |
| 240 | "-ldl", |
| 241 | "-lncurses", |
| 242 | ], |
| 243 | static_libs: ["libutils"], |
| 244 | }, |
| 245 | }, |
| 246 | } |