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