blob: 036cb7e4483058d737df3d23141dedf27d6db505 [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",
60 "LogStatistics.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070061 "LogTags.cpp",
Tom Cherry0efb4102020-06-16 10:14:09 -070062 "PruneList.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -070063 "SerializedFlushToState.cpp",
64 "SerializedLogBuffer.cpp",
65 "SerializedLogChunk.cpp",
Tom Cherry8f613462020-05-12 12:46:43 -070066 "SimpleLogBuffer.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070067 ],
68 logtags: ["event.logtags"],
69
70 export_include_dirs: ["."],
Steven Morelandfca20d82017-06-27 18:20:18 -070071}
72
73cc_binary {
74 name: "logd",
Tom Cherry73953962020-05-15 10:58:43 -070075 defaults: ["logd_defaults"],
Steven Morelandfca20d82017-06-27 18:20:18 -070076 init_rc: ["logd.rc"],
77
Tom Cherry73953962020-05-15 10:58:43 -070078 srcs: [
79 "main.cpp",
80 "LogPermissions.cpp",
81 "CommandListener.cpp",
82 "LogListener.cpp",
83 "LogReader.cpp",
84 "LogAudit.cpp",
85 "LogKlog.cpp",
86 "libaudit.cpp",
87 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070088
Tom Cherry9e124332019-01-17 11:37:22 -080089 static_libs: [
90 "liblog",
91 "liblogd",
92 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070093
94 shared_libs: [
95 "libsysutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070096 "libcutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070097 "libpackagelistparser",
Suren Baghdasaryan94910782019-01-25 05:32:52 +000098 "libprocessgroup",
Steven Morelandfca20d82017-06-27 18:20:18 -070099 "libcap",
100 ],
Steven Morelandfca20d82017-06-27 18:20:18 -0700101}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800102
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700103cc_binary {
104 name: "auditctl",
105
Tom Cherry73953962020-05-15 10:58:43 -0700106 srcs: [
107 "auditctl.cpp",
108 "libaudit.cpp",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700109 ],
110
111 shared_libs: ["libbase"],
112
113 cflags: [
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700114 "-Wextra",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700115 ],
116}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800117
118prebuilt_etc {
119 name: "logtagd.rc",
120 src: "logtagd.rc",
121 sub_dir: "init",
122}
Tom Cherry43f3f762020-05-14 22:28:09 -0700123
124// -----------------------------------------------------------------------------
125// Unit tests.
126// -----------------------------------------------------------------------------
127
128cc_defaults {
129 name: "logd-unit-test-defaults",
130
131 cflags: [
132 "-fstack-protector-all",
133 "-g",
134 "-Wall",
135 "-Wextra",
136 "-Werror",
137 "-fno-builtin",
Tom Cherryb398a7c2020-05-20 12:09:22 -0700138 ] + event_flag,
Tom Cherry43f3f762020-05-14 22:28:09 -0700139
140 srcs: [
Tom Cherrye18346d2020-05-21 12:13:20 -0700141 "ChattyLogBufferTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700142 "logd_test.cpp",
143 "LogBufferTest.cpp",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700144 "SerializedLogChunkTest.cpp",
145 "SerializedFlushToStateTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700146 ],
147
148 static_libs: [
149 "libbase",
150 "libcutils",
151 "liblog",
152 "liblogd",
153 "libselinux",
Tom Cherry1a796bc2020-05-13 09:28:37 -0700154 "libz",
155 "libzstd",
Tom Cherry43f3f762020-05-14 22:28:09 -0700156 ],
157}
158
159// Build tests for the logger. Run with:
160// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
161cc_test {
162 name: "logd-unit-tests",
Tom Cherrya5151972020-05-15 11:39:58 -0700163 host_supported: true,
Tom Cherry43f3f762020-05-14 22:28:09 -0700164 defaults: ["logd-unit-test-defaults"],
165}
166
167cc_test {
168 name: "CtsLogdTestCases",
169 defaults: ["logd-unit-test-defaults"],
170 multilib: {
171 lib32: {
172 suffix: "32",
173 },
174 lib64: {
175 suffix: "64",
176 },
177 },
178 test_suites: [
179 "cts",
180 "vts10",
181 ],
182}