platform_system_core/logd/Android.bp
Tom Cherry a515197266 logd: build liblogd and its test on host
Plus the various fixups needed for building on host.

Test: run these tests on host
Change-Id: I85e6c989068f80c5a80eaf5ad149fdad0a045c08
2020-05-18 15:54:06 -07:00

170 lines
3.6 KiB
Text

// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This is what we want to do:
// event_logtags = $(shell
// sed -n
// "s/^\([0-9]*\)[ \t]*$1[ \t].*/-D`echo $1 | tr a-z A-Z`_LOG_TAG=\1/p"
// $(LOCAL_PATH)/$2/event.logtags)
// event_flag := $(call event_logtags,auditd)
// event_flag += $(call event_logtags,logd)
// event_flag += $(call event_logtags,tag_def)
// so make sure we do not regret hard-coding it as follows:
event_flag = [
"-DAUDITD_LOG_TAG=1003",
"-DCHATTY_LOG_TAG=1004",
"-DTAG_DEF_LOG_TAG=1005",
"-DLIBLOG_LOG_TAG=1006",
]
cc_defaults {
name: "logd_defaults",
shared_libs: ["libbase"],
cflags: [
"-Wextra",
"-Wthread-safety",
] + event_flag,
lto: {
thin: true,
},
}
cc_library_static {
name: "liblogd",
defaults: ["logd_defaults"],
host_supported: true,
srcs: [
"ChattyLogBuffer.cpp",
"LogReaderList.cpp",
"LogReaderThread.cpp",
"LogBufferElement.cpp",
"LogStatistics.cpp",
"LogWhiteBlackList.cpp",
"LogTags.cpp",
],
logtags: ["event.logtags"],
export_include_dirs: ["."],
}
cc_binary {
name: "logd",
defaults: ["logd_defaults"],
init_rc: ["logd.rc"],
srcs: [
"main.cpp",
"LogPermissions.cpp",
"CommandListener.cpp",
"LogListener.cpp",
"LogReader.cpp",
"LogAudit.cpp",
"LogKlog.cpp",
"libaudit.cpp",
],
static_libs: [
"liblog",
"liblogd",
],
shared_libs: [
"libsysutils",
"libcutils",
"libpackagelistparser",
"libprocessgroup",
"libcap",
],
}
cc_binary {
name: "auditctl",
srcs: [
"auditctl.cpp",
"libaudit.cpp",
],
shared_libs: ["libbase"],
cflags: [
"-Wextra",
],
}
prebuilt_etc {
name: "logtagd.rc",
src: "logtagd.rc",
sub_dir: "init",
}
// -----------------------------------------------------------------------------
// Unit tests.
// -----------------------------------------------------------------------------
cc_defaults {
name: "logd-unit-test-defaults",
cflags: [
"-fstack-protector-all",
"-g",
"-Wall",
"-Wextra",
"-Werror",
"-fno-builtin",
"-DAUDITD_LOG_TAG=1003",
"-DCHATTY_LOG_TAG=1004",
],
srcs: [
"logd_test.cpp",
"LogBufferTest.cpp",
],
static_libs: [
"libbase",
"libcutils",
"liblog",
"liblogd",
"libselinux",
],
}
// Build tests for the logger. Run with:
// adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
cc_test {
name: "logd-unit-tests",
host_supported: true,
defaults: ["logd-unit-test-defaults"],
}
cc_test {
name: "CtsLogdTestCases",
defaults: ["logd-unit-test-defaults"],
multilib: {
lib32: {
suffix: "32",
},
lib64: {
suffix: "64",
},
},
test_suites: [
"cts",
"vts10",
],
}