| # 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 some libs. |
| # gnlint: disable=GnLintVisibilityFlags |
| |
| import("//common-mk/pkg_config.gni") |
| import("//common-mk/proto_library.gni") |
| |
| group("all") { |
| deps = [ |
| ":libtpm_manager", |
| ":local_data_migration", |
| ":tpm_manager_client", |
| ":tpm_manager_test", |
| ":tpm_managerd", |
| ] |
| if (use.test) { |
| deps += [ ":tpm_manager_testrunner" ] |
| } |
| } |
| |
| pkg_config("target_default_deps") { |
| # This is a list of pkg-config dependencies |
| pkg_deps = [ |
| "libbrillo", |
| "libchrome", |
| "libtpmcrypto", |
| "openssl", |
| ] |
| if (use.fuzzer) { |
| pkg_deps += [ "protobuf" ] |
| } else { |
| pkg_deps += [ "protobuf-lite" ] |
| } |
| } |
| |
| config("target_defaults") { |
| configs = [ ":target_default_deps" ] |
| defines = [ "USE_TPM2=${use.tpm2}" ] |
| } |
| |
| # A protobuf library of legacy local data. |
| proto_library("legacy_local_data_proto") { |
| # Use -fPIC so this code can be linked into a shared library. |
| use_pic = true |
| proto_in_dir = "server" |
| proto_out_dir = "include/tpm_manager/server" |
| sources = [ "${proto_in_dir}/legacy_local_data.proto" ] |
| } |
| |
| static_library("proto_library") { |
| configs -= [ |
| "//common-mk:use_thin_archive", |
| "//common-mk:pie", |
| ] |
| configs += [ |
| ":target_defaults", |
| "//common-mk:nouse_thin_archive", |
| |
| # TODO: Use brillo/brillo_export.h instead to export symbols. |
| "//common-mk:visibility_default", |
| "//common-mk:pic", |
| ] |
| proto_in_dir = "common" |
| sources = [ "${proto_in_dir}/print_tpm_manager_proto.cc" ] |
| } |
| |
| # A shared library for clients. |
| shared_library("libtpm_manager") { |
| configs += [ ":target_defaults" ] |
| sources = [ |
| "client/tpm_manager_utility.cc", |
| "client/tpm_nvram_dbus_proxy.cc", |
| "client/tpm_ownership_dbus_proxy.cc", |
| ] |
| libs = [ "system_api" ] |
| deps = [ ":proto_library" ] |
| } |
| |
| # A client command line utility. |
| executable("tpm_manager_client") { |
| configs += [ ":target_defaults" ] |
| sources = [ "client/main.cc" ] |
| deps = [ |
| ":libtpm_manager", |
| ":proto_library", |
| ] |
| |
| # 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", |
| ] |
| } |
| |
| # A library for server code. |
| config("server_library_tpm2_config") { |
| libs = [ "trunks" ] |
| } |
| |
| config("server_library_tpm1_config") { |
| libs = [ |
| "hwsec", |
| "tspi", |
| ] |
| } |
| |
| static_library("server_library") { |
| configs += [ ":target_defaults" ] |
| sources = [ |
| "server/dbus_service.cc", |
| "server/local_data_migration.cc", |
| "server/local_data_store_impl.cc", |
| "server/openssl_crypto_util_impl.cc", |
| "server/tpm_manager_metrics.cc", |
| "server/tpm_manager_service.cc", |
| ] |
| if (use.tpm2) { |
| sources += [ |
| "server/tpm2_initializer_impl.cc", |
| "server/tpm2_nvram_impl.cc", |
| "server/tpm2_status_impl.cc", |
| ] |
| all_dependent_configs = [ ":server_library_tpm2_config" ] |
| } else { |
| sources += [ |
| "server/tpm_connection.cc", |
| "server/tpm_initializer_impl.cc", |
| "server/tpm_nvram_impl.cc", |
| "server/tpm_status_impl.cc", |
| ] |
| all_dependent_configs = [ ":server_library_tpm1_config" ] |
| } |
| deps = [ |
| ":legacy_local_data_proto", |
| ":proto_library", |
| ] |
| |
| # 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", |
| ] |
| } |
| |
| # The tpm_manager daemon. |
| pkg_config("tpm_managerd_config") { |
| pkg_deps = [ |
| "libmetrics", |
| "libminijail", |
| ] |
| } |
| |
| executable("tpm_managerd") { |
| configs += [ |
| ":target_defaults", |
| ":tpm_managerd_config", |
| ] |
| sources = [ "server/main.cc" ] |
| deps = [ |
| ":proto_library", |
| ":server_library", |
| ] |
| |
| # 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", |
| ] |
| } |
| |
| config("local_data_migration_config") { |
| libs = [ "tpmcrypto" ] |
| } |
| |
| # Local data migrator. |
| executable("local_data_migration") { |
| configs += [ |
| ":local_data_migration_config", |
| ":target_defaults", |
| ] |
| sources = [ "server/local_data_migration_main.cc" ] |
| deps = [ ":server_library" ] |
| } |
| |
| # A library for externally useful tpm_manager_testtest code. |
| static_library("tpm_manager_test") { |
| configs += [ |
| ":target_defaults", |
| "//common-mk:nouse_thin_archive", |
| ] |
| configs -= [ "//common-mk:use_thin_archive" ] |
| sources = [ |
| "common/mock_tpm_nvram_interface.cc", |
| "common/mock_tpm_ownership_interface.cc", |
| ] |
| deps = [ ":proto_library" ] |
| |
| # 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", |
| ] |
| } |
| |
| if (use.test) { |
| pkg_config("tpm_manager_testrunner_config") { |
| pkg_deps = [ |
| "libbrillo-test", |
| "libchrome-test", |
| "libmetrics", |
| ] |
| } |
| |
| executable("tpm_manager_testrunner") { |
| configs += [ |
| "//common-mk:test", |
| ":target_defaults", |
| ":tpm_manager_testrunner_config", |
| ] |
| sources = [ |
| "client/tpm_manager_utility_test.cc", |
| "client/tpm_nvram_dbus_proxy_test.cc", |
| "client/tpm_ownership_dbus_proxy_test.cc", |
| |
| # "server/dbus_service_test.cc", |
| "server/local_data_migration_test.cc", |
| "server/mock_local_data_store.cc", |
| "server/mock_openssl_crypto_util.cc", |
| "server/mock_tpm_initializer.cc", |
| "server/mock_tpm_nvram.cc", |
| "server/mock_tpm_status.cc", |
| "server/tpm_manager_metrics_test.cc", |
| "server/tpm_manager_service_test.cc", |
| "tpm_manager_testrunner.cc", |
| ] |
| if (use.tpm2) { |
| sources += [ |
| "server/tpm2_initializer_test.cc", |
| "server/tpm2_nvram_test.cc", |
| "server/tpm2_status_test.cc", |
| ] |
| libs = [ "trunks_test" ] |
| } else { |
| sources += [ |
| "server/tpm_connection_test.cc", |
| "server/tpm_initializer_test.cc", |
| ] |
| libs = [ "hwsec_test" ] |
| } |
| deps = [ |
| ":libtpm_manager", |
| ":proto_library", |
| ":server_library", |
| ":tpm_manager_test", |
| ] |
| |
| # 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", |
| ] |
| } |
| } |