blob: fe22d1caadb6ad0719a805cf5a864ff8534def8d [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 Cherry053daca2020-04-29 15:38:19 -070039 cflags: [
40 "-Wextra",
Tom Cherry64e90162020-05-07 14:44:43 -070041 "-Wthread-safety",
Tom Cherry053daca2020-04-29 15:38:19 -070042 ] + event_flag,
Tom Cherry72f1aa82020-05-13 11:03:08 -070043
44 lto: {
Tom Cherry73953962020-05-15 10:58:43 -070045 thin: true,
46 },
Tom Cherry1a796bc2020-05-13 09:28:37 -070047 cpp_std: "experimental",
Tom Cherry73953962020-05-15 10:58:43 -070048}
49
50cc_library_static {
51 name: "liblogd",
52 defaults: ["logd_defaults"],
Tom Cherrya5151972020-05-15 11:39:58 -070053 host_supported: true,
Tom Cherry73953962020-05-15 10:58:43 -070054 srcs: [
55 "ChattyLogBuffer.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -070056 "CompressionEngine.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070057 "LogReaderList.cpp",
58 "LogReaderThread.cpp",
59 "LogBufferElement.cpp",
Tom Cherry39dc2212020-08-05 12:14:45 -070060 "LogSize.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070061 "LogStatistics.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070062 "LogTags.cpp",
Tom Cherry0efb4102020-06-16 10:14:09 -070063 "PruneList.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -070064 "SerializedFlushToState.cpp",
65 "SerializedLogBuffer.cpp",
66 "SerializedLogChunk.cpp",
Tom Cherry8f613462020-05-12 12:46:43 -070067 "SimpleLogBuffer.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070068 ],
Tom Cherry3d8b7392020-09-16 11:32:47 -070069 static_libs: ["liblog"],
Tom Cherry73953962020-05-15 10:58:43 -070070 logtags: ["event.logtags"],
71
72 export_include_dirs: ["."],
Steven Morelandfca20d82017-06-27 18:20:18 -070073}
74
75cc_binary {
76 name: "logd",
Tom Cherry73953962020-05-15 10:58:43 -070077 defaults: ["logd_defaults"],
Steven Morelandfca20d82017-06-27 18:20:18 -070078 init_rc: ["logd.rc"],
79
Tom Cherry73953962020-05-15 10:58:43 -070080 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 Morelandfca20d82017-06-27 18:20:18 -070090
Tom Cherry9e124332019-01-17 11:37:22 -080091 static_libs: [
92 "liblog",
93 "liblogd",
94 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070095
96 shared_libs: [
97 "libsysutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070098 "libcutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070099 "libpackagelistparser",
Suren Baghdasaryan94910782019-01-25 05:32:52 +0000100 "libprocessgroup",
Steven Morelandfca20d82017-06-27 18:20:18 -0700101 "libcap",
102 ],
Steven Morelandfca20d82017-06-27 18:20:18 -0700103}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800104
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700105cc_binary {
106 name: "auditctl",
107
Tom Cherry73953962020-05-15 10:58:43 -0700108 srcs: [
109 "auditctl.cpp",
110 "libaudit.cpp",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700111 ],
112
113 shared_libs: ["libbase"],
114
115 cflags: [
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700116 "-Wextra",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700117 ],
118}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800119
120prebuilt_etc {
121 name: "logtagd.rc",
122 src: "logtagd.rc",
123 sub_dir: "init",
124}
Tom Cherry43f3f762020-05-14 22:28:09 -0700125
126// -----------------------------------------------------------------------------
127// Unit tests.
128// -----------------------------------------------------------------------------
129
130cc_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 Cherryb398a7c2020-05-20 12:09:22 -0700140 ] + event_flag,
Tom Cherry43f3f762020-05-14 22:28:09 -0700141
142 srcs: [
Tom Cherrye18346d2020-05-21 12:13:20 -0700143 "ChattyLogBufferTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700144 "logd_test.cpp",
145 "LogBufferTest.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700146 "SerializedLogChunkTest.cpp",
147 "SerializedFlushToStateTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700148 ],
149
150 static_libs: [
151 "libbase",
152 "libcutils",
153 "liblog",
154 "liblogd",
155 "libselinux",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700156 "libz",
157 "libzstd",
Tom Cherry43f3f762020-05-14 22:28:09 -0700158 ],
159}
160
161// Build tests for the logger. Run with:
162// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
163cc_test {
164 name: "logd-unit-tests",
Tom Cherrya5151972020-05-15 11:39:58 -0700165 host_supported: true,
Tom Cherry43f3f762020-05-14 22:28:09 -0700166 defaults: ["logd-unit-test-defaults"],
167}
168
169cc_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 Cherryb4bc99e2020-07-28 13:21:13 -0700182 "device-tests",
Tom Cherry43f3f762020-05-14 22:28:09 -0700183 "vts10",
184 ],
185}
Tom Cherryec39a3f2020-07-09 09:51:16 -0700186
187cc_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}