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