blob: 32bfefea2bd454e5259ca410ff8e3911eb836133 [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
34 shared_libs: ["libbase"],
Tom Cherry053daca2020-04-29 15:38:19 -070035 cflags: [
36 "-Wextra",
Tom Cherry64e90162020-05-07 14:44:43 -070037 "-Wthread-safety",
Tom Cherry053daca2020-04-29 15:38:19 -070038 ] + event_flag,
Tom Cherry72f1aa82020-05-13 11:03:08 -070039
40 lto: {
Tom Cherry73953962020-05-15 10:58:43 -070041 thin: true,
42 },
43}
44
45cc_library_static {
46 name: "liblogd",
47 defaults: ["logd_defaults"],
48
49 srcs: [
50 "ChattyLogBuffer.cpp",
51 "LogReaderList.cpp",
52 "LogReaderThread.cpp",
53 "LogBufferElement.cpp",
54 "LogStatistics.cpp",
55 "LogWhiteBlackList.cpp",
56 "LogTags.cpp",
57 ],
58 logtags: ["event.logtags"],
59
60 export_include_dirs: ["."],
Steven Morelandfca20d82017-06-27 18:20:18 -070061}
62
63cc_binary {
64 name: "logd",
Tom Cherry73953962020-05-15 10:58:43 -070065 defaults: ["logd_defaults"],
Steven Morelandfca20d82017-06-27 18:20:18 -070066 init_rc: ["logd.rc"],
67
Tom Cherry73953962020-05-15 10:58:43 -070068 srcs: [
69 "main.cpp",
70 "LogPermissions.cpp",
71 "CommandListener.cpp",
72 "LogListener.cpp",
73 "LogReader.cpp",
74 "LogAudit.cpp",
75 "LogKlog.cpp",
76 "libaudit.cpp",
77 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070078
Tom Cherry9e124332019-01-17 11:37:22 -080079 static_libs: [
80 "liblog",
81 "liblogd",
82 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070083
84 shared_libs: [
85 "libsysutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070086 "libcutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070087 "libpackagelistparser",
Suren Baghdasaryan94910782019-01-25 05:32:52 +000088 "libprocessgroup",
Steven Morelandfca20d82017-06-27 18:20:18 -070089 "libcap",
90 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070091}
Sasha Smundak3a62fc42019-01-24 21:16:39 -080092
Nick Kralevichbe5e4462019-04-09 10:59:39 -070093cc_binary {
94 name: "auditctl",
95
Tom Cherry73953962020-05-15 10:58:43 -070096 srcs: [
97 "auditctl.cpp",
98 "libaudit.cpp",
Nick Kralevichbe5e4462019-04-09 10:59:39 -070099 ],
100
101 shared_libs: ["libbase"],
102
103 cflags: [
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700104 "-Wextra",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700105 ],
106}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800107
108prebuilt_etc {
109 name: "logtagd.rc",
110 src: "logtagd.rc",
111 sub_dir: "init",
112}
Tom Cherry43f3f762020-05-14 22:28:09 -0700113
114// -----------------------------------------------------------------------------
115// Unit tests.
116// -----------------------------------------------------------------------------
117
118cc_defaults {
119 name: "logd-unit-test-defaults",
120
121 cflags: [
122 "-fstack-protector-all",
123 "-g",
124 "-Wall",
125 "-Wextra",
126 "-Werror",
127 "-fno-builtin",
128
129 "-DAUDITD_LOG_TAG=1003",
130 "-DCHATTY_LOG_TAG=1004",
131 ],
132
133 srcs: [
134 "logd_test.cpp",
135 "LogBufferTest.cpp",
136 ],
137
138 static_libs: [
139 "libbase",
140 "libcutils",
141 "liblog",
142 "liblogd",
143 "libselinux",
144 ],
145}
146
147// Build tests for the logger. Run with:
148// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
149cc_test {
150 name: "logd-unit-tests",
151 defaults: ["logd-unit-test-defaults"],
152}
153
154cc_test {
155 name: "CtsLogdTestCases",
156 defaults: ["logd-unit-test-defaults"],
157 multilib: {
158 lib32: {
159 suffix: "32",
160 },
161 lib64: {
162 suffix: "64",
163 },
164 },
165 test_suites: [
166 "cts",
167 "vts10",
168 ],
169}