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