| # 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/lwip.gni") |
| import("//build_overrides/mbedtls.gni") |
| import("//build_overrides/mw320_sdk.gni") |
| |
| import("${lwip_root}/lwip.gni") |
| import("${mbedtls_root}/mbedtls.gni") |
| import("${mw320_sdk_build_root}/mw320_sdk.gni") |
| |
| declare_args() { |
| # Build target to use for mw320 SDK. Use this to set global SDK defines. |
| mw320_sdk_target = "" |
| } |
| |
| assert(mw320_sdk_target != "", "mw320_sdk_target must be specified") |
| |
| group("mw320_sdk") { |
| public_deps = [ mw320_sdk_target ] |
| } |
| |
| if (chip_crypto == "tinycrypt") { |
| assert( |
| mbedtls_repo == |
| "//third_party/connectedhomeip/third_party/nxp/libs/mbedtls", |
| "mbedtls_repo must be set to nxp mbedtls-tinycrypt library when chip_crypto == \"tinycrypt\"") |
| } |
| |
| config("mbedtls_mw320_config") { |
| defines = [ |
| "MBEDTLS_CONFIG_FILE=<src/platform/nxp/mw320/mw320-chip-mbedtls-config.h>", |
| |
| # These options should really be in the config.h... |
| "MBEDTLS_NO_PLATFORM_ENTROPY", |
| "MBEDTLS_ECP_C", |
| "ECP_SHORTWEIERSTRASS", |
| "MBEDTLS_BIGNUM_C", |
| "MBEDTLS_MD_C", |
| "MBEDTLS_SHA256_C", |
| "MBEDTLS_X509_CSR_WRITE_C", |
| "MBEDTLS_X509_CREATE_C", |
| "MBEDTLS_PK_WRITE_C", |
| "MBEDTLS_PK_C", |
| "MBEDTLS_ASN1_WRITE_C", |
| "MBEDTLS_ASN1_PARSE_C", |
| "MBEDTLS_OID_C", |
| "MBEDTLS_PEM_WRITE_C", |
| "MBEDTLS_BASE64_C", |
| "MBEDTLS_HKDF_C", |
| "MBEDTLS_ERROR_C", |
| "MBEDTLS_PKCS5_C", |
| "MBEDTLS_CTR_DRBG_C", |
| "MBEDTLS_AES_C", |
| "MBEDTLS_CIPHER_C", |
| "MBEDTLS_CCM_C", |
| "MBEDTLS_ENTROPY_C", |
| |
| # "MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED", |
| ] |
| |
| if (chip_with_factory_data == 1) { |
| defines += [ |
| "MBEDTLS_X509_CRT_PARSE_C", |
| "MBEDTLS_X509_USE_C", |
| "MBEDTLS_PK_PARSE_C", |
| "MBEDTLS_PLATFORM_C", |
| ] |
| } |
| |
| #if (mbedtls_use_tinycrypt) { |
| if (chip_crypto == "tinycrypt") { |
| defines += [ |
| "MBEDTLS_USE_TINYCRYPT", |
| "MBEDTLS_OPTIMIZE_TINYCRYPT_ASM", |
| ] |
| } |
| |
| include_dirs = [ chip_root ] |
| |
| #if (mbedtls_use_tinycrypt) { |
| if (chip_crypto == "tinycrypt") { |
| include_dirs += [ "${mbedtls_repo}/repo/include/tinycrypt" ] |
| } |
| } |
| |
| mbedtls_target("mbedtls") { |
| import("${mw320_sdk_build_root}/mw320_sdk.gni") |
| |
| #if (mbedtls_use_tinycrypt) { |
| if (chip_crypto == "tinycrypt") { |
| if (!defined(sources)) { |
| sources = [] |
| } |
| sources += [ |
| "${mbedtls_repo}/repo/tinycrypt/ecc.c", |
| "${mbedtls_repo}/repo/tinycrypt/ecc_dh.c", |
| "${mbedtls_repo}/repo/tinycrypt/ecc_dsa.c", |
| ] |
| } |
| public_configs = [ ":mbedtls_mw320_config" ] |
| |
| public_deps = [ ":mw320_sdk" ] |
| } |