Skip to content

Commit

Permalink
[build] add OpenThread device type config in gn (#12786)
Browse files Browse the repository at this point in the history
* [build] add OpenThread device type config in gn

Allow users to build OpenThread MTD to save flash size.

* remove duplicate dependencies
  • Loading branch information
gjc13 authored and pull[bot] committed Sep 1, 2023
1 parent 50b016e commit 4092114
Show file tree
Hide file tree
Showing 41 changed files with 184 additions and 82 deletions.
4 changes: 4 additions & 0 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ if (CONFIG_OPENTHREAD_ENABLED)
chip_gn_arg_append("chip_enable_openthread" "true")
endif()

if (CONFIG_OPENTHREAD_FTD)
chip_gn_arg_append("chip_openthread_ftd" "true")
endif()

if (CONFIG_ENABLE_OTA_REQUESTOR)
chip_gn_arg_append("chip_enable_ota_requestor" "true")
endif()
Expand Down
1 change: 1 addition & 0 deletions config/nrfconnect/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ chip_gn_arg_string("zephyr_cxx" ${CMAKE_CXX_COMPILER
chip_gn_arg_bool ("is_debug" CONFIG_DEBUG)
chip_gn_arg_bool ("chip_logging" CONFIG_LOG)
chip_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD)
chip_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD)
chip_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT)
chip_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4)
chip_gn_arg_bool ("chip_enable_nfc" CONFIG_CHIP_NFC_COMMISSIONING)
Expand Down
1 change: 1 addition & 0 deletions config/telink/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ chip_gn_arg_string("chip_project_config_include" "${CHIP_PROJECT_CONF
chip_gn_arg_string("chip_system_project_config_include" "${CHIP_PROJECT_CONFIG}")
chip_gn_arg_bool ("is_debug" CONFIG_DEBUG)
chip_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD)
chip_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD)
chip_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4)
chip_gn_arg_bool ("chip_build_tests" CONFIG_CHIP_BUILD_TESTS)
chip_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS)
Expand Down
16 changes: 14 additions & 2 deletions examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${efr32_sdk_build_root}/efr32_sdk.gni")

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")

if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
Expand Down Expand Up @@ -99,11 +101,21 @@ efr32_executable("lighting_app") {
"${chip_root}/src/setup_payload",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
"${examples_plat_dir}:efr-matter-shell",
]

if (chip_openthread_ftd) {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]
} else {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]
}

include_dirs = [ "include" ]

defines = []
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
chip_enable_openthread = true
chip_openthread_ftd = true
1 change: 1 addition & 0 deletions examples/lighting-app/efr32/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_pw_rpc = true
chip_enable_openthread = true
chip_openthread_ftd = true

cpp_standard = "gnu++17"
15 changes: 13 additions & 2 deletions examples/lighting-app/nxp/k32w/k32w0/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import("${k32w0_sdk_build_root}/k32w0_executable.gni")
import("${k32w0_sdk_build_root}/k32w0_sdk.gni")

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

assert(current_os == "freertos")

Expand Down Expand Up @@ -79,10 +80,20 @@ k32w0_executable("light_app") {
"${chip_root}/src/lib",
"${chip_root}/third_party/mbedtls:mbedtls",
"${k32w0_platform_dir}/app/support:freertos_mbedtls_utils",
"${openthread_root}:libopenthread-cli-ftd",
"${openthread_root}:libopenthread-ftd",
]

if (chip_openthread_ftd) {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]
} else {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]
}

cflags = [ "-Wconversion" ]

ldscript = "${k32w0_platform_dir}/app/ldscripts/chip-k32w061-linker.ld"
Expand Down
15 changes: 13 additions & 2 deletions examples/lighting-app/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("//build_overrides/openthread.gni")
import("//build_overrides/qpg_sdk.gni")

import("${build_root}/config/defaults.gni")
import("${chip_root}/src/platform/device.gni")
import("${qpg_sdk_build_root}/qpg_executable.gni")
import("${qpg_sdk_build_root}/qpg_sdk.gni")
assert(current_os == "freertos")
Expand Down Expand Up @@ -55,10 +56,20 @@ qpg_executable("lighting_app") {
"${chip_root}/src/setup_payload",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]

if (chip_openthread_ftd) {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]
} else {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]
}

cflags = [ "-Wconversion" ]

include_dirs = [
Expand Down
9 changes: 8 additions & 1 deletion examples/lock-app/cc13x2x7_26x2x7/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import("//build_overrides/ti_simplelink_sdk.gni")

import("${build_root}/config/defaults.gni")

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

import("${ti_simplelink_sdk_build_root}/ti_simplelink_executable.gni")
import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni")

Expand Down Expand Up @@ -90,9 +92,14 @@ ti_simplelink_executable("lock_app") {
":sysconfig",
"${chip_root}/examples/lock-app/lock-common",
"${chip_root}/src/lib",
"${openthread_root}:libopenthread-ftd",
]

if (chip_openthread_ftd) {
deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-ftd" ]
} else {
deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ]
}

include_dirs = [
"${project_dir}",
"${project_dir}/main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@

#endif // BUILD_RELEASE

/**
* CHIP_DEVICE_CONFIG_THREAD_FTD
*
* Disable Full Thread Device features
*/
#define CHIP_DEVICE_CONFIG_THREAD_FTD 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
*
Expand Down
17 changes: 15 additions & 2 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")

import("${build_root}/config/defaults.gni")

import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${efr32_sdk_build_root}/efr32_sdk.gni")

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")

if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
Expand Down Expand Up @@ -96,11 +99,21 @@ efr32_executable("lock_app") {
"${chip_root}/src/setup_payload",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
"${examples_plat_dir}:efr-matter-shell",
]

if (chip_openthread_ftd) {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]
} else {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]
}

include_dirs = [ "include" ]

defines = []
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ import("${chip_root}/src/platform/EFR32/args.gni")
efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_openthread = true
chip_openthread_ftd = true
pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
1 change: 1 addition & 0 deletions examples/lock-app/efr32/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_pw_rpc = true
chip_enable_openthread = true
chip_openthread_ftd = true

cpp_standard = "gnu++17"
15 changes: 13 additions & 2 deletions examples/lock-app/nxp/k32w/k32w0/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import("//build_overrides/chip.gni")
import("//build_overrides/k32w0_sdk.gni")
import("//build_overrides/openthread.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/third_party/simw-top-mini/simw_config.gni")

import("${k32w0_sdk_build_root}/k32w0_executable.gni")
Expand Down Expand Up @@ -75,10 +76,20 @@ k32w0_executable("lock_app") {
"${chip_root}/third_party/mbedtls:mbedtls",
"${chip_root}/third_party/simw-top-mini:se05x",
"${k32w0_platform_dir}/app/support:freertos_mbedtls_utils",
"${openthread_root}:libopenthread-cli-mtd",
"${openthread_root}:libopenthread-mtd",
]

if (chip_openthread_ftd) {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]
} else {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]
}

cflags = [ "-Wconversion" ]

output_dir = root_out_dir
Expand Down
7 changes: 0 additions & 7 deletions examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,6 @@
#define CONFIG_CHIP_NFC_COMMISSIONING 1
#define CHIP_DEVICE_CONFIG_ENABLE_NFC 1

/**
* CHIP_DEVICE_CONFIG_THREAD_FTD
*
* E-Lock Demo Application is a Thread SED (Sleepy End Device)
*/
#define CHIP_DEVICE_CONFIG_THREAD_FTD 0

/**
* @def CHIP_CONFIG_MAX_DEVICE_ADMINS
*
Expand Down
15 changes: 13 additions & 2 deletions examples/lock-app/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("//build_overrides/openthread.gni")
import("//build_overrides/qpg_sdk.gni")

import("${build_root}/config/defaults.gni")
import("${chip_root}/src/platform/device.gni")
import("${qpg_sdk_build_root}/qpg_executable.gni")
import("${qpg_sdk_build_root}/qpg_sdk.gni")

Expand Down Expand Up @@ -55,10 +56,20 @@ qpg_executable("lock_app") {
"${chip_root}/src/setup_payload",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]

if (chip_openthread_ftd) {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]
} else {
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]
}

include_dirs = [
"${qpg_project_dir}/include",
"${examples_plat_dir}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@

#endif // BUILD_RELEASE

/**
* CHIP_DEVICE_CONFIG_THREAD_FTD
*
* Disable Full Thread Device features
*/
#define CHIP_DEVICE_CONFIG_THREAD_FTD 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
*
Expand Down
1 change: 1 addition & 0 deletions examples/platform/cc13x2_26x2/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import("//build_overrides/chip.gni")

import("${chip_root}/src/platform/cc13x2_26x2/args.gni")

chip_openthread_ftd = true
openthread_config_file = "<OpenThreadConfig.h>"
openthread_core_config_deps = []

Expand Down
1 change: 1 addition & 0 deletions examples/platform/nxp/k32w/k32w0/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ arm_float_abi = "soft"
arm_cpu = "cortex-m4"
arm_arch = "armv7e-m"

chip_openthread_ftd = false
openthread_core_config_deps = []
openthread_core_config_deps = [ "${chip_root}/examples/platform/nxp/k32w/k32w0:openthread_core_config_k32w0_chip_examples" ]

Expand Down
1 change: 1 addition & 0 deletions examples/platform/qpg/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import("//build_overrides/chip.gni")

import("${chip_root}/src/platform/qpg/args.gni")

chip_openthread_ftd = false
openthread_project_core_config_file = "OpenThreadConfig.h"
openthread_core_config_deps = []
openthread_core_config_deps = [
Expand Down
7 changes: 0 additions & 7 deletions examples/platform/qpg/project_include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@
*/
#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512)

/**
* CHIP_DEVICE_CONFIG_THREAD_FTD
*
* Disable Full Thread Device features
*/
#define CHIP_DEVICE_CONFIG_THREAD_FTD 0

/**
* CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI
*
Expand Down
8 changes: 7 additions & 1 deletion examples/pump-app/cc13x2x7_26x2x7/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("//build_overrides/openthread.gni")
import("//build_overrides/ti_simplelink_sdk.gni")

import("${build_root}/config/defaults.gni")
import("${chip_root}/src/platform/device.gni")

import("${ti_simplelink_sdk_build_root}/ti_simplelink_executable.gni")
import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni")
Expand Down Expand Up @@ -90,9 +91,14 @@ ti_simplelink_executable("pump_app") {
":sysconfig",
"${chip_root}/examples/pump-app/pump-common",
"${chip_root}/src/lib",
"${openthread_root}:libopenthread-ftd",
]

if (chip_openthread_ftd) {
deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd" ]
} else {
deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd" ]
}

include_dirs = [
"${project_dir}",
"${project_dir}/main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@

#endif // BUILD_RELEASE

/**
* CHIP_DEVICE_CONFIG_THREAD_FTD
*
* Disable Full Thread Device features
*/
#define CHIP_DEVICE_CONFIG_THREAD_FTD 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
*
Expand Down
Loading

0 comments on commit 4092114

Please sign in to comment.