blob: 7f67ab0bef01e4e50c48a90942fd0ac7abbe86d8 [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 ],
69 logtags: ["event.logtags"],
70
71 export_include_dirs: ["."],
Steven Morelandfca20d82017-06-27 18:20:18 -070072}
73
74cc_binary {
75 name: "logd",
Tom Cherry73953962020-05-15 10:58:43 -070076 defaults: ["logd_defaults"],
Steven Morelandfca20d82017-06-27 18:20:18 -070077 init_rc: ["logd.rc"],
78
Tom Cherry73953962020-05-15 10:58:43 -070079 srcs: [
80 "main.cpp",
81 "LogPermissions.cpp",
82 "CommandListener.cpp",
83 "LogListener.cpp",
84 "LogReader.cpp",
85 "LogAudit.cpp",
86 "LogKlog.cpp",
87 "libaudit.cpp",
88 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070089
Tom Cherry9e124332019-01-17 11:37:22 -080090 static_libs: [
91 "liblog",
92 "liblogd",
93 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070094
95 shared_libs: [
96 "libsysutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070097 "libcutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070098 "libpackagelistparser",
Suren Baghdasaryan94910782019-01-25 05:32:52 +000099 "libprocessgroup",
Steven Morelandfca20d82017-06-27 18:20:18 -0700100 "libcap",
101 ],
Steven Morelandfca20d82017-06-27 18:20:18 -0700102}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800103
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700104cc_binary {
105 name: "auditctl",
106
Tom Cherry73953962020-05-15 10:58:43 -0700107 srcs: [
108 "auditctl.cpp",
109 "libaudit.cpp",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700110 ],
111
112 shared_libs: ["libbase"],
113
114 cflags: [
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700115 "-Wextra",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700116 ],
117}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800118
119prebuilt_etc {
120 name: "logtagd.rc",
121 src: "logtagd.rc",
122 sub_dir: "init",
123}
Tom Cherry43f3f762020-05-14 22:28:09 -0700124
125// -----------------------------------------------------------------------------
126// Unit tests.
127// -----------------------------------------------------------------------------
128
129cc_defaults {
130 name: "logd-unit-test-defaults",
131
132 cflags: [
133 "-fstack-protector-all",
134 "-g",
135 "-Wall",
136 "-Wextra",
137 "-Werror",
138 "-fno-builtin",
Tom Cherryb398a7c2020-05-20 12:09:22 -0700139 ] + event_flag,
Tom Cherry43f3f762020-05-14 22:28:09 -0700140
141 srcs: [
Tom Cherrye18346d2020-05-21 12:13:20 -0700142 "ChattyLogBufferTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700143 "logd_test.cpp",
144 "LogBufferTest.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700145 "SerializedLogChunkTest.cpp",
146 "SerializedFlushToStateTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700147 ],
148
149 static_libs: [
150 "libbase",
151 "libcutils",
152 "liblog",
153 "liblogd",
154 "libselinux",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700155 "libz",
156 "libzstd",
Tom Cherry43f3f762020-05-14 22:28:09 -0700157 ],
158}
159
160// Build tests for the logger. Run with:
161// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
162cc_test {
163 name: "logd-unit-tests",
Tom Cherrya5151972020-05-15 11:39:58 -0700164 host_supported: true,
Tom Cherry43f3f762020-05-14 22:28:09 -0700165 defaults: ["logd-unit-test-defaults"],
166}
167
168cc_test {
169 name: "CtsLogdTestCases",
170 defaults: ["logd-unit-test-defaults"],
171 multilib: {
172 lib32: {
173 suffix: "32",
174 },
175 lib64: {
176 suffix: "64",
177 },
178 },
179 test_suites: [
180 "cts",
Tom Cherryb4bc99e2020-07-28 13:21:13 -0700181 "device-tests",
Tom Cherry43f3f762020-05-14 22:28:09 -0700182 "vts10",
183 ],
184}
Tom Cherryec39a3f2020-07-09 09:51:16 -0700185
186cc_binary {
187 name: "replay_messages",
188 defaults: ["logd_defaults"],
189 host_supported: true,
190
191 srcs: [
192 "ReplayMessages.cpp",
193 ],
194
195 static_libs: [
196 "libbase",
197 "libcutils",
198 "liblog",
199 "liblogd",
200 "libselinux",
201 "libz",
202 "libzstd",
203 ],
204}