blob: 1f6ab3467def2787c2b733a80aba37b0751fd9dd [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"],
Tom Cherrya5151972020-05-15 11:39:58 -070048 host_supported: true,
Tom Cherry73953962020-05-15 10:58:43 -070049 srcs: [
50 "ChattyLogBuffer.cpp",
51 "LogReaderList.cpp",
52 "LogReaderThread.cpp",
53 "LogBufferElement.cpp",
54 "LogStatistics.cpp",
55 "LogWhiteBlackList.cpp",
56 "LogTags.cpp",
Tom Cherry8f613462020-05-12 12:46:43 -070057 "SimpleLogBuffer.cpp",
Tom Cherry73953962020-05-15 10:58:43 -070058 ],
59 logtags: ["event.logtags"],
60
61 export_include_dirs: ["."],
Steven Morelandfca20d82017-06-27 18:20:18 -070062}
63
64cc_binary {
65 name: "logd",
Tom Cherry73953962020-05-15 10:58:43 -070066 defaults: ["logd_defaults"],
Steven Morelandfca20d82017-06-27 18:20:18 -070067 init_rc: ["logd.rc"],
68
Tom Cherry73953962020-05-15 10:58:43 -070069 srcs: [
70 "main.cpp",
71 "LogPermissions.cpp",
72 "CommandListener.cpp",
73 "LogListener.cpp",
74 "LogReader.cpp",
75 "LogAudit.cpp",
76 "LogKlog.cpp",
77 "libaudit.cpp",
78 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070079
Tom Cherry9e124332019-01-17 11:37:22 -080080 static_libs: [
81 "liblog",
82 "liblogd",
83 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070084
85 shared_libs: [
86 "libsysutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070087 "libcutils",
Steven Morelandfca20d82017-06-27 18:20:18 -070088 "libpackagelistparser",
Suren Baghdasaryan94910782019-01-25 05:32:52 +000089 "libprocessgroup",
Steven Morelandfca20d82017-06-27 18:20:18 -070090 "libcap",
91 ],
Steven Morelandfca20d82017-06-27 18:20:18 -070092}
Sasha Smundak3a62fc42019-01-24 21:16:39 -080093
Nick Kralevichbe5e4462019-04-09 10:59:39 -070094cc_binary {
95 name: "auditctl",
96
Tom Cherry73953962020-05-15 10:58:43 -070097 srcs: [
98 "auditctl.cpp",
99 "libaudit.cpp",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700100 ],
101
102 shared_libs: ["libbase"],
103
104 cflags: [
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700105 "-Wextra",
Nick Kralevichbe5e4462019-04-09 10:59:39 -0700106 ],
107}
Sasha Smundak3a62fc42019-01-24 21:16:39 -0800108
109prebuilt_etc {
110 name: "logtagd.rc",
111 src: "logtagd.rc",
112 sub_dir: "init",
113}
Tom Cherry43f3f762020-05-14 22:28:09 -0700114
115// -----------------------------------------------------------------------------
116// Unit tests.
117// -----------------------------------------------------------------------------
118
119cc_defaults {
120 name: "logd-unit-test-defaults",
121
122 cflags: [
123 "-fstack-protector-all",
124 "-g",
125 "-Wall",
126 "-Wextra",
127 "-Werror",
128 "-fno-builtin",
Tom Cherryb398a7c2020-05-20 12:09:22 -0700129 ] + event_flag,
Tom Cherry43f3f762020-05-14 22:28:09 -0700130
131 srcs: [
Tom Cherrye18346d2020-05-21 12:13:20 -0700132 "ChattyLogBufferTest.cpp",
Tom Cherry43f3f762020-05-14 22:28:09 -0700133 "logd_test.cpp",
134 "LogBufferTest.cpp",
135 ],
136
137 static_libs: [
138 "libbase",
139 "libcutils",
140 "liblog",
141 "liblogd",
142 "libselinux",
143 ],
144}
145
146// Build tests for the logger. Run with:
147// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
148cc_test {
149 name: "logd-unit-tests",
Tom Cherrya5151972020-05-15 11:39:58 -0700150 host_supported: true,
Tom Cherry43f3f762020-05-14 22:28:09 -0700151 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}