Steven Moreland | fca20d8 | 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: |
| 24 | event_flag = [ |
| 25 | "-DAUDITD_LOG_TAG=1003", |
| 26 | "-DCHATTY_LOG_TAG=1004", |
| 27 | "-DTAG_DEF_LOG_TAG=1005", |
Elliott Hughes | dc699a2 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 28 | "-DLIBLOG_LOG_TAG=1006", |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 29 | ] |
| 30 | |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 31 | cc_defaults { |
| 32 | name: "logd_defaults", |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 33 | |
Tom Cherry | 1a796bc | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 34 | shared_libs: [ |
| 35 | "libbase", |
| 36 | "libz", |
| 37 | ], |
| 38 | static_libs: ["libzstd"], |
Tom Cherry | 053daca | 2020-04-29 15:38:19 -0700 | [diff] [blame] | 39 | cflags: [ |
| 40 | "-Wextra", |
Tom Cherry | 64e9016 | 2020-05-07 14:44:43 -0700 | [diff] [blame] | 41 | "-Wthread-safety", |
Tom Cherry | 053daca | 2020-04-29 15:38:19 -0700 | [diff] [blame] | 42 | ] + event_flag, |
Tom Cherry | 72f1aa8 | 2020-05-13 11:03:08 -0700 | [diff] [blame] | 43 | |
| 44 | lto: { |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 45 | thin: true, |
| 46 | }, |
Tom Cherry | 1a796bc | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 47 | cpp_std: "experimental", |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | cc_library_static { |
| 51 | name: "liblogd", |
| 52 | defaults: ["logd_defaults"], |
Tom Cherry | a515197 | 2020-05-15 11:39:58 -0700 | [diff] [blame] | 53 | host_supported: true, |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 54 | srcs: [ |
| 55 | "ChattyLogBuffer.cpp", |
Tom Cherry | 1a796bc | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 56 | "CompressionEngine.cpp", |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 57 | "LogReaderList.cpp", |
| 58 | "LogReaderThread.cpp", |
| 59 | "LogBufferElement.cpp", |
Tom Cherry | 39dc221 | 2020-08-05 12:14:45 -0700 | [diff] [blame] | 60 | "LogSize.cpp", |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 61 | "LogStatistics.cpp", |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 62 | "LogTags.cpp", |
Tom Cherry | 0efb410 | 2020-06-16 10:14:09 -0700 | [diff] [blame] | 63 | "PruneList.cpp", |
Tom Cherry | 1a796bc | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 64 | "SerializedFlushToState.cpp", |
| 65 | "SerializedLogBuffer.cpp", |
| 66 | "SerializedLogChunk.cpp", |
Tom Cherry | 8f61346 | 2020-05-12 12:46:43 -0700 | [diff] [blame] | 67 | "SimpleLogBuffer.cpp", |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 68 | ], |
Tom Cherry | 3d8b739 | 2020-09-16 11:32:47 -0700 | [diff] [blame] | 69 | static_libs: ["liblog"], |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 70 | logtags: ["event.logtags"], |
| 71 | |
| 72 | export_include_dirs: ["."], |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | cc_binary { |
| 76 | name: "logd", |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 77 | defaults: ["logd_defaults"], |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 78 | init_rc: ["logd.rc"], |
| 79 | |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 80 | srcs: [ |
| 81 | "main.cpp", |
| 82 | "LogPermissions.cpp", |
| 83 | "CommandListener.cpp", |
| 84 | "LogListener.cpp", |
| 85 | "LogReader.cpp", |
| 86 | "LogAudit.cpp", |
| 87 | "LogKlog.cpp", |
| 88 | "libaudit.cpp", |
| 89 | ], |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 90 | |
Tom Cherry | 9e12433 | 2019-01-17 11:37:22 -0800 | [diff] [blame] | 91 | static_libs: [ |
| 92 | "liblog", |
| 93 | "liblogd", |
| 94 | ], |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 95 | |
| 96 | shared_libs: [ |
| 97 | "libsysutils", |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 98 | "libcutils", |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 99 | "libpackagelistparser", |
Suren Baghdasaryan | 9491078 | 2019-01-25 05:32:52 +0000 | [diff] [blame] | 100 | "libprocessgroup", |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 101 | "libcap", |
| 102 | ], |
Steven Moreland | fca20d8 | 2017-06-27 18:20:18 -0700 | [diff] [blame] | 103 | } |
Sasha Smundak | 3a62fc4 | 2019-01-24 21:16:39 -0800 | [diff] [blame] | 104 | |
Nick Kralevich | be5e446 | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 105 | cc_binary { |
| 106 | name: "auditctl", |
| 107 | |
Tom Cherry | 7395396 | 2020-05-15 10:58:43 -0700 | [diff] [blame] | 108 | srcs: [ |
| 109 | "auditctl.cpp", |
| 110 | "libaudit.cpp", |
Nick Kralevich | be5e446 | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 111 | ], |
| 112 | |
| 113 | shared_libs: ["libbase"], |
| 114 | |
| 115 | cflags: [ |
Nick Kralevich | be5e446 | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 116 | "-Wextra", |
Nick Kralevich | be5e446 | 2019-04-09 10:59:39 -0700 | [diff] [blame] | 117 | ], |
| 118 | } |
Sasha Smundak | 3a62fc4 | 2019-01-24 21:16:39 -0800 | [diff] [blame] | 119 | |
| 120 | prebuilt_etc { |
| 121 | name: "logtagd.rc", |
| 122 | src: "logtagd.rc", |
| 123 | sub_dir: "init", |
| 124 | } |
Tom Cherry | 43f3f76 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 125 | |
| 126 | // ----------------------------------------------------------------------------- |
| 127 | // Unit tests. |
| 128 | // ----------------------------------------------------------------------------- |
| 129 | |
| 130 | cc_defaults { |
| 131 | name: "logd-unit-test-defaults", |
| 132 | |
| 133 | cflags: [ |
| 134 | "-fstack-protector-all", |
| 135 | "-g", |
| 136 | "-Wall", |
| 137 | "-Wextra", |
| 138 | "-Werror", |
| 139 | "-fno-builtin", |
Tom Cherry | b398a7c | 2020-05-20 12:09:22 -0700 | [diff] [blame] | 140 | ] + event_flag, |
Tom Cherry | 43f3f76 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 141 | |
| 142 | srcs: [ |
Tom Cherry | e18346d | 2020-05-21 12:13:20 -0700 | [diff] [blame] | 143 | "ChattyLogBufferTest.cpp", |
Tom Cherry | 43f3f76 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 144 | "logd_test.cpp", |
| 145 | "LogBufferTest.cpp", |
Tom Cherry | 1a796bc | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 146 | "SerializedLogChunkTest.cpp", |
| 147 | "SerializedFlushToStateTest.cpp", |
Tom Cherry | 43f3f76 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 148 | ], |
| 149 | |
| 150 | static_libs: [ |
| 151 | "libbase", |
| 152 | "libcutils", |
| 153 | "liblog", |
| 154 | "liblogd", |
| 155 | "libselinux", |
Tom Cherry | 1a796bc | 2020-05-13 09:28:37 -0700 | [diff] [blame] | 156 | "libz", |
| 157 | "libzstd", |
Tom Cherry | 43f3f76 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 158 | ], |
| 159 | } |
| 160 | |
| 161 | // Build tests for the logger. Run with: |
| 162 | // adb shell /data/nativetest/logd-unit-tests/logd-unit-tests |
| 163 | cc_test { |
| 164 | name: "logd-unit-tests", |
Tom Cherry | a515197 | 2020-05-15 11:39:58 -0700 | [diff] [blame] | 165 | host_supported: true, |
Tom Cherry | 43f3f76 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 166 | defaults: ["logd-unit-test-defaults"], |
| 167 | } |
| 168 | |
| 169 | cc_test { |
| 170 | name: "CtsLogdTestCases", |
| 171 | defaults: ["logd-unit-test-defaults"], |
| 172 | multilib: { |
| 173 | lib32: { |
| 174 | suffix: "32", |
| 175 | }, |
| 176 | lib64: { |
| 177 | suffix: "64", |
| 178 | }, |
| 179 | }, |
| 180 | test_suites: [ |
| 181 | "cts", |
Tom Cherry | b4bc99e | 2020-07-28 13:21:13 -0700 | [diff] [blame] | 182 | "device-tests", |
Tom Cherry | 43f3f76 | 2020-05-14 22:28:09 -0700 | [diff] [blame] | 183 | "vts10", |
| 184 | ], |
| 185 | } |
Tom Cherry | ec39a3f | 2020-07-09 09:51:16 -0700 | [diff] [blame] | 186 | |
| 187 | cc_binary { |
| 188 | name: "replay_messages", |
| 189 | defaults: ["logd_defaults"], |
| 190 | host_supported: true, |
| 191 | |
| 192 | srcs: [ |
| 193 | "ReplayMessages.cpp", |
| 194 | ], |
| 195 | |
| 196 | static_libs: [ |
| 197 | "libbase", |
| 198 | "libcutils", |
| 199 | "liblog", |
| 200 | "liblogd", |
| 201 | "libselinux", |
| 202 | "libz", |
| 203 | "libzstd", |
| 204 | ], |
| 205 | } |