Skip to content

Commit

Permalink
Make sure all known CHIP_DEVICE_LAYER_TARGET_* are defined. (#29230)
Browse files Browse the repository at this point in the history
* Make sure all known CHIP_DEVICE_LAYER_TARGET_* are defined.

To either 0 or 1 depending on whether they are actually the target.

* Address review comment.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jan 3, 2024
1 parent 743467e commit 17f184f
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 89 deletions.
2 changes: 1 addition & 1 deletion src/inet/tests/TestInetCommonPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void ServiceEvents(uint32_t aSleepTimeMilliseconds)

if (sRemainingSystemLayerEventDelay == 0)
{
#if defined(CHIP_DEVICE_LAYER_TARGET_OPEN_IOT_SDK)
#if CHIP_DEVICE_LAYER_TARGET_OPEN_IOT_SDK
// We need to terminate event loop after performance single step.
// Event loop processing work items until StopEventLoopTask is called.
// Scheduling StopEventLoop task guarantees correct operation of the loop.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dnssd/platform/tests/TestPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <nlunit-test.h>

#if !defined(CHIP_DEVICE_LAYER_TARGET_FAKE) || CHIP_DEVICE_LAYER_TARGET_FAKE != 1
#if CHIP_DEVICE_LAYER_TARGET_FAKE != 1
#error "This test is designed for use only with the fake platform"
#endif

Expand Down
190 changes: 103 additions & 87 deletions src/platform/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -158,171 +158,187 @@ if (chip_device_platform != "none" && chip_device_platform != "external") {
}

if (chip_device_platform == "cc13x2_26x2") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_CC13X2_26X2=1",
"CHIP_DEVICE_LAYER_TARGET=cc13xx_26xx/cc13x2_26x2",
]
device_layer_target_define = "CC13X2_26X2"
defines += [ "CHIP_DEVICE_LAYER_TARGET=cc13xx_26xx/cc13x2_26x2" ]
} else if (chip_device_platform == "cc13x4_26x4") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_CC13X4_26X4=1",
"CHIP_DEVICE_LAYER_TARGET=cc13xx_26xx/cc13x4_26x4",
]
device_layer_target_define = "CC13X4_26X4"
defines += [ "CHIP_DEVICE_LAYER_TARGET=cc13xx_26xx/cc13x4_26x4" ]
} else if (chip_device_platform == "cc32xx") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_CC32XX=1",
"CHIP_DEVICE_LAYER_TARGET=cc32xx",
]
device_layer_target_define = "CC32XX"
defines += [ "CHIP_DEVICE_LAYER_TARGET=cc32xx" ]
} else if (chip_device_platform == "darwin") {
device_layer_target_define = "DARWIN"
defines += [
"CHIP_DEVICE_LAYER_TARGET_DARWIN=1",
"CHIP_DEVICE_LAYER_TARGET=Darwin",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "efr32") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_EFR32=1",
"CHIP_DEVICE_LAYER_TARGET=silabs",
]
device_layer_target_define = "EFR32"
defines += [ "CHIP_DEVICE_LAYER_TARGET=silabs" ]
} else if (chip_device_platform == "SiWx917") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_EFR32=1",
"CHIP_DEVICE_LAYER_TARGET=silabs",
]
device_layer_target_define = "EFR32"
defines += [ "CHIP_DEVICE_LAYER_TARGET=silabs" ]
} else if (chip_device_platform == "esp32") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_ESP32=1",
"CHIP_DEVICE_LAYER_TARGET=ESP32",
]
device_layer_target_define = "ESP32"
defines += [ "CHIP_DEVICE_LAYER_TARGET=ESP32" ]
} else if (chip_device_platform == "psoc6") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_PSOC6=1",
"CHIP_DEVICE_LAYER_TARGET=Infineon/PSOC6",
]
device_layer_target_define = "PSOC6"
defines += [ "CHIP_DEVICE_LAYER_TARGET=Infineon/PSOC6" ]
} else if (chip_device_platform == "linux") {
device_layer_target_define = "LINUX"
defines += [
"CHIP_DEVICE_LAYER_TARGET_LINUX=1",
"CHIP_DEVICE_LAYER_TARGET=Linux",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "tizen") {
device_layer_target_define = "TIZEN"
defines += [
"CHIP_DEVICE_LAYER_TARGET_TIZEN=1",
"CHIP_DEVICE_LAYER_TARGET=Tizen",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "nrfconnect") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_NRFCONNECT=1",
"CHIP_DEVICE_LAYER_TARGET=nrfconnect",
]
device_layer_target_define = "NRFCONNECT"
defines += [ "CHIP_DEVICE_LAYER_TARGET=nrfconnect" ]
} else if (chip_device_platform == "qpg") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_QPG=1",
"CHIP_DEVICE_LAYER_TARGET=qpg",
]
device_layer_target_define = "QPG"
defines += [ "CHIP_DEVICE_LAYER_TARGET=qpg" ]
} else if (chip_device_platform == "k32w0") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_K32W=1",
"CHIP_DEVICE_LAYER_TARGET=nxp/k32w/k32w0",
]
device_layer_target_define = "K32W"
defines += [ "CHIP_DEVICE_LAYER_TARGET=nxp/k32w/k32w0" ]
} else if (chip_device_platform == "telink") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_TELINK=1",
"CHIP_DEVICE_LAYER_TARGET=telink",
]
device_layer_target_define = "TELINK"
defines += [ "CHIP_DEVICE_LAYER_TARGET=telink" ]
} else if (chip_device_platform == "mbed") {
device_layer_target_define = "MBED"
defines += [
"CHIP_DEVICE_LAYER_TARGET_MBED=1",
"CHIP_DEVICE_LAYER_TARGET=mbed",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
"CHIP_DEVICE_ENABLE_DATA_MODEL=${chip_enable_data_model}",
]
} else if (chip_device_platform == "bl602") {
device_layer_target_define = "BL602"
defines += [
"CHIP_DEVICE_LAYER_TARGET_BL602=1",
"CHIP_DEVICE_LAYER_TARGET=bouffalolab/common",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "bl702") {
device_layer_target_define = "BL702"
defines += [
"CHIP_DEVICE_LAYER_TARGET_BL702=1",
"CHIP_DEVICE_LAYER_TARGET=bouffalolab/common",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "bl702l") {
device_layer_target_define = "BL702L"
defines += [
"CHIP_DEVICE_LAYER_TARGET_BL702L=1",
"CHIP_DEVICE_LAYER_TARGET=bouffalolab/common",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "fake") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_FAKE=1",
"CHIP_DEVICE_LAYER_TARGET=fake",
]
device_layer_target_define = "FAKE"
defines += [ "CHIP_DEVICE_LAYER_TARGET=fake" ]
} else if (chip_device_platform == "android") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_ANDROID=1",
"CHIP_DEVICE_LAYER_TARGET=android",
]
device_layer_target_define = "ANDROID"
defines += [ "CHIP_DEVICE_LAYER_TARGET=android" ]
} else if (chip_device_platform == "ameba") {
device_layer_target_define = "AMEBA"
defines += [
"CHIP_DEVICE_LAYER_TARGET_AMEBA=1",
"CHIP_DEVICE_LAYER_TARGET=Ameba",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "cyw30739") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_CYW30739=1",
"CHIP_DEVICE_LAYER_TARGET=Infineon/CYW30739",
]
device_layer_target_define = "CYW30739"
defines += [ "CHIP_DEVICE_LAYER_TARGET=Infineon/CYW30739" ]
} else if (chip_device_platform == "webos") {
device_layer_target_define = "WEBOS"
defines += [
"CHIP_DEVICE_LAYER_TARGET_WEBOS=1",
"CHIP_DEVICE_LAYER_TARGET=webos",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
defines -=
[ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" ]
} else if (chip_device_platform == "mw320") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_MW320=1",
"CHIP_DEVICE_LAYER_TARGET=nxp/mw320",
]
device_layer_target_define = "MW320"
defines += [ "CHIP_DEVICE_LAYER_TARGET=nxp/mw320" ]
} else if (chip_device_platform == "zephyr") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_ZEPHYR=1",
"CHIP_DEVICE_LAYER_TARGET=Zephyr",
]
device_layer_target_define = "ZEPHYR"
defines += [ "CHIP_DEVICE_LAYER_TARGET=Zephyr" ]
} else if (chip_device_platform == "beken") {
device_layer_target_define = "BEKEN"
defines += [
"CHIP_DEVICE_LAYER_TARGET_BEKEN=1",
"CHIP_DEVICE_LAYER_TARGET=Beken",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "mt793x") {
device_layer_target_define = "MT793X"
defines += [
"CHIP_DEVICE_LAYER_TARGET_MT793X=1",
"CHIP_DEVICE_LAYER_TARGET=mt793x",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "openiotsdk") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_OPEN_IOT_SDK=1",
"CHIP_DEVICE_LAYER_TARGET=openiotsdk",
]
device_layer_target_define = "OPEN_IOT_SDK"
defines += [ "CHIP_DEVICE_LAYER_TARGET=openiotsdk" ]
} else if (chip_device_platform == "asr") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_ASR=1",
"CHIP_DEVICE_LAYER_TARGET=ASR",
]
device_layer_target_define = "ASR"
defines += [ "CHIP_DEVICE_LAYER_TARGET=ASR" ]
} else if (chip_device_platform == "stm32") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_STM32=1",
"CHIP_DEVICE_LAYER_TARGET=stm32",
]
device_layer_target_define = "STM32"
defines += [ "CHIP_DEVICE_LAYER_TARGET=stm32" ]
} else {
device_layer_target_define = ""
}

assert(device_layer_target_define != "",
"Unknown chip_device_platform value: '${chip_device_platform}'")

found_device_layer_target_define = false
possible_device_layer_target_defines = [
"CC13X2_26X2",
"CC13X4_26X4",
"CC32XX",
"DARWIN",
"EFR32",
"ESP32",
"PSOC6",
"LINUX",
"TIZEN",
"NRFCONNECT",
"QPG",
"K32W",
"TELINK",
"MBED",
"BL602",
"BL702",
"BL702L",
"FAKE",
"ANDROID",
"AMEBA",
"CYW30739",
"WEBOS",
"MW320",
"ZEPHYR",
"BEKEN",
"MT793X",
"OPEN_IOT_SDK",
"ASR",
"STM32",
]
foreach(possible_device_layer_target_define,
possible_device_layer_target_defines) {
if (possible_device_layer_target_define == device_layer_target_define) {
found_device_layer_target_define = true
defines += [
"CHIP_DEVICE_LAYER_TARGET_${possible_device_layer_target_define}=1",
]
} else {
defines += [
"CHIP_DEVICE_LAYER_TARGET_${possible_device_layer_target_define}=0",
]
}
}
assert(
found_device_layer_target_define,
"possible_device_layer_target_defines list missing '${device_layer_target_define}'")

if (chip_device_config_device_software_version != "") {
defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=${chip_device_config_device_software_version}" ]
}
Expand Down

0 comments on commit 17f184f

Please sign in to comment.