| # Copyright 2019 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. |
| |
| # 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", |
| ":libattestation", |
| ":pca_agent_client", |
| ":pca_agentd", |
| ] |
| if (use.test) { |
| deps += [ ":attestation_testrunner" ] |
| } |
| } |
| |
| config("local_proto_include") { |
| # This config is used when any build target used the local protobufs. |
| # The local protobuf used some other protos in system_api, so we'll need |
| # to fix the include path so that it builds correctly. |
| include_dirs = [ "${sysroot}/usr/include/attestation/proto_bindings/" ] |
| } |
| |
| pkg_config("target_defaults") { |
| pkg_deps = [ |
| # This is a list of pkg-config dependencies |
| "libbrillo", |
| "libchrome", |
| ] |
| if (use.fuzzer) { |
| pkg_deps += [ "protobuf" ] |
| } else { |
| pkg_deps += [ "protobuf-lite" ] |
| } |
| defines = [ "USE_TPM2=${use.tpm2}" ] |
| } |
| |
| # A library for just the protobufs. |
| proto_library("proto_library_proto") { |
| # Use -fPIC so this code can be linked into a shared library. |
| use_pic = true |
| proto_in_dir = "common" |
| proto_out_dir = "include/attestation/common" |
| proto_lib_dirs = [ "${sysroot}/usr/include/chromeos/dbus/attestation/" ] |
| configs = [ ":local_proto_include" ] |
| sources = [ "${proto_in_dir}/database.proto" ] |
| standalone = true |
| } |
| |
| source_set("proto_library") { |
| configs += [ |
| "//common-mk:nouse_thin_archive", |
| "//common-mk:pic", |
| |
| # TODO: Use brillo/brillo_export.h instead to export symbols. |
| "//common-mk:visibility_default", |
| ":target_defaults", |
| ] |
| sources = [ |
| "common/print_attestation_ca_proto.cc", |
| "common/print_interface_proto.cc", |
| "common/print_keystore_proto.cc", |
| ] |
| } |
| |
| # A library for common code. |
| pkg_config("common_library_config") { |
| pkg_deps = [ |
| "openssl", |
| "vboot_host", |
| ] |
| libs = [ "tpm_manager" ] |
| } |
| |
| 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/tpm_utility_factory.cc", |
| ] |
| all_dependent_configs = [ ":common_library_config" ] |
| configs += [ |
| "//common-mk:nouse_thin_archive", |
| ":target_defaults", |
| ":local_proto_include", |
| ] |
| deps = [ |
| ":proto_library", |
| ":proto_library_proto", |
| ] |
| if (use.tpm2) { |
| sources += [ |
| "common/tpm_utility_common.cc", |
| "common/tpm_utility_v2.cc", |
| ] |
| all_dependent_configs += [ ":common_library_with_tpm2_config" ] |
| } else { |
| sources += [ |
| "common/tpm_utility_common.cc", |
| "common/tpm_utility_v1.cc", |
| ] |
| all_dependent_configs += [ ":common_library_without_tpm2_config" ] |
| } |
| } |
| |
| # A library for client code. |
| source_set("client_library") { |
| configs += [ |
| "//common-mk:pic", |
| ":target_defaults", |
| "//common-mk:nouse_thin_archive", |
| ":local_proto_include", |
| |
| # TODO: Use brillo/brillo_export.h instead to export symbols. |
| "//common-mk:visibility_default", |
| ] |
| sources = [ "client/dbus_proxy.cc" ] |
| deps = [ |
| ":proto_library", |
| ":proto_library_proto", |
| ] |
| } |
| |
| # A shared library for clients. |
| shared_library("libattestation") { |
| configs += [ |
| "//common-mk:nouse_thin_archive", |
| ":local_proto_include", |
| |
| # TODO: Use brillo/brillo_export.h instead to export symbols. |
| "//common-mk:visibility_default", |
| ":target_defaults", |
| ] |
| libs = [ "system_api" ] |
| deps = [ |
| ":client_library", |
| ":proto_library", |
| ":proto_library_proto", |
| ] |
| } |
| |
| # A client command line utility. |
| executable("attestation_client") { |
| sources = [ "client/main.cc" ] |
| configs += [ |
| ":target_defaults", |
| ":local_proto_include", |
| ] |
| |
| # 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 = [ |
| ":client_library", |
| ":common_library", |
| ":proto_library", |
| ":proto_library_proto", |
| ] |
| } |
| |
| # 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", |
| ":local_proto_include", |
| ] |
| deps = [ |
| ":proto_library", |
| ":proto_library_proto", |
| ] |
| } |
| |
| # The attestation daemon. |
| pkg_config("attestationd_config") { |
| pkg_deps = [ |
| "libmetrics", |
| "libminijail", |
| ] |
| } |
| |
| executable("attestationd") { |
| sources = [ "server/main.cc" ] |
| configs += [ |
| ":attestationd_config", |
| ":local_proto_include", |
| ":target_defaults", |
| ] |
| libs = [ "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", |
| ":proto_library_proto", |
| ":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/pca_agent_service.cc", |
| "pca_agent/server/pca_request.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| executable("pca_agentd") { |
| sources = [ "pca_agent/server/main.cc" ] |
| configs += [ |
| ":attestationd_config", |
| ":target_defaults", |
| ] |
| |
| # 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-adaptors", |
| ":pca_agent_server_library", |
| ] |
| } |
| |
| executable("pca_agent_client") { |
| sources = [ "pca_agent/client/main.cc" ] |
| configs += [ ":target_defaults" ] |
| |
| # 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", |
| ] |
| } |
| |
| if (use.test) { |
| pkg_config("attestation_testrunner_config") { |
| pkg_deps = [ |
| "libbrillo-test", |
| "libchrome-test", |
| "libmetrics", |
| ] |
| } |
| executable("attestation_testrunner") { |
| sources = [ |
| "attestation_testrunner.cc", |
| "client/dbus_proxy_test.cc", |
| "common/crypto_utility_impl_test.cc", |
| "common/mock_crypto_utility.cc", |
| "common/mock_tpm_utility.cc", |
| "pca_agent/server/pca_request_test.cc", |
| "server/attestation_service_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", |
| ] |
| if (use.tpm2) { |
| sources += [ "common/tpm_utility_v2_test.cc" ] |
| libs = [ |
| "hwsec_test", |
| "policy", |
| "tpm_manager_test", |
| "trunks_test", |
| ] |
| } else { |
| sources += [ "common/tpm_utility_common_test.cc" ] |
| libs = [ |
| "hwsec_test", |
| "policy", |
| ] |
| } |
| configs += [ |
| "//common-mk:test", |
| ":attestation_testrunner_config", |
| ":local_proto_include", |
| ":target_defaults", |
| ] |
| |
| # 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-lite", |
| ] |
| deps = [ |
| ":client_library", |
| ":common_library", |
| ":pca_agent_server_library", |
| ":proto_library", |
| ":proto_library_proto", |
| ":server_library", |
| ] |
| } |
| } |