blob: 829c95fc7072c88831d3670ab9eb79fa7969958b [file] [log] [blame]
Steven Morelandfca20d82017-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:
24event_flag = [
25 "-DAUDITD_LOG_TAG=1003",
26 "-DCHATTY_LOG_TAG=1004",
27 "-DTAG_DEF_LOG_TAG=1005",
Elliott Hughesdc699a22018-02-16 17:58:14 -080028 "-DLIBLOG_LOG_TAG=1006",
Steven Morelandfca20d82017-06-27 18:20:18 -070029]
30
Tom Cherry73953962020-05-15 10:58:43 -070031cc_defaults {
32 name: "logd_defaults",
Steven Morelandfca20d82017-06-27 18:20:18 -070033
Tom Cherry1a796bc2020-05-13 09:28:37 -070034 shared_libs: [
35 "libbase",
36 "libz",
37 ],
38 static_libs: ["libzstd"],
Tom Cherrya5edc0f2020-09-17 09:38:42 -070039 header_libs: ["libcutils_headers"],
Tom Cherry053daca2020-04-29 15:38:19 -070040 cflags: [
41 "-Wextra",
Tom Cherry64e90162020-05-07 14:44:43 -070042 "-Wthread-safety",
Tom Cherry053daca2020-04-29 15:38:19 -070043 ] + event_flag,
Tom Cherry72f1aa82020-05-13 11:03:08 -070044
45 lto: {
Tom Cherry73953962020-05-15 10:58:43 -070046 thin: true,
47 },
Tom Cherryd96139f2020-09-23 09:34:15 -070048 sanitize: {
49 cfi: true,
50 },
Tom Cherry1a796bc2020-05-13 09:28:37 -070051 cpp_std: "experimental",
Tom Cherry73953962020-05-15 10:58:43 -070052}
53
54cc_library_static {
55 name: "liblogd",
56 defaults: ["logd_defaults"],
Tom Cherrya5151972020-05-15 11:39:58 -070057 host_supported: true,
Tom Cherry73953962020-05-15 10:58:43 -070058 srcs: [
59 "ChattyLogBuffer.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -070060 "CompressionEngine.cpp",
Tom Cherryc5818862020-10-06 10:22:35 -070061 "LogBufferElement.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070062 "LogReaderList.cpp",
63 "LogReaderThread.cpp",
Tom Cherry39dc2212020-08-05 12:14:45 -070064 "LogSize.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070065 "LogStatistics.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070066 "LogTags.cpp",
Tom Cherryc5818862020-10-06 10:22:35 -070067 "LogdLock.cpp",
Tom Cherry0efb4102020-06-16 10:14:09 -070068 "PruneList.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -070069 "SerializedFlushToState.cpp",
70 "SerializedLogBuffer.cpp",
71 "SerializedLogChunk.cpp",
Tom Cherry8f613462020-05-12 12:46:43 -070072 "SimpleLogBuffer.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070073 ],
Tom Cherry3d8b7392020-09-16 11:32:47 -070074 static_libs: ["liblog"],
Tom Cherry73953962020-05-15 10:58:43 -070075 logtags: ["event.logtags"],
76
77 export_include_dirs: ["."],
Steven Morelandfca20d82017-06-27 18:20:18 -070078}
79
80cc_binary {
81 name: "logd",
Tom Cherry73953962020-05-15 10:58:43 -070082 defaults: ["logd_defaults"],
Steven Morelandfca20d82017-06-27 18:20:18 -070083 init_rc: ["logd.rc"],
84
Tom Cherry73953962020-05-15 10:58:43 -070085 srcs: [
86 "main.cpp",
87 "LogPermissions.cpp",
88 "CommandListener.cpp",
89 "LogListener.cpp",
90 "LogReader.cpp",
91 "LogAudit.cpp",
92 "LogKlog.cpp",
93 "libaudit.cpp",
94 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070095
Tom Cherry9e124332019-01-17 11:37:22 -080096 static_libs: [
97 "liblog",
98 "liblogd",
99 ],
Steven Morelandfca20d82017-06-27 18:20:18 -0700100
101 shared_libs: [
102 "libsysutils",
Steven Morelandfca20d82017-06-27 18:20:18 -0700103 "libcutils",
Steven Morelandfca20d82017-06-27 18:20:18 -0700104 "libpackagelistparser",
Suren Baghdasaryan94910782019-01-25 05:32:52 +0000105 "libprocessgroup",
Steven Morelandfca20d82017-06-27 18:20:18 -0700106 "libcap",
107 ],
Steven Morelandfca20d82017-06-27 18:20:18 -0700108}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800109
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700110cc_binary {
111 name: "auditctl",
112
Tom Cherry73953962020-05-15 10:58:43 -0700113 srcs: [
114 "auditctl.cpp",
115 "libaudit.cpp",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700116 ],
117
118 shared_libs: ["libbase"],
119
120 cflags: [
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700121 "-Wextra",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700122 ],
123}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800124
125prebuilt_etc {
126 name: "logtagd.rc",
127 src: "logtagd.rc",
128 sub_dir: "init",
129}
Tom Cherry43f3f762020-05-14 22:28:09 -0700130
131// -----------------------------------------------------------------------------
132// Unit tests.
133// -----------------------------------------------------------------------------
134
135cc_defaults {
136 name: "logd-unit-test-defaults",
137
138 cflags: [
139 "-fstack-protector-all",
140 "-g",
141 "-Wall",
Tom Cherryc5818862020-10-06 10:22:35 -0700142 "-Wthread-safety",
Tom Cherry43f3f762020-05-14 22:28:09 -0700143 "-Wextra",
144 "-Werror",
145 "-fno-builtin",
Tom Cherryb398a7c2020-05-20 12:09:22 -0700146 ] + event_flag,
Tom Cherry43f3f762020-05-14 22:28:09 -0700147
148 srcs: [
Tom Cherrye18346d2020-05-21 12:13:20 -0700149 "ChattyLogBufferTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700150 "logd_test.cpp",
151 "LogBufferTest.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700152 "SerializedLogChunkTest.cpp",
153 "SerializedFlushToStateTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700154 ],
Tom Cherryd96139f2020-09-23 09:34:15 -0700155 sanitize: {
156 cfi: true,
157 },
Tom Cherry43f3f762020-05-14 22:28:09 -0700158 static_libs: [
159 "libbase",
160 "libcutils",
161 "liblog",
162 "liblogd",
163 "libselinux",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700164 "libz",
165 "libzstd",
Tom Cherry43f3f762020-05-14 22:28:09 -0700166 ],
167}
168
169// Build tests for the logger. Run with:
170// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
171cc_test {
172 name: "logd-unit-tests",
Tom Cherrya5151972020-05-15 11:39:58 -0700173 host_supported: true,
Tom Cherry43f3f762020-05-14 22:28:09 -0700174 defaults: ["logd-unit-test-defaults"],
175}
176
177cc_test {
178 name: "CtsLogdTestCases",
179 defaults: ["logd-unit-test-defaults"],
180 multilib: {
181 lib32: {
182 suffix: "32",
183 },
184 lib64: {
185 suffix: "64",
186 },
187 },
188 test_suites: [
189 "cts",
Tom Cherryb4bc99e2020-07-28 13:21:13 -0700190 "device-tests",
Tom Cherry43f3f762020-05-14 22:28:09 -0700191 ],
192}
Tom Cherryec39a3f2020-07-09 09:51:16 -0700193
194cc_binary {
195 name: "replay_messages",
196 defaults: ["logd_defaults"],
197 host_supported: true,
198
199 srcs: [
200 "ReplayMessages.cpp",
201 ],
202
203 static_libs: [
204 "libbase",
205 "libcutils",
206 "liblog",
207 "liblogd",
208 "libselinux",
209 "libz",
210 "libzstd",
211 ],
212}