xref: /aosp_15_r20/system/logging/logd/Android.bp (revision 598139dc91b21518d67c408eaea2644226490971)
1// Copyright (C) 2017 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// This is what we want to do:
16//  event_logtags = $(shell
17//    sed -n
18//        "s/^\([0-9]*\)[ \t]*$1[ \t].*/-D`echo $1 | tr a-z A-Z`_LOG_TAG=\1/p"
19//        $(LOCAL_PATH)/$2/event.logtags)
20//  event_flag := $(call event_logtags,auditd)
21//  event_flag += $(call event_logtags,logd)
22//  event_flag += $(call event_logtags,tag_def)
23// so make sure we do not regret hard-coding it as follows:
24package {
25    default_applicable_licenses: ["Android-Apache-2.0"],
26    default_team: "trendy_team_native_tools_libraries",
27}
28
29event_flag = [
30    "-DAUDITD_LOG_TAG=1003",
31    "-DTAG_DEF_LOG_TAG=1005",
32    "-DLIBLOG_LOG_TAG=1006",
33]
34
35cc_defaults {
36    name: "logd_defaults",
37
38    shared_libs: [
39        "libbase",
40        "libz",
41    ],
42    static_libs: ["libzstd"],
43    header_libs: ["libcutils_headers"],
44    cflags: [
45        "-Wextra",
46        "-Wthread-safety",
47    ] + event_flag,
48
49    lto: {
50        thin: true,
51    },
52    sanitize: {
53        cfi: true,
54    },
55}
56
57cc_library_static {
58    name: "liblogd",
59    defaults: ["logd_defaults"],
60    host_supported: true,
61    srcs: [
62        "CompressionEngine.cpp",
63        "LogBufferElement.cpp",
64        "LogReaderList.cpp",
65        "LogReaderThread.cpp",
66        "LogSize.cpp",
67        "LogStatistics.cpp",
68        "LogTags.cpp",
69        "LogdLock.cpp",
70        "PruneList.cpp",
71        "SerializedFlushToState.cpp",
72        "SerializedLogBuffer.cpp",
73        "SerializedLogChunk.cpp",
74        "SimpleLogBuffer.cpp",
75    ],
76    static_libs: ["liblog"],
77    shared_libs: ["libbinder"],
78    logtags: ["event.logtags"],
79
80    export_include_dirs: ["."],
81
82    aidl: {
83        libs: [
84            "ILogcatManagerService_aidl",
85        ],
86    },
87}
88
89cc_binary {
90    name: "logd",
91    defaults: ["logd_defaults"],
92    init_rc: ["logd.rc"],
93
94    srcs: [
95        "main.cpp",
96        "CommandListener.cpp",
97        "LogdNativeService.cpp",
98        "LogAudit.cpp",
99        "LogKlog.cpp",
100        "LogListener.cpp",
101        "LogPermissions.cpp",
102        "LogReader.cpp",
103        "TrustyLog.cpp",
104        "PkgIds.cpp",
105    ],
106
107    static_libs: [
108        "libaudit",
109        "liblog",
110        "liblogd",
111        "liblogd_binder",
112    ],
113
114    shared_libs: [
115        "libbinder",
116        "libsysutils",
117        "libcutils",
118        "libpackagelistparser",
119        "libprocessgroup",
120        "libcap",
121        "libutils",
122    ],
123    aidl: {
124        libs: [
125            "ILogcatManagerService_aidl",
126        ]
127    }
128}
129
130cc_library_static {
131    name: "libaudit",
132    srcs: [
133        "libaudit/libaudit.cpp"
134    ],
135    shared_libs: ["libbase"],
136
137    export_include_dirs: ["libaudit/include"],
138
139    recovery_available: true,
140    vendor_available: true,
141}
142
143cc_binary {
144    name: "auditctl",
145
146    srcs: [
147        "auditctl.cpp",
148    ],
149
150    shared_libs: ["libbase"],
151    static_libs: ["libaudit"],
152
153    cflags: [
154        "-Wextra",
155    ],
156}
157
158prebuilt_etc {
159    name: "logtagd.rc",
160    src: "logtagd.rc",
161    sub_dir: "init",
162}
163
164// -----------------------------------------------------------------------------
165// Unit tests.
166// -----------------------------------------------------------------------------
167
168cc_defaults {
169    name: "logd-unit-test-defaults",
170
171    cflags: [
172        "-fstack-protector-all",
173        "-g",
174        "-Wall",
175        "-Wthread-safety",
176        "-Wextra",
177        "-Werror",
178        "-fno-builtin",
179    ] + event_flag,
180
181    srcs: [
182        "logd_test.cpp",
183        "LogBufferTest.cpp",
184        "SerializedLogBufferTest.cpp",
185        "SerializedLogChunkTest.cpp",
186        "SerializedFlushToStateTest.cpp",
187    ],
188    sanitize: {
189        cfi: true,
190    },
191    static_libs: [
192        "libbase",
193        "libcutils",
194        "liblog",
195        "liblogd",
196        "libselinux",
197        "libz",
198        "libzstd",
199    ],
200    shared_libs: [
201        "libbinder",
202        "libutils",
203    ],
204}
205
206// Build tests for the logger. Run with:
207//   adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
208cc_test {
209    name: "logd-unit-tests",
210    host_supported: true,
211    defaults: ["logd-unit-test-defaults"],
212    test_suites: [
213        "general-tests",
214    ],
215}
216
217cc_test {
218    name: "CtsLogdTestCases",
219    defaults: ["logd-unit-test-defaults"],
220    multilib: {
221        lib32: {
222            suffix: "32",
223        },
224        lib64: {
225            suffix: "64",
226        },
227    },
228    test_suites: [
229        "cts",
230        "device-tests",
231    ],
232    test_config: "device_test_config.xml",
233}
234
235cc_binary {
236    name: "replay_messages",
237    defaults: ["logd_defaults"],
238    host_supported: true,
239
240    srcs: [
241        "ReplayMessages.cpp",
242    ],
243
244    static_libs: [
245        "libbase",
246        "libcutils",
247        "liblog",
248        "liblogd",
249        "libselinux",
250        "libz",
251        "libzstd",
252    ],
253    shared_libs: [
254        "libbinder",
255        "libutils",
256    ],
257}
258
259cc_library_static {
260    name: "liblogd_binder",
261    defaults: ["logd_defaults"],
262
263    srcs: [
264        ":logd_aidl",
265    ],
266    shared_libs: [
267        "libbinder",
268        "libutils",
269    ],
270    aidl: {
271        local_include_dirs: ["binder"],
272        export_aidl_headers: true,
273    },
274    whole_static_libs: [
275        "libincremental_aidl-cpp",
276    ],
277    export_shared_lib_headers: [
278        "libbinder",
279    ],
280}
281
282filegroup {
283    name: "logd_aidl",
284    srcs: [
285        "binder/android/os/ILogd.aidl",
286    ],
287    path: "binder",
288}
289