Skip to content

Commit

Permalink
Add chip_external_mbedtls flag to src/crypto (#23538)
Browse files Browse the repository at this point in the history
This allows mbedtls to be compiled outside of the Matter gn build
routine, for build targets that wish to share mbedtls symbols.
  • Loading branch information
alexhqwang authored and pull[bot] committed Nov 15, 2023
1 parent 10b4732 commit 6bd8a97
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions config/nrfconnect/chip-gn/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import("//build_overrides/chip.gni")

import("${chip_root}/src/crypto/crypto.gni")

chip_device_platform = "nrfconnect"

chip_build_tests = false
Expand All @@ -22,6 +24,9 @@ chip_project_config_include = ""
chip_system_project_config_include = ""
chip_ble_project_config_include = ""

chip_crypto = "mbedtls"
chip_external_mbedtls = true

custom_toolchain = "${chip_root}/config/nrfconnect/chip-gn/toolchain:zephyr"

pw_build_PIP_CONSTRAINTS = [ "${chip_root}/scripts/constraints.txt" ]
5 changes: 5 additions & 0 deletions config/telink/chip-gn/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import("//build_overrides/chip.gni")

import("${chip_root}/src/crypto/crypto.gni")

chip_device_platform = "telink"

chip_build_tests = false
Expand All @@ -22,6 +24,9 @@ chip_project_config_include = ""
chip_system_project_config_include = ""
chip_ble_project_config_include = ""

chip_crypto = "mbedtls"
chip_external_mbedtls = true

custom_toolchain = "${chip_root}/config/telink/chip-gn/toolchain:zephyr"

pw_build_PIP_CONSTRAINTS = [ "${chip_root}/scripts/constraints.txt" ]
5 changes: 5 additions & 0 deletions config/zephyr/chip-gn/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import("//build_overrides/chip.gni")

import("${chip_root}/src/crypto/crypto.gni")

chip_device_platform = "zephyr"

chip_build_tests = false
Expand All @@ -22,6 +24,9 @@ chip_project_config_include = ""
chip_system_project_config_include = ""
chip_ble_project_config_include = ""

chip_crypto = "mbedtls"
chip_external_mbedtls = true

custom_toolchain = "${chip_root}/config/zephyr/chip-gn/toolchain:zephyr"

pw_build_PIP_CONSTRAINTS = [ "${chip_root}/scripts/constraints.txt" ]
4 changes: 1 addition & 3 deletions src/crypto/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ if (chip_crypto == "openssl") {
sources = [ "CHIPCryptoPALmbedTLS.cpp" ]
public_deps = [ ":public_headers" ]

external_mbedtls = current_os == "zephyr"

if (!external_mbedtls) {
if (!chip_external_mbedtls) {
public_deps += [ "${mbedtls_root}:mbedtls" ]
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/crypto/crypto.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ declare_args() {
# Crypto implementation: mbedtls, openssl, tinycrypt, boringssl, platform.
chip_crypto = ""
chip_with_se05x = 0

# Compile mbedtls externally. Only used if chip_crypto == "mbedtls"
chip_external_mbedtls = false
}

assert(!chip_external_mbedtls || chip_crypto == "mbedtls",
"Use of external mbedtls requires the mbedtls crypto impl")

0 comments on commit 6bd8a97

Please sign in to comment.