Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 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: |
Bob Badour | 7ca20c1 | 2021-02-03 18:29:06 -0800 | [diff] [blame] | 24 | package { |
| 25 | default_applicable_licenses: ["Android-Apache-2.0"], |
Yihan Dong | a08bb0a | 2024-06-03 01:18:02 +0000 | [diff] [blame] | 26 | default_team: "trendy_team_native_tools_libraries", |
Bob Badour | 7ca20c1 | 2021-02-03 18:29:06 -0800 | [diff] [blame] | 27 | } |
| 28 | |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 29 | event_flag = [ |
| 30 | "-DAUDITD_LOG_TAG=1003", |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 31 | "-DTAG_DEF_LOG_TAG=1005", |
Elliott Hughes | 5fe2531 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 32 | "-DLIBLOG_LOG_TAG=1006", |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 33 | ] |
| 34 | |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 35 | cc_defaults { |
| 36 | name: "logd_defaults", |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 37 | |
Tom Cherry | fb150dd | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 38 | shared_libs: [ |
| 39 | "libbase", |
| 40 | "libz", |
| 41 | ], |
| 42 | static_libs: ["libzstd"], |
Tom Cherry | c52ed0b | 2020-09-17 09:38:42 -0700 | [diff] [blame] | 43 | header_libs: ["libcutils_headers"], |
Tom Cherry | f3c0e5c | 2020-04-29 15:38:19 -0700 | [diff] [blame] | 44 | cflags: [ |
| 45 | "-Wextra", |
Tom Cherry | 479b503 | 2020-05-07 14:44:43 -0700 | [diff] [blame] | 46 | "-Wthread-safety", |
Tom Cherry | f3c0e5c | 2020-04-29 15:38:19 -0700 | [diff] [blame] | 47 | ] + event_flag, |
Tom Cherry | 7dabe9f | 2020-05-13 11:03:08 -0700 | [diff] [blame] | 48 | |
| 49 | lto: { |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 50 | thin: true, |
| 51 | }, |
Tom Cherry | f83edf7 | 2020-09-23 09:34:15 -0700 | [diff] [blame] | 52 | sanitize: { |
| 53 | cfi: true, |
| 54 | }, |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | cc_library_static { |
| 58 | name: "liblogd", |
| 59 | defaults: ["logd_defaults"], |
Tom Cherry | f3a8569 | 2020-05-15 11:39:58 -0700 | [diff] [blame] | 60 | host_supported: true, |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 61 | srcs: [ |
Tom Cherry | fb150dd | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 62 | "CompressionEngine.cpp", |
Tom Cherry | c5c9eba | 2020-10-06 10:22:35 -0700 | [diff] [blame] | 63 | "LogBufferElement.cpp", |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 64 | "LogReaderList.cpp", |
| 65 | "LogReaderThread.cpp", |
Tom Cherry | 8022895 | 2020-08-05 12:14:45 -0700 | [diff] [blame] | 66 | "LogSize.cpp", |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 67 | "LogStatistics.cpp", |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 68 | "LogTags.cpp", |
Tom Cherry | c5c9eba | 2020-10-06 10:22:35 -0700 | [diff] [blame] | 69 | "LogdLock.cpp", |
Tom Cherry | 3236191 | 2020-06-16 10:14:09 -0700 | [diff] [blame] | 70 | "PruneList.cpp", |
Tom Cherry | fb150dd | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 71 | "SerializedFlushToState.cpp", |
| 72 | "SerializedLogBuffer.cpp", |
| 73 | "SerializedLogChunk.cpp", |
Tom Cherry | 0c6eb46 | 2020-05-12 12:46:43 -0700 | [diff] [blame] | 74 | "SimpleLogBuffer.cpp", |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 75 | ], |
Tom Cherry | f03065c | 2020-09-16 11:32:47 -0700 | [diff] [blame] | 76 | static_libs: ["liblog"], |
Devin Moore | 5d3dd5d | 2022-08-01 16:36:48 +0000 | [diff] [blame] | 77 | shared_libs: ["libbinder"], |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 78 | logtags: ["event.logtags"], |
| 79 | |
| 80 | export_include_dirs: ["."], |
Vinh Tran | 8a06241 | 2023-05-01 17:49:22 -0400 | [diff] [blame] | 81 | |
| 82 | aidl: { |
| 83 | libs: [ |
| 84 | "ILogcatManagerService_aidl", |
| 85 | ], |
| 86 | }, |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Jiyong Park | d073cba | 2022-09-07 22:50:11 +0900 | [diff] [blame] | 89 | cc_binary { |
| 90 | name: "logd", |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 91 | defaults: ["logd_defaults"], |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 92 | init_rc: ["logd.rc"], |
| 93 | |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 94 | srcs: [ |
| 95 | "main.cpp", |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 96 | "CommandListener.cpp", |
Wenhao Wang | b1f6c6c | 2021-11-19 16:42:43 -0800 | [diff] [blame] | 97 | "LogdNativeService.cpp", |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 98 | "LogAudit.cpp", |
| 99 | "LogKlog.cpp", |
Wenhao Wang | b1f6c6c | 2021-11-19 16:42:43 -0800 | [diff] [blame] | 100 | "LogListener.cpp", |
| 101 | "LogPermissions.cpp", |
| 102 | "LogReader.cpp", |
Marco Nelissen | 9357be4 | 2021-12-02 10:49:52 -0800 | [diff] [blame] | 103 | "TrustyLog.cpp", |
eric.yan | 025217c | 2020-10-15 12:08:56 +0800 | [diff] [blame] | 104 | "PkgIds.cpp", |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 105 | ], |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 106 | |
Tom Cherry | 5203752 | 2019-01-17 11:37:22 -0800 | [diff] [blame] | 107 | static_libs: [ |
ThiƩbaud Weksteen | 9d0a959 | 2023-12-06 14:28:49 +1100 | [diff] [blame] | 108 | "libaudit", |
Tom Cherry | 5203752 | 2019-01-17 11:37:22 -0800 | [diff] [blame] | 109 | "liblog", |
| 110 | "liblogd", |
Wenhao Wang | b1f6c6c | 2021-11-19 16:42:43 -0800 | [diff] [blame] | 111 | "liblogd_binder", |
Tom Cherry | 5203752 | 2019-01-17 11:37:22 -0800 | [diff] [blame] | 112 | ], |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 113 | |
| 114 | shared_libs: [ |
Wenhao Wang | b1f6c6c | 2021-11-19 16:42:43 -0800 | [diff] [blame] | 115 | "libbinder", |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 116 | "libsysutils", |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 117 | "libcutils", |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 118 | "libpackagelistparser", |
Suren Baghdasaryan | 3e671a5 | 2019-01-25 05:32:52 +0000 | [diff] [blame] | 119 | "libprocessgroup", |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 120 | "libcap", |
Wenhao Wang | b1f6c6c | 2021-11-19 16:42:43 -0800 | [diff] [blame] | 121 | "libutils", |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 122 | ], |
Vinh Tran | 8a06241 | 2023-05-01 17:49:22 -0400 | [diff] [blame] | 123 | aidl: { |
| 124 | libs: [ |
| 125 | "ILogcatManagerService_aidl", |
| 126 | ] |
| 127 | } |
Steven Moreland | d611d62 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 128 | } |
Sasha Smundak | 6a78714 | 2019-01-24 21:16:39 -0800 | [diff] [blame] | 129 | |
ThiƩbaud Weksteen | 9d0a959 | 2023-12-06 14:28:49 +1100 | [diff] [blame] | 130 | cc_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 Kralevich | 8c8fd2f | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 143 | cc_binary { |
| 144 | name: "auditctl", |
| 145 | |
Tom Cherry | 5999389 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 146 | srcs: [ |
| 147 | "auditctl.cpp", |
Nick Kralevich | 8c8fd2f | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 148 | ], |
| 149 | |
| 150 | shared_libs: ["libbase"], |
ThiƩbaud Weksteen | 9d0a959 | 2023-12-06 14:28:49 +1100 | [diff] [blame] | 151 | static_libs: ["libaudit"], |
Nick Kralevich | 8c8fd2f | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 152 | |
| 153 | cflags: [ |
Nick Kralevich | 8c8fd2f | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 154 | "-Wextra", |
Nick Kralevich | 8c8fd2f | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 155 | ], |
| 156 | } |
Sasha Smundak | 6a78714 | 2019-01-24 21:16:39 -0800 | [diff] [blame] | 157 | |
| 158 | prebuilt_etc { |
| 159 | name: "logtagd.rc", |
| 160 | src: "logtagd.rc", |
| 161 | sub_dir: "init", |
| 162 | } |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 163 | |
| 164 | // ----------------------------------------------------------------------------- |
| 165 | // Unit tests. |
| 166 | // ----------------------------------------------------------------------------- |
| 167 | |
| 168 | cc_defaults { |
| 169 | name: "logd-unit-test-defaults", |
| 170 | |
| 171 | cflags: [ |
| 172 | "-fstack-protector-all", |
| 173 | "-g", |
| 174 | "-Wall", |
Tom Cherry | c5c9eba | 2020-10-06 10:22:35 -0700 | [diff] [blame] | 175 | "-Wthread-safety", |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 176 | "-Wextra", |
| 177 | "-Werror", |
| 178 | "-fno-builtin", |
Tom Cherry | 9f3eb61 | 2020-05-20 12:09:22 -0700 | [diff] [blame] | 179 | ] + event_flag, |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 180 | |
| 181 | srcs: [ |
| 182 | "logd_test.cpp", |
| 183 | "LogBufferTest.cpp", |
Tom Cherry | da4752e | 2021-06-22 23:20:08 -0700 | [diff] [blame] | 184 | "SerializedLogBufferTest.cpp", |
Tom Cherry | fb150dd | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 185 | "SerializedLogChunkTest.cpp", |
| 186 | "SerializedFlushToStateTest.cpp", |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 187 | ], |
Tom Cherry | f83edf7 | 2020-09-23 09:34:15 -0700 | [diff] [blame] | 188 | sanitize: { |
| 189 | cfi: true, |
| 190 | }, |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 191 | static_libs: [ |
| 192 | "libbase", |
| 193 | "libcutils", |
| 194 | "liblog", |
| 195 | "liblogd", |
| 196 | "libselinux", |
Tom Cherry | fb150dd | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 197 | "libz", |
| 198 | "libzstd", |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 199 | ], |
Wenhao Wang | b1f6c6c | 2021-11-19 16:42:43 -0800 | [diff] [blame] | 200 | shared_libs: [ |
| 201 | "libbinder", |
| 202 | "libutils", |
| 203 | ], |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | // Build tests for the logger. Run with: |
| 207 | // adb shell /data/nativetest/logd-unit-tests/logd-unit-tests |
| 208 | cc_test { |
| 209 | name: "logd-unit-tests", |
Tom Cherry | f3a8569 | 2020-05-15 11:39:58 -0700 | [diff] [blame] | 210 | host_supported: true, |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 211 | defaults: ["logd-unit-test-defaults"], |
Tom Cherry | d249e35 | 2020-11-03 06:21:39 -0800 | [diff] [blame] | 212 | test_suites: [ |
| 213 | "general-tests", |
| 214 | ], |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | cc_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 Cherry | b264311 | 2020-07-28 13:21:13 -0700 | [diff] [blame] | 230 | "device-tests", |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 231 | ], |
Tom Cherry | d249e35 | 2020-11-03 06:21:39 -0800 | [diff] [blame] | 232 | test_config: "device_test_config.xml", |
Tom Cherry | fbe7942 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 233 | } |
Tom Cherry | f0dc09b | 2020-07-09 09:51:16 -0700 | [diff] [blame] | 234 | |
| 235 | cc_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 Wang | b1f6c6c | 2021-11-19 16:42:43 -0800 | [diff] [blame] | 253 | shared_libs: [ |
| 254 | "libbinder", |
| 255 | "libutils", |
| 256 | ], |
| 257 | } |
| 258 | |
| 259 | cc_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 | |
| 282 | filegroup { |
| 283 | name: "logd_aidl", |
| 284 | srcs: [ |
| 285 | "binder/android/os/ILogd.aidl", |
| 286 | ], |
| 287 | path: "binder", |
Tom Cherry | f0dc09b | 2020-07-09 09:51:16 -0700 | [diff] [blame] | 288 | } |