| # Copyright 2022 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//common-mk/pkg_config.gni") |
| import("//common-mk/proto_library.gni") |
| import("//secagentd/tools/bpf_gen.gni") |
| |
| group("all") { |
| deps = [ |
| ":install_rsyslog_conf", |
| ":install_tmpfiles_conf", |
| ":install_upstart_conf", |
| ":secagentd", |
| ] |
| |
| if (use.test) { |
| deps += [ ":secagentd_testrunner" ] |
| } |
| } |
| |
| generate_vmlinux("vmlinux_h") { |
| vmlinux_out_dir = "include/secagentd/vmlinux" |
| btf_out_dir = "btf" |
| } |
| |
| global_use_defines = [] |
| if (use.secagentd_min_core_btf) { |
| global_use_defines += [ "USE_MIN_CORE_BTF=1" ] |
| } |
| |
| generate_ebpf_skeletons("bpf_process") { |
| sources = [ "bpf/process_bpf.c" ] |
| bpf_skeleton_out_dir = "include/secagentd/bpf_skeletons" |
| if (use.secagentd_min_core_btf) { |
| # Need to match the path in ebuild src_install(). |
| btf_inout_dir = "btf" |
| } else { |
| btf_inout_dir = "" |
| } |
| defines = global_use_defines |
| deps = [ ":vmlinux_h" ] |
| } |
| |
| pkg_config("target_defaults") { |
| # NOSORT |
| pkg_deps = [ |
| "absl", |
| "libattestation-client", |
| "libbpf", |
| "libbrillo", |
| "libchrome", |
| "libfeatures", |
| "libmissiveclient", |
| "libmetrics", |
| "libtpm_manager-client", |
| "openssl", |
| "protobuf", |
| "system_api", |
| "vboot_host", |
| ] |
| defines = global_use_defines |
| } |
| |
| static_library("libsecagent") { |
| sources = [ |
| "agent_plugin.cc", |
| "bpf_utils.cc", |
| "daemon.cc", |
| "factories.cc", |
| "message_sender.cc", |
| "metrics_sender.cc", |
| "process_bpf_skeleton.cc", |
| "process_cache.cc", |
| "process_plugin.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| deps = [ |
| ":bpf_process", |
| "proto:security_xdr_events_proto", |
| ] |
| } |
| |
| executable("secagentd") { |
| sources = [ "main.cc" ] |
| libs = [ "policy" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":libsecagent" ] |
| } |
| |
| # Install Upstart configuration. |
| install_config("install_upstart_conf") { |
| sources = [ "secagentd.conf" ] |
| install_path = "/etc/init" |
| } |
| |
| # Redirects log messages to /var/log/secagentd.log. |
| install_config("install_rsyslog_conf") { |
| sources = [ "rsyslog/rsyslog.secagentd.conf" ] |
| install_path = "/etc/rsyslog.d" |
| } |
| |
| # Creates secagentd.log entry. |
| install_config("install_tmpfiles_conf") { |
| sources = [ "tmpfiles.d/secagentd.conf" ] |
| install_path = "/usr/lib/tmpfiles.d" |
| } |
| |
| if (use.test) { |
| pkg_config("secagentd_testrunner_config") { |
| pkg_deps = [ |
| "libattestation-client-test", |
| "libchrome-test", |
| "libtpm_manager-client-test", |
| ] |
| } |
| |
| executable("secagentd_testrunner") { |
| sources = [ |
| "test/agent_plugin_test.cc", |
| "test/bpf_skeleton_factory_tests.cc", |
| "test/message_sender_test.cc", |
| "test/metrics_sender_test.cc", |
| "test/process_cache_test.cc", |
| "test/process_plugin_test.cc", |
| ] |
| configs += [ |
| "//common-mk:test", |
| ":secagentd_testrunner_config", |
| ":target_defaults", |
| ] |
| run_test = true |
| deps = [ |
| ":libsecagent", |
| "proto:security_xdr_events_proto", |
| "//common-mk/testrunner", |
| ] |
| } |
| } |