| # 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/pkg_config.gni") |
| import("//common-mk/proto_library.gni") |
| |
| group("all") { |
| deps = [ ":libtpmcrypto" ] |
| if (use.test) { |
| deps += [ ":tpmcrypto_test" ] |
| } |
| } |
| |
| pkg_config("target_defaults") { |
| defines = [ "USE_TPM2=${use.tpm2}" ] |
| pkg_deps = [ |
| "libbrillo", |
| "libchrome", |
| "openssl", |
| "protobuf-lite", |
| ] |
| } |
| |
| proto_library("tpm_encrypted_data_proto") { |
| proto_in_dir = "." |
| proto_out_dir = "include/libtpmcrypto" |
| sources = [ "tpm_encrypted_data.proto" ] |
| |
| # tpm_encrypted_data_proto.a is used by a shared_libary |
| # object, so we need to build it with '-fPIC' instead of '-fPIE'. |
| use_pic = true |
| } |
| |
| shared_library("libtpmcrypto") { |
| configs += [ ":target_defaults" ] |
| sources = [ |
| "tpm_crypto_impl.cc", |
| "tpm_proto_utils.cc", |
| ] |
| deps = [ ":tpm_encrypted_data_proto" ] |
| if (use.tpm2) { |
| sources += [ "tpm2_impl.cc" ] |
| libs = [ "trunks" ] |
| } |
| if (!use.tpm2) { |
| sources += [ "tpm1_impl.cc" ] |
| libs = [ "tspi" ] |
| } |
| } |
| |
| if (use.test) { |
| pkg_config("test_config") { |
| pkg_deps = [ "libchrome-test" ] |
| } |
| |
| executable("tpmcrypto_test") { |
| configs += [ |
| "//common-mk:test", |
| ":target_defaults", |
| ":test_config", |
| ] |
| sources = [ |
| "tpm_crypto_impl_test.cc", |
| "tpm_proto_utils.cc", |
| "tpm_proto_utils_test.cc", |
| ] |
| if (use.tpm2) { |
| sources += [ "tpm2_impl.cc" ] |
| libs = [ "trunks" ] |
| } |
| if (!use.tpm2) { |
| sources += [ "tpm1_impl.cc" ] |
| libs = [ "tspi" ] |
| } |
| deps = [ |
| ":libtpmcrypto", |
| ":tpm_encrypted_data_proto", |
| "//common-mk/testrunner", |
| ] |
| } |
| } |