blob: c057ef07cc1a611cc6886edf43316313bac2653f [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 Cherry1a796bc2020-05-13 09:28:37 -070048 cpp_std: "experimental",
Tom Cherry73953962020-05-15 10:58:43 -070049}
50
51cc_library_static {
52 name: "liblogd",
53 defaults: ["logd_defaults"],
Tom Cherrya5151972020-05-15 11:39:58 -070054 host_supported: true,
Tom Cherry73953962020-05-15 10:58:43 -070055 srcs: [
56 "ChattyLogBuffer.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -070057 "CompressionEngine.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070058 "LogReaderList.cpp",
59 "LogReaderThread.cpp",
60 "LogBufferElement.cpp",
Tom Cherry39dc2212020-08-05 12:14:45 -070061 "LogSize.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070062 "LogStatistics.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070063 "LogTags.cpp",
Tom Cherry0efb4102020-06-16 10:14:09 -070064 "PruneList.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -070065 "SerializedFlushToState.cpp",
66 "SerializedLogBuffer.cpp",
67 "SerializedLogChunk.cpp",
Tom Cherry8f613462020-05-12 12:46:43 -070068 "SimpleLogBuffer.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070069 ],
Tom Cherry3d8b7392020-09-16 11:32:47 -070070 static_libs: ["liblog"],
Tom Cherry73953962020-05-15 10:58:43 -070071 logtags: ["event.logtags"],
72
73 export_include_dirs: ["."],
Steven Morelandfca20d82017-06-27 18:20:18 -070074}
75
76cc_binary {
77 name: "logd",
Tom Cherry73953962020-05-15 10:58:43 -070078 defaults: ["logd_defaults"],
Steven Morelandfca20d82017-06-27 18:20:18 -070079 init_rc: ["logd.rc"],
80
Tom Cherry73953962020-05-15 10:58:43 -070081 srcs: [
82 "main.cpp",
83 "LogPermissions.cpp",
84 "CommandListener.cpp",
85 "LogListener.cpp",
86 "LogReader.cpp",
87 "LogAudit.cpp",
88 "LogKlog.cpp",
89 "libaudit.cpp",
90 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070091
Tom Cherry9e124332019-01-17 11:37:22 -080092 static_libs: [
93 "liblog",
94 "liblogd",
95 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070096
97 shared_libs: [
98 "libsysutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070099 "libcutils",
Steven Morelandfca20d82017-06-27 18:20:18 -0700100 "libpackagelistparser",
Suren Baghdasaryan94910782019-01-25 05:32:52 +0000101 "libprocessgroup",
Steven Morelandfca20d82017-06-27 18:20:18 -0700102 "libcap",
103 ],
Steven Morelandfca20d82017-06-27 18:20:18 -0700104}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800105
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700106cc_binary {
107 name: "auditctl",
108
Tom Cherry73953962020-05-15 10:58:43 -0700109 srcs: [
110 "auditctl.cpp",
111 "libaudit.cpp",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700112 ],
113
114 shared_libs: ["libbase"],
115
116 cflags: [
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700117 "-Wextra",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700118 ],
119}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800120
121prebuilt_etc {
122 name: "logtagd.rc",
123 src: "logtagd.rc",
124 sub_dir: "init",
125}
Tom Cherry43f3f762020-05-14 22:28:09 -0700126
127// -----------------------------------------------------------------------------
128// Unit tests.
129// -----------------------------------------------------------------------------
130
131cc_defaults {
132 name: "logd-unit-test-defaults",
133
134 cflags: [
135 "-fstack-protector-all",
136 "-g",
137 "-Wall",
138 "-Wextra",
139 "-Werror",
140 "-fno-builtin",
Tom Cherryb398a7c2020-05-20 12:09:22 -0700141 ] + event_flag,
Tom Cherry43f3f762020-05-14 22:28:09 -0700142
143 srcs: [
Tom Cherrye18346d2020-05-21 12:13:20 -0700144 "ChattyLogBufferTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700145 "logd_test.cpp",
146 "LogBufferTest.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700147 "SerializedLogChunkTest.cpp",
148 "SerializedFlushToStateTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700149 ],
150
151 static_libs: [
152 "libbase",
153 "libcutils",
154 "liblog",
155 "liblogd",
156 "libselinux",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700157 "libz",
158 "libzstd",
Tom Cherry43f3f762020-05-14 22:28:09 -0700159 ],
160}
161
162// Build tests for the logger. Run with:
163// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
164cc_test {
165 name: "logd-unit-tests",
Tom Cherrya5151972020-05-15 11:39:58 -0700166 host_supported: true,
Tom Cherry43f3f762020-05-14 22:28:09 -0700167 defaults: ["logd-unit-test-defaults"],
168}
169
170cc_test {
171 name: "CtsLogdTestCases",
172 defaults: ["logd-unit-test-defaults"],
173 multilib: {
174 lib32: {
175 suffix: "32",
176 },
177 lib64: {
178 suffix: "64",
179 },
180 },
181 test_suites: [
182 "cts",
Tom Cherryb4bc99e2020-07-28 13:21:13 -0700183 "device-tests",
Tom Cherry43f3f762020-05-14 22:28:09 -0700184 "vts10",
185 ],
186}
Tom Cherryec39a3f2020-07-09 09:51:16 -0700187
188cc_binary {
189 name: "replay_messages",
190 defaults: ["logd_defaults"],
191 host_supported: true,
192
193 srcs: [
194 "ReplayMessages.cpp",
195 ],
196
197 static_libs: [
198 "libbase",
199 "libcutils",
200 "liblog",
201 "liblogd",
202 "libselinux",
203 "libz",
204 "libzstd",
205 ],
206}