blob: 415cdebf07bf48d320fd303d3fb5be0891b89530 [file] [log] [blame]
Steven Morelandd611d622017-06-27 18:20:18 -07001// 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:
Bob Badour7ca20c12021-02-03 18:29:06 -080024package {
25 default_applicable_licenses: ["Android-Apache-2.0"],
Yihan Donga08bb0a2024-06-03 01:18:02 +000026 default_team: "trendy_team_native_tools_libraries",
Bob Badour7ca20c12021-02-03 18:29:06 -080027}
28
Steven Morelandd611d622017-06-27 18:20:18 -070029event_flag = [
30 "-DAUDITD_LOG_TAG=1003",
Steven Morelandd611d622017-06-27 18:20:18 -070031 "-DTAG_DEF_LOG_TAG=1005",
Elliott Hughes5fe25312018-02-16 17:58:14 -080032 "-DLIBLOG_LOG_TAG=1006",
Steven Morelandd611d622017-06-27 18:20:18 -070033]
34
Tom Cherry59993892020-05-15 10:58:43 -070035cc_defaults {
36 name: "logd_defaults",
Steven Morelandd611d622017-06-27 18:20:18 -070037
Tom Cherryfb150dd2020-05-13 09:28:37 -070038 shared_libs: [
39 "libbase",
40 "libz",
41 ],
42 static_libs: ["libzstd"],
Tom Cherryc52ed0b2020-09-17 09:38:42 -070043 header_libs: ["libcutils_headers"],
Tom Cherryf3c0e5c2020-04-29 15:38:19 -070044 cflags: [
45 "-Wextra",
Tom Cherry479b5032020-05-07 14:44:43 -070046 "-Wthread-safety",
Tom Cherryf3c0e5c2020-04-29 15:38:19 -070047 ] + event_flag,
Tom Cherry7dabe9f2020-05-13 11:03:08 -070048
49 lto: {
Tom Cherry59993892020-05-15 10:58:43 -070050 thin: true,
51 },
Tom Cherryf83edf72020-09-23 09:34:15 -070052 sanitize: {
53 cfi: true,
54 },
Tom Cherry59993892020-05-15 10:58:43 -070055}
56
57cc_library_static {
58 name: "liblogd",
59 defaults: ["logd_defaults"],
Tom Cherryf3a85692020-05-15 11:39:58 -070060 host_supported: true,
Tom Cherry59993892020-05-15 10:58:43 -070061 srcs: [
Tom Cherryfb150dd2020-05-13 09:28:37 -070062 "CompressionEngine.cpp",
Tom Cherryc5c9eba2020-10-06 10:22:35 -070063 "LogBufferElement.cpp",
Tom Cherry59993892020-05-15 10:58:43 -070064 "LogReaderList.cpp",
65 "LogReaderThread.cpp",
Tom Cherry80228952020-08-05 12:14:45 -070066 "LogSize.cpp",
Tom Cherry59993892020-05-15 10:58:43 -070067 "LogStatistics.cpp",
Tom Cherry59993892020-05-15 10:58:43 -070068 "LogTags.cpp",
Tom Cherryc5c9eba2020-10-06 10:22:35 -070069 "LogdLock.cpp",
Tom Cherry32361912020-06-16 10:14:09 -070070 "PruneList.cpp",
Tom Cherryfb150dd2020-05-13 09:28:37 -070071 "SerializedFlushToState.cpp",
72 "SerializedLogBuffer.cpp",
73 "SerializedLogChunk.cpp",
Tom Cherry0c6eb462020-05-12 12:46:43 -070074 "SimpleLogBuffer.cpp",
Tom Cherry59993892020-05-15 10:58:43 -070075 ],
Tom Cherryf03065c2020-09-16 11:32:47 -070076 static_libs: ["liblog"],
Devin Moore5d3dd5d2022-08-01 16:36:48 +000077 shared_libs: ["libbinder"],
Tom Cherry59993892020-05-15 10:58:43 -070078 logtags: ["event.logtags"],
79
80 export_include_dirs: ["."],
Vinh Tran8a062412023-05-01 17:49:22 -040081
82 aidl: {
83 libs: [
84 "ILogcatManagerService_aidl",
85 ],
86 },
Steven Morelandd611d622017-06-27 18:20:18 -070087}
88
Jiyong Parkd073cba2022-09-07 22:50:11 +090089cc_binary {
90 name: "logd",
Tom Cherry59993892020-05-15 10:58:43 -070091 defaults: ["logd_defaults"],
Steven Morelandd611d622017-06-27 18:20:18 -070092 init_rc: ["logd.rc"],
93
Tom Cherry59993892020-05-15 10:58:43 -070094 srcs: [
95 "main.cpp",
Tom Cherry59993892020-05-15 10:58:43 -070096 "CommandListener.cpp",
Wenhao Wangb1f6c6c2021-11-19 16:42:43 -080097 "LogdNativeService.cpp",
Tom Cherry59993892020-05-15 10:58:43 -070098 "LogAudit.cpp",
99 "LogKlog.cpp",
Wenhao Wangb1f6c6c2021-11-19 16:42:43 -0800100 "LogListener.cpp",
101 "LogPermissions.cpp",
102 "LogReader.cpp",
Marco Nelissen9357be42021-12-02 10:49:52 -0800103 "TrustyLog.cpp",
eric.yan025217c2020-10-15 12:08:56 +0800104 "PkgIds.cpp",
Tom Cherry59993892020-05-15 10:58:43 -0700105 ],
Steven Morelandd611d622017-06-27 18:20:18 -0700106
Tom Cherry52037522019-01-17 11:37:22 -0800107 static_libs: [
ThiƩbaud Weksteen9d0a9592023-12-06 14:28:49 +1100108 "libaudit",
Tom Cherry52037522019-01-17 11:37:22 -0800109 "liblog",
110 "liblogd",
Wenhao Wangb1f6c6c2021-11-19 16:42:43 -0800111 "liblogd_binder",
Tom Cherry52037522019-01-17 11:37:22 -0800112 ],
Steven Morelandd611d622017-06-27 18:20:18 -0700113
114 shared_libs: [
Wenhao Wangb1f6c6c2021-11-19 16:42:43 -0800115 "libbinder",
Steven Morelandd611d622017-06-27 18:20:18 -0700116 "libsysutils",
Steven Morelandd611d622017-06-27 18:20:18 -0700117 "libcutils",
Steven Morelandd611d622017-06-27 18:20:18 -0700118 "libpackagelistparser",
Suren Baghdasaryan3e671a52019-01-25 05:32:52 +0000119 "libprocessgroup",
Steven Morelandd611d622017-06-27 18:20:18 -0700120 "libcap",
Wenhao Wangb1f6c6c2021-11-19 16:42:43 -0800121 "libutils",
Steven Morelandd611d622017-06-27 18:20:18 -0700122 ],
Vinh Tran8a062412023-05-01 17:49:22 -0400123 aidl: {
124 libs: [
125 "ILogcatManagerService_aidl",
126 ]
127 }
Steven Morelandd611d622017-06-27 18:20:18 -0700128}
Sasha Smundak6a787142019-01-24 21:16:39 -0800129
ThiƩbaud Weksteen9d0a9592023-12-06 14:28:49 +1100130cc_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
Nick Kralevich8c8fd2f2019-04-09 10:59:39 -0700143cc_binary {
144 name: "auditctl",
145
Tom Cherry59993892020-05-15 10:58:43 -0700146 srcs: [
147 "auditctl.cpp",
Nick Kralevich8c8fd2f2019-04-09 10:59:39 -0700148 ],
149
150 shared_libs: ["libbase"],
ThiƩbaud Weksteen9d0a9592023-12-06 14:28:49 +1100151 static_libs: ["libaudit"],
Nick Kralevich8c8fd2f2019-04-09 10:59:39 -0700152
153 cflags: [
Nick Kralevich8c8fd2f2019-04-09 10:59:39 -0700154 "-Wextra",
Nick Kralevich8c8fd2f2019-04-09 10:59:39 -0700155 ],
156}
Sasha Smundak6a787142019-01-24 21:16:39 -0800157
158prebuilt_etc {
159 name: "logtagd.rc",
160 src: "logtagd.rc",
161 sub_dir: "init",
162}
Tom Cherryfbe79422020-05-14 22:28:09 -0700163
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",
Tom Cherryc5c9eba2020-10-06 10:22:35 -0700175 "-Wthread-safety",
Tom Cherryfbe79422020-05-14 22:28:09 -0700176 "-Wextra",
177 "-Werror",
178 "-fno-builtin",
Tom Cherry9f3eb612020-05-20 12:09:22 -0700179 ] + event_flag,
Tom Cherryfbe79422020-05-14 22:28:09 -0700180
181 srcs: [
182 "logd_test.cpp",
183 "LogBufferTest.cpp",
Tom Cherryda4752e2021-06-22 23:20:08 -0700184 "SerializedLogBufferTest.cpp",
Tom Cherryfb150dd2020-05-13 09:28:37 -0700185 "SerializedLogChunkTest.cpp",
186 "SerializedFlushToStateTest.cpp",
Tom Cherryfbe79422020-05-14 22:28:09 -0700187 ],
Tom Cherryf83edf72020-09-23 09:34:15 -0700188 sanitize: {
189 cfi: true,
190 },
Tom Cherryfbe79422020-05-14 22:28:09 -0700191 static_libs: [
192 "libbase",
193 "libcutils",
194 "liblog",
195 "liblogd",
196 "libselinux",
Tom Cherryfb150dd2020-05-13 09:28:37 -0700197 "libz",
198 "libzstd",
Tom Cherryfbe79422020-05-14 22:28:09 -0700199 ],
Wenhao Wangb1f6c6c2021-11-19 16:42:43 -0800200 shared_libs: [
201 "libbinder",
202 "libutils",
203 ],
Tom Cherryfbe79422020-05-14 22:28:09 -0700204}
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",
Tom Cherryf3a85692020-05-15 11:39:58 -0700210 host_supported: true,
Tom Cherryfbe79422020-05-14 22:28:09 -0700211 defaults: ["logd-unit-test-defaults"],
Tom Cherryd249e352020-11-03 06:21:39 -0800212 test_suites: [
213 "general-tests",
214 ],
Tom Cherryfbe79422020-05-14 22:28:09 -0700215}
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",
Tom Cherryb2643112020-07-28 13:21:13 -0700230 "device-tests",
Tom Cherryfbe79422020-05-14 22:28:09 -0700231 ],
Tom Cherryd249e352020-11-03 06:21:39 -0800232 test_config: "device_test_config.xml",
Tom Cherryfbe79422020-05-14 22:28:09 -0700233}
Tom Cherryf0dc09b2020-07-09 09:51:16 -0700234
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 ],
Wenhao Wangb1f6c6c2021-11-19 16:42:43 -0800253 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",
Tom Cherryf0dc09b2020-07-09 09:51:16 -0700288}