• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17package {
18    default_applicable_licenses: ["Android-Apache-2.0"],
19}
20
21cc_defaults {
22    name: "libbacktrace_common",
23
24    cflags: [
25        "-Wall",
26        "-Werror",
27    ],
28
29    target: {
30        darwin: {
31            enabled: false,
32        },
33    },
34}
35
36libbacktrace_sources = [
37    "Backtrace.cpp",
38    "BacktraceCurrent.cpp",
39    "BacktracePtrace.cpp",
40    "ThreadEntry.cpp",
41    "UnwindStack.cpp",
42    "UnwindStackMap.cpp",
43]
44
45cc_library_headers {
46    name: "libbacktrace_headers",
47    vendor_available: true,
48    product_available: true,
49    host_supported: true,
50    recovery_available: true,
51    vendor_ramdisk_available: true,
52    native_bridge_supported: true,
53    export_include_dirs: ["include"],
54    apex_available: [
55        "//apex_available:platform",
56        "//apex_available:anyapex",
57    ],
58    target: {
59        linux_glibc: {
60            enabled: true,
61        },
62        linux_bionic: {
63            enabled: true,
64        },
65    },
66    min_sdk_version: "apex_inherit",
67}
68
69cc_defaults {
70    name: "libbacktrace_defaults",
71    defaults: ["libbacktrace_common"],
72
73    cflags: [
74        "-Wexit-time-destructors",
75    ],
76
77    srcs: [
78        "BacktraceMap.cpp",
79    ],
80
81    export_include_dirs: ["include"],
82
83    target: {
84        darwin: {
85            enabled: true,
86            shared_libs: [
87                "libbase",
88            ],
89        },
90        linux: {
91            srcs: libbacktrace_sources,
92
93            shared_libs: [
94                "libbase",
95                "liblog",
96            ],
97
98            static_libs: [
99                "libprocinfo",
100            ],
101        },
102        android: {
103            static_libs: ["libasync_safe"],
104            static: {
105                whole_static_libs: ["libasync_safe"],
106            },
107        },
108    },
109}
110
111cc_library {
112    name: "libbacktrace",
113    vendor_available: true,
114    product_available: true,
115    // TODO(b/153609531): remove when no longer needed.
116    native_bridge_supported: true,
117    recovery_available: true,
118    apex_available: [
119        "//apex_available:platform",
120        "//apex_available:anyapex",
121    ],
122    min_sdk_version: "apex_inherit",
123    vndk: {
124        enabled: true,
125        support_system_process: true,
126        private: true,
127    },
128    host_supported: true,
129    defaults: ["libbacktrace_defaults"],
130
131    target: {
132        linux: {
133            shared_libs: [
134                "libunwindstack",
135            ],
136        },
137        vendor: {
138            cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
139        },
140        product: {
141            cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
142        },
143        recovery: {
144            cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
145        },
146        native_bridge: {
147            cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
148        },
149    },
150}
151
152// Static library without DEX support to avoid dependencies on the ART APEX.
153cc_library_static {
154    name: "libbacktrace_no_dex",
155    visibility: [
156        "//system/core/debuggerd",
157        "//system/core/init",
158    ],
159    defaults: ["libbacktrace_defaults"],
160    cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
161    target: {
162        linux: {
163            static_libs: [
164                "libunwindstack_no_dex",
165            ],
166        },
167    },
168}
169
170cc_test_library {
171    name: "libbacktrace_test",
172    defaults: ["libbacktrace_common"],
173    host_supported: true,
174    strip: {
175        none: true,
176    },
177    cflags: ["-O0"],
178    srcs: ["backtrace_testlib.cpp"],
179
180    shared_libs: [
181        "libunwindstack",
182    ],
183
184    target: {
185        linux_glibc: {
186            // This forces the creation of eh_frame with unwind information
187            // for host.
188            cflags: [
189                "-fcxx-exceptions"
190            ],
191        },
192    },
193}
194
195//-------------------------------------------------------------------------
196// The backtrace_test executable.
197//-------------------------------------------------------------------------
198cc_test {
199    name: "backtrace_test",
200    isolated: true,
201    defaults: ["libbacktrace_common"],
202    host_supported: true,
203    test_options: {
204        unit_test: true,
205    },
206    srcs: [
207        "backtrace_test.cpp",
208    ],
209
210    cflags: [
211        "-fno-builtin",
212        "-O0",
213        "-g",
214    ],
215
216    shared_libs: [
217        "libbacktrace",
218        "libbase",
219        "liblog",
220        "libunwindstack",
221    ],
222
223    group_static_libs: true,
224
225    target: {
226        android: {
227            // So that the dlopen can find the libbacktrace_test.so.
228            ldflags: [
229                "-Wl,--rpath,${ORIGIN}",
230            ],
231        },
232    },
233
234    test_suites: ["device-tests"],
235    data: [
236        ":libbacktrace_test",
237        "testdata/arm/*",
238        "testdata/arm64/*",
239        "testdata/x86/*",
240        "testdata/x86_64/*",
241    ],
242}
243
244cc_benchmark {
245    name: "backtrace_benchmarks",
246    defaults: ["libbacktrace_common"],
247
248    srcs: [
249        "backtrace_benchmarks.cpp",
250        "backtrace_read_benchmarks.cpp",
251    ],
252
253    shared_libs: [
254        "libbacktrace",
255        "libbase",
256        "libunwindstack",
257    ],
258}
259