blob: 6c2bbafb569a61711820d5c1cb4ed9025c018d0f [file] [log] [blame]
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//common-mk/generate-dbus-adaptors.gni")
import("//common-mk/pkg_config.gni")
import("//common-mk/proto_library.gni")
group("all") {
deps = [
":authpolicy_parser",
":authpolicyd",
":container-protos",
":dbus_code_generator",
":libauthpolicy",
":policy_code_generator",
]
if (use.test) {
deps += [
":authpolicy_test",
":stub_common",
":stub_kinit",
":stub_klist",
":stub_kpasswd",
":stub_net",
":stub_smbclient",
]
}
if (use.fuzzer) {
deps += [ ":preg_parser_fuzzer" ]
}
}
config("target_defaults") {
cflags = [
"-Wshadow",
"-Wextra",
# -Wextra enables unused parameter warnings, but there are unused parameters.
"-Wno-unused-parameter",
]
}
# D-Bus code generator.
generate_dbus_adaptors("dbus_code_generator") {
new_fd_bindings = true
dbus_service_config = "dbus_bindings/dbus-service-config.json"
dbus_adaptors_out_dir = "include/authpolicy"
sources = [
"dbus_bindings/org.chromium.AuthPolicy.xml",
]
}
# Container protos
proto_library("container-protos") {
configs = [ ":target_defaults" ]
proto_in_dir = "proto"
proto_out_dir = "include/bindings"
sources = [
"${proto_in_dir}/authpolicy_containers.proto",
]
}
# Autogenerated policy sources
action("policy_code_generator") {
policy_resources_dir = "${sysroot}/usr/share/policy_resources"
out_dir = "${root_gen_dir}/include/bindings"
policy_tools_dir = "${sysroot}/usr/share/policy_tools"
script = "${policy_tools_dir}/generate_policy_source.py"
sources = [
"${policy_resources_dir}/VERSION",
"${policy_resources_dir}/policy_templates.json",
]
outputs = [
"${out_dir}/policy_constants.h",
"${out_dir}/policy_constants.cc",
]
args = [
"--cros-policy-constants-header=${out_dir}/policy_constants.h",
"--cros-policy-constants-source=${out_dir}/policy_constants.cc",
"${policy_resources_dir}/VERSION",
"${OS}",
"1", # chromeos-flag
"${policy_resources_dir}/policy_templates.json",
]
}
pkg_config("libauthpolicy_config") {
pkg_deps = [
"dbus-1",
"libbrillo-${libbase_ver}",
"libchrome-${libbase_ver}",
"libpcrecpp",
]
}
# Authpolicy library.
static_library("libauthpolicy") {
configs += [
":libauthpolicy_config",
":target_defaults",
]
gen_src_in_dir = "${root_gen_dir}/include/bindings"
sources = [
"${gen_src_in_dir}/policy_constants.cc",
"anonymizer.cc",
"authpolicy.cc",
"authpolicy_flags.cc",
"authpolicy_metrics.cc",
"constants.cc",
"cryptohome_client.cc",
"gpo_version_cache.cc",
"jail_helper.cc",
"log_colors.cc",
"path_service.cc",
"platform_helper.cc",
"policy/device_policy_encoder.cc",
"policy/extension_policy_encoder.cc",
"policy/policy_encoder_helper.cc",
"policy/preg_parser.cc",
"policy/preg_policy_encoder.cc",
"policy/user_policy_encoder.cc",
"process_executor.cc",
"samba_helper.cc",
"samba_interface.cc",
"session_manager_client.cc",
"tgt_manager.cc",
]
libs = [
"-linstallattributes-${libbase_ver}",
"-lpolicy-${libbase_ver}",
]
deps = [
":container-protos",
":dbus_code_generator",
":policy_code_generator",
"//common-mk/external_dependencies:policy-protos",
"//common-mk/external_dependencies:user_policy-protos",
]
}
pkg_config("authpolicy_parser_config") {
pkg_deps = [
"libbrillo-${libbase_ver}",
"libcap",
"libchrome-${libbase_ver}",
"libmetrics-${libbase_ver}",
"libminijail",
"libpcrecpp",
# system_api depends on protobuf (or protobuf-lite). It must
# appear before protobuf or the linker flags won't be in the right
# order.
"system_api",
"protobuf-lite",
]
}
# Parser tool.
executable("authpolicy_parser") {
configs += [
":authpolicy_parser_config",
":target_defaults",
]
sources = [
"authpolicy_parser_main.cc",
]
deps = [
":libauthpolicy",
]
}
# Authpolicy daemon executable.
executable("authpolicyd") {
configs += [
":authpolicy_parser_config",
":target_defaults",
]
sources = [
"authpolicy_main.cc",
]
deps = [
":authpolicy_parser",
":libauthpolicy",
]
}
# Unit tests.
if (use.test) {
pkg_config("authpolicy_test_config") {
pkg_deps = [
"libbrillo-${libbase_ver}",
"libcap",
"libchrome-${libbase_ver}",
"libchrome-test-${libbase_ver}",
"libmetrics-${libbase_ver}",
"libminijail",
"libpcrecpp",
# system_api depends on protobuf (or protobuf-lite). It must
# appear before protobuf or the linker flags won't be in the right
# order.
"system_api",
"protobuf-lite",
]
}
executable("authpolicy_test") {
configs += [
"//common-mk:test",
":authpolicy_test_config",
":target_defaults",
]
sources = [
"anonymizer_unittest.cc",
"authpolicy_flags_unittest.cc",
"authpolicy_unittest.cc",
"gpo_version_cache_unittest.cc",
"policy/device_policy_encoder_unittest.cc",
"policy/extension_policy_encoder_unittest.cc",
"policy/preg_parser_unittest.cc",
"policy/preg_policy_encoder_unittest.cc",
"policy/preg_policy_writer.cc",
"policy/user_policy_encoder_unittest.cc",
"process_executor_unittest.cc",
"samba_helper_unittest.cc",
]
defines = [ "UNIT_TEST" ]
deps = [
":libauthpolicy",
":stub_common",
":stub_kinit",
":stub_klist",
":stub_kpasswd",
":stub_net",
":stub_smbclient",
"//common-mk/testrunner",
]
}
pkg_config("stub_common_config") {
pkg_deps = [ "libchrome-${libbase_ver}" ]
}
static_library("stub_common") {
configs += [
":stub_common_config",
":target_defaults",
]
sources = [
"stub_common.cc",
]
}
pkg_config("stub_net_config") {
pkg_deps = [
"libcap",
"libchrome-${libbase_ver}",
"libpcrecpp",
]
}
executable("stub_net") {
configs += [
":stub_net_config",
":target_defaults",
]
sources = [
"stub_net_main.cc",
]
deps = [
":libauthpolicy",
":stub_common",
]
}
executable("stub_kinit") {
configs += [
":stub_net_config",
":target_defaults",
]
sources = [
"stub_kinit_main.cc",
]
deps = [
":libauthpolicy",
":stub_common",
]
}
pkg_config("stub_klist_config") {
pkg_deps = [
"libchrome-${libbase_ver}",
"libpcrecpp",
]
}
executable("stub_klist") {
configs += [
":stub_klist_config",
":target_defaults",
]
sources = [
"stub_klist_main.cc",
]
deps = [
":libauthpolicy",
":stub_common",
]
}
executable("stub_kpasswd") {
configs += [
":stub_klist_config",
":target_defaults",
]
sources = [
"stub_kpasswd_main.cc",
]
deps = [
":libauthpolicy",
":stub_common",
]
}
executable("stub_smbclient") {
configs += [
":stub_klist_config",
":target_defaults",
]
sources = [
"stub_smbclient_main.cc",
]
deps = [
":libauthpolicy",
":stub_common",
]
}
}
# Fuzzer target
if (use.fuzzer) {
pkg_config("preg_parser_fuzzer_config") {
pkg_deps = [
"libbrillo-${libbase_ver}",
"libchrome-${libbase_ver}",
"libchrome-test-${libbase_ver}",
]
}
executable("preg_parser_fuzzer") {
configs += [
"//common-mk/common_fuzzer",
":preg_parser_fuzzer_config",
":target_defaults",
]
sources = [
"policy/preg_parser_fuzzer.cc",
]
deps = [
":libauthpolicy",
]
}
}