Home | History | Annotate | Download | only in libbacktrace
      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     defaults: ["libbacktrace_common"],
     68     host_supported: true,
     69 
     70     srcs: [
     71         "BacktraceMap.cpp",
     72     ],
     73 
     74     export_include_dirs: ["include"],
     75 
     76     target: {
     77         darwin: {
     78             enabled: true,
     79         },
     80         linux: {
     81             srcs: libbacktrace_sources,
     82 
     83             shared_libs: [
     84                 "libbase",
     85                 "liblog",
     86                 "libunwind",
     87             ],
     88 
     89             static_libs: ["libcutils"],
     90             host_ldlibs: ["-lrt"],
     91         },
     92         linux_bionic: {
     93             enabled: true,
     94             srcs: libbacktrace_sources,
     95 
     96             shared_libs: [
     97                 "libbase",
     98                 "liblog",
     99                 "libunwind",
    100             ],
    101 
    102             static_libs: ["libcutils"],
    103         },
    104         android: {
    105             srcs: libbacktrace_sources,
    106 
    107             shared_libs: [
    108                 "libbase",
    109                 "liblog",
    110                 "libunwind",
    111             ],
    112 
    113             static_libs: ["libcutils"],
    114         },
    115     },
    116 }
    117 
    118 cc_library_shared {
    119     name: "libbacktrace_test",
    120     defaults: ["libbacktrace_common"],
    121     host_supported: true,
    122     strip: {
    123         none: true,
    124     },
    125     cflags: ["-O0"],
    126     srcs: ["backtrace_testlib.cpp"],
    127 
    128     target: {
    129         linux: {
    130             shared_libs: [
    131                 "libunwind",
    132             ],
    133         },
    134         android: {
    135             shared_libs: [
    136                 "libunwind",
    137             ],
    138         },
    139     }
    140 }
    141 
    142 //-------------------------------------------------------------------------
    143 // The libbacktrace_offline static library.
    144 //-------------------------------------------------------------------------
    145 cc_library_static {
    146     name: "libbacktrace_offline",
    147     defaults: ["libbacktrace_common"],
    148     host_supported: true,
    149     srcs: ["BacktraceOffline.cpp"],
    150 
    151     cflags: [
    152         "-D__STDC_CONSTANT_MACROS",
    153         "-D__STDC_LIMIT_MACROS",
    154         "-D__STDC_FORMAT_MACROS",
    155     ],
    156 
    157     header_libs: ["llvm-headers"],
    158 
    159     // Use shared libraries so their headers get included during build.
    160     shared_libs = [
    161         "libbase",
    162         "libunwind",
    163     ],
    164 }
    165 
    166 //-------------------------------------------------------------------------
    167 // The backtrace_test executable.
    168 //-------------------------------------------------------------------------
    169 cc_test {
    170     name: "backtrace_test",
    171     defaults: ["libbacktrace_common"],
    172     host_supported: true,
    173     srcs: [
    174         "backtrace_offline_test.cpp",
    175         "backtrace_test.cpp",
    176         "GetPss.cpp",
    177         "thread_utils.c",
    178     ],
    179 
    180     cflags: [
    181         "-fno-builtin",
    182         "-O0",
    183         "-g",
    184     ],
    185 
    186     shared_libs: [
    187         "libbacktrace_test",
    188         "libbacktrace",
    189         "libbase",
    190         "libcutils",
    191         "liblog",
    192         "libunwind",
    193     ],
    194 
    195     group_static_libs: true,
    196 
    197     // Statically link LLVMlibraries to remove dependency on llvm shared library.
    198     static_libs = [
    199         "libbacktrace_offline",
    200         "libLLVMObject",
    201         "libLLVMBitReader",
    202         "libLLVMMC",
    203         "libLLVMMCParser",
    204         "libLLVMCore",
    205         "libLLVMSupport",
    206 
    207         "libziparchive",
    208         "libz",
    209     ],
    210 
    211     header_libs: ["llvm-headers"],
    212 
    213     target: {
    214         android: {
    215             cflags: ["-DENABLE_PSS_TESTS"],
    216             shared_libs: [
    217                 "libdl",
    218                 "libutils",
    219             ],
    220         },
    221         linux: {
    222             host_ldlibs: [
    223                 "-lpthread",
    224                 "-lrt",
    225                 "-ldl",
    226                 "-lncurses",
    227             ],
    228             static_libs: ["libutils"],
    229         },
    230     },
    231 }
    232