blob: a7de56180d42d0bd3b12135437dd4046018c94d0 [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 Cherry73953962020-05-15 10:58:43 -070061 "LogReaderList.cpp",
62 "LogReaderThread.cpp",
63 "LogBufferElement.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 Cherry0efb4102020-06-16 10:14:09 -070067 "PruneList.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -070068 "SerializedFlushToState.cpp",
69 "SerializedLogBuffer.cpp",
70 "SerializedLogChunk.cpp",
Tom Cherry8f613462020-05-12 12:46:43 -070071 "SimpleLogBuffer.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070072 ],
Tom Cherry3d8b7392020-09-16 11:32:47 -070073 static_libs: ["liblog"],
Tom Cherry73953962020-05-15 10:58:43 -070074 logtags: ["event.logtags"],
75
76 export_include_dirs: ["."],
Steven Morelandfca20d82017-06-27 18:20:18 -070077}
78
79cc_binary {
80 name: "logd",
Tom Cherry73953962020-05-15 10:58:43 -070081 defaults: ["logd_defaults"],
Steven Morelandfca20d82017-06-27 18:20:18 -070082 init_rc: ["logd.rc"],
83
Tom Cherry73953962020-05-15 10:58:43 -070084 srcs: [
85 "main.cpp",
86 "LogPermissions.cpp",
87 "CommandListener.cpp",
88 "LogListener.cpp",
89 "LogReader.cpp",
90 "LogAudit.cpp",
91 "LogKlog.cpp",
92 "libaudit.cpp",
93 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070094
Tom Cherry9e124332019-01-17 11:37:22 -080095 static_libs: [
96 "liblog",
97 "liblogd",
98 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070099
100 shared_libs: [
101 "libsysutils",
Steven Morelandfca20d82017-06-27 18:20:18 -0700102 "libcutils",
Steven Morelandfca20d82017-06-27 18:20:18 -0700103 "libpackagelistparser",
Suren Baghdasaryan94910782019-01-25 05:32:52 +0000104 "libprocessgroup",
Steven Morelandfca20d82017-06-27 18:20:18 -0700105 "libcap",
106 ],
Steven Morelandfca20d82017-06-27 18:20:18 -0700107}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800108
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700109cc_binary {
110 name: "auditctl",
111
Tom Cherry73953962020-05-15 10:58:43 -0700112 srcs: [
113 "auditctl.cpp",
114 "libaudit.cpp",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700115 ],
116
117 shared_libs: ["libbase"],
118
119 cflags: [
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700120 "-Wextra",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700121 ],
122}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800123
124prebuilt_etc {
125 name: "logtagd.rc",
126 src: "logtagd.rc",
127 sub_dir: "init",
128}
Tom Cherry43f3f762020-05-14 22:28:09 -0700129
130// -----------------------------------------------------------------------------
131// Unit tests.
132// -----------------------------------------------------------------------------
133
134cc_defaults {
135 name: "logd-unit-test-defaults",
136
137 cflags: [
138 "-fstack-protector-all",
139 "-g",
140 "-Wall",
141 "-Wextra",
142 "-Werror",
143 "-fno-builtin",
Tom Cherryb398a7c2020-05-20 12:09:22 -0700144 ] + event_flag,
Tom Cherry43f3f762020-05-14 22:28:09 -0700145
146 srcs: [
Tom Cherrye18346d2020-05-21 12:13:20 -0700147 "ChattyLogBufferTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700148 "logd_test.cpp",
149 "LogBufferTest.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700150 "SerializedLogChunkTest.cpp",
151 "SerializedFlushToStateTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700152 ],
Tom Cherryd96139f2020-09-23 09:34:15 -0700153 sanitize: {
154 cfi: true,
155 },
Tom Cherry43f3f762020-05-14 22:28:09 -0700156 static_libs: [
157 "libbase",
158 "libcutils",
159 "liblog",
160 "liblogd",
161 "libselinux",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700162 "libz",
163 "libzstd",
Tom Cherry43f3f762020-05-14 22:28:09 -0700164 ],
165}
166
167// Build tests for the logger. Run with:
168// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
169cc_test {
170 name: "logd-unit-tests",
Tom Cherrya5151972020-05-15 11:39:58 -0700171 host_supported: true,
Tom Cherry43f3f762020-05-14 22:28:09 -0700172 defaults: ["logd-unit-test-defaults"],
173}
174
175cc_test {
176 name: "CtsLogdTestCases",
177 defaults: ["logd-unit-test-defaults"],
178 multilib: {
179 lib32: {
180 suffix: "32",
181 },
182 lib64: {
183 suffix: "64",
184 },
185 },
186 test_suites: [
187 "cts",
Tom Cherryb4bc99e2020-07-28 13:21:13 -0700188 "device-tests",
Tom Cherry43f3f762020-05-14 22:28:09 -0700189 ],
190}
Tom Cherryec39a3f2020-07-09 09:51:16 -0700191
192cc_binary {
193 name: "replay_messages",
194 defaults: ["logd_defaults"],
195 host_supported: true,
196
197 srcs: [
198 "ReplayMessages.cpp",
199 ],
200
201 static_libs: [
202 "libbase",
203 "libcutils",
204 "liblog",
205 "liblogd",
206 "libselinux",
207 "libz",
208 "libzstd",
209 ],
210}