| # Copyright 2019 The ChromiumOS Authors | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| # TODO: Fix the visibility on these shared libs. | |
| # gnlint: disable=GnLintVisibilityFlags | |
| import("//common-mk/generate-dbus-adaptors.gni") | |
| import("//common-mk/generate-dbus-proxies.gni") | |
| import("//common-mk/pkg_config.gni") | |
| import("//common-mk/proto_library.gni") | |
| group("all") { | |
| deps = [ | |
| ":attestation_client", | |
| ":attestationd", | |
| ":install_init", | |
| ":install_minijail_conf", | |
| ":install_policy", | |
| ":install_systemd", | |
| ":install_tmpfiles_config", | |
| ":libattestation", | |
| ":pca_agent_client", | |
| ":pca_agentd", | |
| ] | |
| if (use.test) { | |
| deps += [ ":attestation_testrunner" ] | |
| } | |
| } | |
| config("local_print_proto_include") { | |
| # This config is used when any build target used the print_proto. | |
| include_dirs = [ "${target_gen_dir}/.." ] | |
| } | |
| pkg_config("target_defaults") { | |
| pkg_deps = [ | |
| # This is a list of pkg-config dependencies | |
| "libbrillo", | |
| "libchrome", | |
| "libcrossystem", | |
| ] | |
| if (use.fuzzer) { | |
| pkg_deps += [ "protobuf" ] | |
| } else { | |
| pkg_deps += [ "protobuf-lite" ] | |
| } | |
| defines = [ | |
| "USE_TPM1=${use.tpm}", | |
| "USE_TPM2=${use.tpm2}", | |
| "USE_TPM2_SIMULATOR=${use.tpm2_simulator}", | |
| "USE_TPM_DYNAMIC=${use.tpm_dynamic}", | |
| "USE_GENERIC_TPM2=${use.generic_tpm2}", | |
| "USE_CR50_ONBOARD=${use.cr50_onboard}", | |
| "USE_TI50_ONBOARD=${use.ti50_onboard}", | |
| ] | |
| cflags = [ "-Wconsumed" ] | |
| } | |
| action("print_proto_library") { | |
| dbus_proto_path = "${sysroot}/usr/include/chromeos/dbus/attestation" | |
| script = "../libhwsec-foundation/utility/proto_print.py" | |
| inputs = [ | |
| "${dbus_proto_path}/attestation_ca.proto", | |
| "${dbus_proto_path}/interface.proto", | |
| "${dbus_proto_path}/keystore.proto", | |
| ] | |
| outputs = [ | |
| "${target_gen_dir}/common/print_attestation_ca_proto.cc", | |
| "${target_gen_dir}/common/print_interface_proto.cc", | |
| "${target_gen_dir}/common/print_keystore_proto.cc", | |
| ] | |
| args = [ | |
| "--subdir", | |
| "common", | |
| "--proto-include", | |
| "attestation/proto_bindings", | |
| "--output-dir", | |
| "${target_gen_dir}/common", | |
| ] + inputs | |
| } | |
| source_set("proto_library") { | |
| sources = get_target_outputs(":print_proto_library") | |
| configs += [ | |
| "//common-mk:nouse_thin_archive", | |
| "//common-mk:pic", | |
| ":local_print_proto_include", | |
| ":target_defaults", | |
| ] | |
| public_deps = [ ":print_proto_library" ] | |
| } | |
| # A library for common code. | |
| pkg_config("common_library_config") { | |
| pkg_deps = [ "openssl" ] | |
| libs = [ | |
| "hwsec", | |
| "hwsec-foundation", | |
| ] | |
| } | |
| config("common_library_with_tpm2_config") { | |
| libs = [ "trunks" ] | |
| } | |
| config("common_library_without_tpm2_config") { | |
| libs = [ "tspi" ] | |
| } | |
| source_set("common_library") { | |
| sources = [ | |
| "common/crypto_utility_impl.cc", | |
| "common/nvram_quoter_factory.cc", | |
| ] | |
| all_dependent_configs = [ ":common_library_config" ] | |
| configs += [ | |
| "//common-mk:nouse_thin_archive", | |
| ":target_defaults", | |
| ] | |
| deps = [ ":proto_library" ] | |
| if (use.tpm2) { | |
| all_dependent_configs += [ ":common_library_with_tpm2_config" ] | |
| } | |
| if (use.tpm) { | |
| all_dependent_configs += [ ":common_library_without_tpm2_config" ] | |
| } | |
| if (use.cr50_onboard || use.ti50_onboard) { | |
| sources += [ "common/gsc_nvram_quoter.cc" ] | |
| } else { | |
| sources += [ "common/null_nvram_quoter.cc" ] | |
| } | |
| } | |
| # A shared library for clients. | |
| shared_library("libattestation") { | |
| install_path = "lib" | |
| configs += [ | |
| "//common-mk:nouse_thin_archive", | |
| ":target_defaults", | |
| ] | |
| libs = [ "system_api" ] | |
| deps = [ ":proto_library" ] | |
| } | |
| # A client command line utility. | |
| executable("attestation_client") { | |
| sources = [ "client/main.cc" ] | |
| configs += [ | |
| ":local_print_proto_include", | |
| ":target_defaults", | |
| ] | |
| install_path = "bin" | |
| # NOSORT | |
| pkg_deps = [ | |
| # system_api depends on protobuf (or protobuf-lite). It must appear | |
| # before protobuf here or the linker flags won't be in the right | |
| # order. | |
| "system_api", | |
| "protobuf", | |
| ] | |
| deps = [ | |
| ":common_library", | |
| ":proto_library", | |
| ] | |
| } | |
| # A library for server code. | |
| config("server_library_config") { | |
| libs = [ "chaps" ] | |
| # TODO(crbug.com/1082873) Remove after fixing usage of deprecated declarations. | |
| cflags_cc = [ "-Wno-error=deprecated-declarations" ] | |
| } | |
| source_set("server_library") { | |
| sources = [ | |
| "server/attestation_flow.cc", | |
| "server/attestation_service.cc", | |
| "server/attestation_service_metrics.cc", | |
| "server/certificate_queue.cc", | |
| "server/database_impl.cc", | |
| "server/dbus_service.cc", | |
| "server/enrollment_queue.cc", | |
| "server/google_keys.cc", | |
| "server/pkcs11_key_store.cc", | |
| ] | |
| all_dependent_configs = [ ":server_library_config" ] | |
| configs += [ ":target_defaults" ] | |
| deps = [ | |
| ":pca-agent-proxies", | |
| ":proto_library", | |
| ] | |
| } | |
| # The attestation daemon. | |
| pkg_config("attestationd_config") { | |
| pkg_deps = [ | |
| "libmetrics", | |
| "libminijail", | |
| ] | |
| } | |
| executable("attestationd") { | |
| sources = [ "server/main.cc" ] | |
| configs += [ | |
| ":attestationd_config", | |
| ":target_defaults", | |
| ] | |
| install_path = "sbin" | |
| libs = [ | |
| "hwsec-profiling", | |
| "policy", | |
| ] | |
| # NOSORT | |
| pkg_deps = [ | |
| # system_api depends on protobuf (or protobuf-lite). It must appear | |
| # before protobuf here or the linker flags won't be in the right | |
| # order. | |
| "system_api", | |
| "protobuf", | |
| ] | |
| deps = [ | |
| ":common_library", | |
| ":proto_library", | |
| ":server_library", | |
| ] | |
| } | |
| generate_dbus_adaptors("pca-agent-adaptors") { | |
| sources = [ "pca_agent/dbus_bindings/org.chromium.PcaAgent.xml" ] | |
| dbus_adaptors_out_dir = "include/attestation/pca-agent/dbus_adaptors" | |
| dbus_service_config = "pca_agent/dbus_bindings/dbus-service-config.json" | |
| } | |
| generate_dbus_proxies("pca-agent-proxies") { | |
| sources = [ "pca_agent/dbus_bindings/org.chromium.PcaAgent.xml" ] | |
| dbus_service_config = "pca_agent/dbus_bindings/dbus-service-config.json" | |
| mock_output_file = "include/attestation/pca_agent/dbus-proxy-mocks.h" | |
| proxy_output_file = "include/attestation/pca_agent/dbus-proxies.h" | |
| proxy_path_in_mocks = "attestation/pca_agent/dbus-proxies.h" | |
| } | |
| source_set("pca_agent_server_library") { | |
| sources = [ | |
| "pca_agent/server/default_transport_factory.cc", | |
| "pca_agent/server/metrics.cc", | |
| "pca_agent/server/pca_agent_service.cc", | |
| "pca_agent/server/pca_request.cc", | |
| "pca_agent/server/rks_agent_service.cc", | |
| "pca_agent/server/rks_cert_fetcher.cc", | |
| ] | |
| configs += [ ":target_defaults" ] | |
| deps = [ ":pca-agent-adaptors" ] | |
| pkg_deps = [ | |
| "libmetrics", | |
| "libshill-client", | |
| "libstorage_platform", | |
| ] | |
| } | |
| executable("pca_agentd") { | |
| sources = [ "pca_agent/server/main.cc" ] | |
| configs += [ | |
| ":attestationd_config", | |
| ":target_defaults", | |
| ] | |
| install_path = "sbin" | |
| pkg_deps = [ | |
| "libshill-client", | |
| "libstorage_platform", | |
| "protobuf", | |
| "system_api", | |
| ] | |
| libs = [ "hwsec-profiling" ] | |
| deps = [ | |
| ":pca-agent-adaptors", | |
| ":pca_agent_server_library", | |
| ] | |
| } | |
| executable("pca_agent_client") { | |
| sources = [ "pca_agent/client/main.cc" ] | |
| configs += [ | |
| ":local_print_proto_include", | |
| ":target_defaults", | |
| ] | |
| install_path = "bin" | |
| # NOSORT | |
| pkg_deps = [ | |
| # system_api depends on protobuf (or protobuf-lite). It must appear | |
| # before protobuf here or the linker flags won't be in the right | |
| # order. | |
| "system_api", | |
| "protobuf", | |
| ] | |
| deps = [ | |
| ":pca-agent-proxies", | |
| ":proto_library", | |
| ] | |
| } | |
| install_config("install_systemd") { | |
| sources = [ | |
| "pca_agent/server/org.chromium.PcaAgent.conf", | |
| "server/org.chromium.Attestation.conf", | |
| ] | |
| install_path = "dbus_system_d" | |
| } | |
| install_config("install_init") { | |
| sources = [ | |
| "pca_agent/server/pca_agentd.conf", | |
| "server/attestationd.conf", | |
| ] | |
| install_path = "upstart" | |
| } | |
| install_config("install_minijail_conf") { | |
| sources = [ "pca_agent/server/minijail/pca_agentd.conf" ] | |
| install_path = "minijail_conf" | |
| } | |
| install_config("install_policy") { | |
| _arch = getenv("ARCH") | |
| sources = [ | |
| "pca_agent/server/pca_agentd-seccomp-${_arch}.policy", | |
| "server/attestationd-seccomp-${_arch}.policy", | |
| ] | |
| install_path = "seccomp_policy" | |
| # NOSORT | |
| outputs = [ | |
| "pca_agentd-seccomp.policy", | |
| "attestationd-seccomp.policy", | |
| ] | |
| } | |
| if (use.test) { | |
| pkg_config("attestation_testrunner_config") { | |
| pkg_deps = [ | |
| "libbrillo-test", | |
| "libchrome-test", | |
| "libmetrics", | |
| ] | |
| } | |
| executable("attestation_testrunner") { | |
| sources = [ | |
| "attestation_testrunner.cc", | |
| "common/crypto_utility_impl_test.cc", | |
| "common/mock_crypto_utility.cc", | |
| "pca_agent/server/pca_request_test.cc", | |
| "pca_agent/server/rks_cert_fetcher_test.cc", | |
| "server/certificate_queue_test.cc", | |
| "server/database_impl_test.cc", | |
| "server/dbus_service_test.cc", | |
| "server/enrollment_queue_test.cc", | |
| "server/mock_database.cc", | |
| "server/mock_key_store.cc", | |
| "server/pkcs11_key_store_test.cc", | |
| ] | |
| libs = [ | |
| "hwsec_test", | |
| "policy", | |
| ] | |
| if (use.tpm2) { | |
| libs += [ "trunks_test" ] | |
| } | |
| if (use.cr50_onboard || use.ti50_onboard) { | |
| sources += [ "common/gsc_nvram_quoter_test.cc" ] | |
| } | |
| if (use.tpm || use.tpm2) { | |
| sources += [ "server/attestation_service_test.cc" ] | |
| } | |
| configs += [ | |
| "//common-mk:test", | |
| ":attestation_testrunner_config", | |
| ":target_defaults", | |
| ] | |
| run_test = true | |
| pkg_deps = [ | |
| "libshill-client", | |
| "libshill-client-test", | |
| "libstorage_fake_platform", | |
| "protobuf-lite", | |
| "system_api", | |
| ] | |
| deps = [ | |
| ":common_library", | |
| ":pca_agent_server_library", | |
| ":proto_library", | |
| ":server_library", | |
| ] | |
| } | |
| } | |
| install_config("install_tmpfiles_config") { | |
| sources = [ "pca_agent/server/tmpfiles.d/pca_agent.conf" ] | |
| install_path = "tmpfilesd" | |
| } |