From 282a44066354b57c07e03cbea24c7165c57f285a Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Thu, 7 Jul 2022 09:17:11 -0700 Subject: [PATCH] Cleanup Linux platform source includes (#20362) (#20420) * Make bluez source include conditional on chip_enable_ble Linux platform is unconditionally including bluez source files. But this only makes sense if ble is enabled. Configure includes to be conditional on this. * Make WiFi commissioning driver source include conditional on chip_enable_wifi Linux platform is unconditionally including the WiFI commissioning driver source files. But this only makes sense if wifi is enabled. Configure includes to be conditional on this. * Move Network Commissioning driver source includes into app projects Network commissioning source is unconditionally included in the Linux platform. But this only makes sense for commissionable apps that actually use this code. This commit moves these source includes to the apps and also fixes a build error that is arising from blindly assigning size_t to a uint8_t. * per Damian-Nordic, revert networkIDLen to uint8_t But, use static_cast to fix build warning * per Damian-Nordic, introduce chip_enable_network_commissioning This allows general and ethernet network commissioning source to be conditionally included in platform configuration. * Revert NetworkCommissioningDriver changes Co-authored-by: Michael Sandstedt --- src/platform/Linux/BUILD.gn | 29 ++++++++++++------- .../NetworkCommissioningEthernetDriver.cpp | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/platform/Linux/BUILD.gn b/src/platform/Linux/BUILD.gn index bfcbcd9be73703..5a66ab0ccc335d 100644 --- a/src/platform/Linux/BUILD.gn +++ b/src/platform/Linux/BUILD.gn @@ -70,28 +70,32 @@ static_library("Linux") { "Logging.cpp", "NetworkCommissioningDriver.h", "NetworkCommissioningEthernetDriver.cpp", - "NetworkCommissioningWiFiDriver.cpp", "PlatformManagerImpl.cpp", "PlatformManagerImpl.h", "PosixConfig.cpp", "PosixConfig.h", "SystemPlatformConfig.h", "SystemTimeSupport.cpp", - "bluez/AdapterIterator.cpp", - "bluez/AdapterIterator.h", - "bluez/ChipDeviceScanner.cpp", - "bluez/ChipDeviceScanner.h", - "bluez/Helper.cpp", - "bluez/Helper.h", - "bluez/MainLoop.cpp", - "bluez/MainLoop.h", - "bluez/Types.h", ] if (chip_enable_openthread) { sources += [ "NetworkCommissioningThreadDriver.cpp" ] } + if (chip_enable_ble) { + sources += [ + "bluez/AdapterIterator.cpp", + "bluez/AdapterIterator.h", + "bluez/ChipDeviceScanner.cpp", + "bluez/ChipDeviceScanner.h", + "bluez/Helper.cpp", + "bluez/Helper.h", + "bluez/MainLoop.cpp", + "bluez/MainLoop.h", + "bluez/Types.h", + ] + } + deps = [ "${chip_root}/src/setup_payload" ] public_deps = [ @@ -135,7 +139,10 @@ static_library("Linux") { } if (chip_enable_wifi) { - sources += [ "GlibTypeDeleter.h" ] + sources += [ + "GlibTypeDeleter.h", + "NetworkCommissioningWiFiDriver.cpp", + ] public_deps += [ "dbus/wpa" ] } diff --git a/src/platform/Linux/NetworkCommissioningEthernetDriver.cpp b/src/platform/Linux/NetworkCommissioningEthernetDriver.cpp index 00c619c3605be3..10d056708a980d 100644 --- a/src/platform/Linux/NetworkCommissioningEthernetDriver.cpp +++ b/src/platform/Linux/NetworkCommissioningEthernetDriver.cpp @@ -34,7 +34,7 @@ NetworkIterator * LinuxEthernetDriver::GetNetworks() { auto ret = new EthernetNetworkIterator(); ConnectivityUtils::GetEthInterfaceName(SafePointerCast(ret->interfaceName), sizeof(ret->interfaceName)); - ret->interfaceNameLen = strnlen(SafePointerCast(ret->interfaceName), sizeof(ret->interfaceName)); + ret->interfaceNameLen = static_cast(strnlen(SafePointerCast(ret->interfaceName), sizeof(ret->interfaceName))); return ret; }