blob: 2f1e06c38e0b5a28da3a7b6ba2ea99505a300188 [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") {
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",
"--chrome-version-file=${policy_resources_dir}/VERSION",
"--target-platform=chromeos",
"--policy-templates-file=${policy_resources_dir}/policy_templates.json",
]
}
pkg_config("libauthpolicy_config") {
pkg_deps = [
"dbus-1",
"libbrillo",
"libchrome",
"libpcrecpp",
"libsession_manager-client",
]
}
# 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",
"auth_data_cache.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 = [
"installattributes",
"policy",
]
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") {
# NOSORT
pkg_deps = [
"libbrillo",
"libcap",
"libchrome",
"libmetrics",
"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",
]
if (use.fuzzer) {
pkg_deps += [ "protobuf" ]
} else {
pkg_deps += [ "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") {
# NOSORT
pkg_deps = [
"libbrillo",
"libcap",
"libchrome",
"libchrome-test",
"libmetrics",
"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",
]
if (use.fuzzer) {
pkg_deps += [ "protobuf" ]
} else {
pkg_deps += [ "protobuf-lite" ]
}
}
executable("authpolicy_test") {
configs += [
"//common-mk:test",
":authpolicy_test_config",
":target_defaults",
]
sources = [
"anonymizer_test.cc",
"auth_data_cache_test.cc",
"authpolicy_flags_test.cc",
"authpolicy_test.cc",
"gpo_version_cache_test.cc",
"policy/device_policy_encoder_test.cc",
"policy/extension_policy_encoder_test.cc",
"policy/preg_parser_test.cc",
"policy/preg_policy_encoder_test.cc",
"policy/preg_policy_writer.cc",
"policy/user_policy_encoder_test.cc",
"process_executor_test.cc",
"samba_helper_test.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" ]
}
static_library("stub_common") {
configs += [
":stub_common_config",
":target_defaults",
]
sources = [ "stub_common.cc" ]
}
pkg_config("stub_net_config") {
pkg_deps = [
"libcap",
"libchrome",
"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",
"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",
"libchrome",
"libchrome-test",
]
}
executable("preg_parser_fuzzer") {
configs += [
"//common-mk/common_fuzzer",
":preg_parser_fuzzer_config",
":target_defaults",
]
sources = [ "policy/preg_parser_fuzzer.cc" ]
deps = [ ":libauthpolicy" ]
}
}