blob: 1734303f188f6d2ef6bf28940a6f1dd42a3d7c0b [file] [log] [blame]
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build_overrides/chip.gni")
import("//build_overrides/nlassert.gni")
import("${chip_root}/gn/chip/buildconfig_header.gni")
import("crypto.gni")
buildconfig_header("crypto_buildconfig") {
header = "CryptoBuildConfig.h"
header_dir = "crypto"
chip_crypto_mbedtls = chip_crypto == "mbedtls"
chip_crypto_openssl = chip_crypto == "openssl"
defines = [
"CHIP_CRYPTO_MBEDTLS=${chip_crypto_mbedtls}",
"CHIP_CRYPTO_OPENSSL=${chip_crypto_openssl}",
"CHIP_WITH_OPENSSL=${chip_crypto_openssl}",
]
}
if (chip_crypto == "openssl") {
import("//build/config/linux/pkg_config.gni")
pkg_config("openssl_config") {
packages = [ "openssl" ]
}
} else {
import("//build_overrides/mbedtls.gni")
}
static_library("crypto") {
output_name = "libChipCrypto"
sources = [
"CHIPCryptoPAL.cpp",
"CHIPCryptoPAL.h",
]
cflags = [ "-Wconversion" ]
public_deps = [
":crypto_buildconfig",
"${chip_root}/src/lib/core",
"${nlassert_root}:nlassert",
]
public_configs = []
if (chip_crypto == "mbedtls") {
sources += [ "CHIPCryptoPALmbedTLS.cpp" ]
public_deps += [ "${mbedtls_root}:mbedtls" ]
} else if (chip_crypto == "openssl") {
sources += [ "CHIPCryptoPALOpenSSL.cpp" ]
public_configs += [ ":openssl_config" ]
} else {
assert(false, "Invalid CHIP crypto")
}
}