From 636ebedccdfe0a4eceb8489a476bf9d36fe2a464 Mon Sep 17 00:00:00 2001 From: milanr-q <114670456+milanr-q@users.noreply.github.com> Date: Tue, 6 Dec 2022 15:02:10 +0100 Subject: [PATCH] Adding conditional compilation for jlink/segger_rtt code (#23777) * Adding conditional compilation for jlink/segger_rtt code * Review remarks addressed --- src/platform/device.gni | 7 ++++++- third_party/openthread/platforms/BUILD.gn | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/platform/device.gni b/src/platform/device.gni index 70cbe9955e7419..bddd80e6e8f973 100755 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -185,7 +185,7 @@ declare_args() { build_tv_casting_common_a = false } -assert(chip_disable_platform_kvs == false || chip_device_platform == "darwin", +assert(!chip_disable_platform_kvs || chip_device_platform == "darwin", "Can only disable KVS on some platforms") if (_chip_device_layer != "none" && chip_device_platform != "external") { @@ -201,6 +201,11 @@ if (_chip_device_layer != "none" && chip_device_platform != "external") { "" } +declare_args() { + # Enable jlink/segger_rtt support. + chip_enable_segger_rtt = chip_device_platform != "qpg" +} + assert( (current_os != "freertos" && chip_device_platform == "none") || chip_device_platform == "fake" || diff --git a/third_party/openthread/platforms/BUILD.gn b/third_party/openthread/platforms/BUILD.gn index 3e0e4d2da2dfc7..7445a6407ab63e 100644 --- a/third_party/openthread/platforms/BUILD.gn +++ b/third_party/openthread/platforms/BUILD.gn @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") import("//build_overrides/jlink.gni") import("//build_overrides/openthread.gni") +import("${chip_root}/src/platform/device.gni") config("libopenthread-platform_config") { include_dirs = [ "${openthread_root}/examples/platforms" ] @@ -45,8 +47,6 @@ static_library("libopenthread-platform-utils") { "${openthread_root}/examples/platforms/utils/code_utils.h", "${openthread_root}/examples/platforms/utils/debug_uart.c", "${openthread_root}/examples/platforms/utils/encoding.h", - "${openthread_root}/examples/platforms/utils/logging_rtt.c", - "${openthread_root}/examples/platforms/utils/logging_rtt.h", "${openthread_root}/examples/platforms/utils/mac_frame.cpp", "${openthread_root}/examples/platforms/utils/mac_frame.h", "${openthread_root}/examples/platforms/utils/settings.h", @@ -54,10 +54,17 @@ static_library("libopenthread-platform-utils") { "${openthread_root}/examples/platforms/utils/soft_source_match_table.c", "${openthread_root}/examples/platforms/utils/soft_source_match_table.h", ] - public_deps = [ - "${openthread_root}/src/core:libopenthread_core_headers", - "${segger_rtt_root}:segger_rtt", - ] + + public_deps = [ "${openthread_root}/src/core:libopenthread_core_headers" ] + + if (chip_enable_segger_rtt) { + sources += [ + "${openthread_root}/examples/platforms/utils/logging_rtt.c", + "${openthread_root}/examples/platforms/utils/logging_rtt.h", + ] + + public_deps += [ "${segger_rtt_root}:segger_rtt" ] + } public_configs = [ ":libopenthread-platform_config" ] }