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 ], 24 25 // The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists. 26 clang_cflags: ["-Wno-inline-asm"], 27 28 include_dirs: ["external/libunwind/include/tdep"], 29 30 31 target: { 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 58 cc_library_headers { 59 name: "libbacktrace_headers", 60 vendor_available: true, 61 export_include_dirs: ["include"], 62 } 63 64 cc_library { 65 name: "libbacktrace", 66 vendor_available: true, 67 vndk: { 68 enabled: true, 69 support_system_process: true, 70 }, 71 defaults: ["libbacktrace_common"], 72 host_supported: true, 73 74 srcs: [ 75 "BacktraceMap.cpp", 76 ], 77 78 export_include_dirs: ["include"], 79 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"], 94 host_ldlibs: ["-lrt"], 95 }, 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 }, 108 android: { 109 srcs: libbacktrace_sources, 110 111 shared_libs: [ 112 "libbase", 113 "liblog", 114 "libunwind", 115 ], 116 117 static_libs: ["libasync_safe", "libcutils"], 118 }, 119 }, 120 whole_static_libs: ["libdemangle"], 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"], 131 srcs: ["backtrace_testlib.cpp"], 132 133 target: { 134 linux: { 135 shared_libs: [ 136 "libunwind", 137 ], 138 }, 139 android: { 140 shared_libs: [ 141 "libunwind", 142 ], 143 }, 144 } 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", 168 "libziparchive", 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 } 238