[ci] Checkout only relevant submodules (#17250)

* [ci] Checkout only relevant submodules

1. Associate submodules to platforms for which they're
   needed.
2. Add a script that is able to checkout submodules for
   specific platforms only.
3. Use the script in CI workflows.

* Fix cirque build

* Address code reviews
diff --git a/.gitmodules b/.gitmodules
index 82d6d04..7fadeb7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -26,6 +26,7 @@
 	path = examples/common/m5stack-tft/repo
 	url = https://github.com/jeremyjh/ESP32_TFT_library.git
 	branch  = master
+	platforms = esp32
 [submodule "pigweed"]
 	path = third_party/pigweed/repo
 	url = https://github.com/google/pigweed.git
@@ -38,14 +39,17 @@
 	path = third_party/ot-br-posix/repo
 	url = https://github.com/openthread/ot-br-posix.git
 	branch  = main
+	platforms = linux
 [submodule "bluez"]
 	path = third_party/bluez/repo
 	url = https://github.com/bluez/bluez.git
 	branch  = master
+	platforms = linux
 [submodule "cirque"]
 	path = third_party/cirque/repo
 	url = https://github.com/openweave/cirque.git
 	branch  = master
+	platforms = linux
 [submodule "nanopb"]
 	path = third_party/nanopb/repo
 	url = https://github.com/nanopb/nanopb.git
@@ -54,6 +58,7 @@
 	path = third_party/qpg_sdk/repo
 	url = https://github.com/Qorvo/qpg-connectedhomeip
 	branch  = master
+	platforms = qpg
 [submodule "zap"]
 	path = third_party/zap/repo
 	url = https://github.com/project-chip/zap.git
@@ -62,103 +67,134 @@
 	path = third_party/freertos/repo
 	url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
 	branch  = V10.3.1-kernel-only
+	platforms = ameba,cc13x2_26x2,bl602,efr32,esp32,k32w0,p6,qpg
 [submodule "efr32_sdk"]
 	path = third_party/efr32_sdk/repo
 	url = https://github.com/SiliconLabs/sdk_support.git
 	branch  = master
+	platforms = efr32
 [submodule "simw-top-mini"]
 	path = third_party/simw-top-mini/repo
 	url = https://github.com/NXP/plug-and-trust.git
 	branch  = int/CHIPSE_Release
+	platforms = k32w0
 [submodule "third_party/openthread/ot-nxp"]
 	path = third_party/openthread/ot-nxp
 	url = https://github.com/openthread/ot-nxp.git
+	platforms = k32w0
 [submodule "third_party/openthread/ot-qorvo"]
 	path = third_party/openthread/ot-qorvo
 	url = https://github.com/openthread/ot-qorvo.git
+	platforms = qpg
 [submodule "third_party/openthread/ot-efr32"]
 	path = third_party/openthread/ot-efr32
 	url = https://github.com/openthread/ot-efr32.git
+	platforms = efr32
 [submodule "third_party/openthread/ot-ifx"]
 	path = third_party/openthread/ot-ifx
 	url = https://github.com/Infineon/ot-ifx-release.git
 	branch = cyw30739
+	platforms = cyw30739
 [submodule "third_party/mbed-os/repo"]
 	path = third_party/mbed-os/repo
 	url = https://github.com/ARMmbed/mbed-os.git
 	branch = master
+	platforms = mbed
 [submodule "third_party/mbed-os-posix-socket/repo"]
 	path = third_party/mbed-os-posix-socket/repo
 	url = https://github.com/ARMmbed/mbed-os-posix-socket.git
 	branch  = main
+	platforms = mbed
 [submodule "mbed-os-cypress-capsense-button"]
 	path = third_party/mbed-os-cypress-capsense-button/repo
 	url = https://github.com/ARMmbed/mbed-os-cypress-capsense-button.git
 	branch = main
+	platforms = mbed
 [submodule "p6/abstraction-rtos"]
 	path = third_party/p6/p6_sdk/libs/abstraction-rtos
 	url = https://github.com/Infineon/abstraction-rtos
+	platforms = p6
 [submodule "p6/bluetooth-freertos"]
 	path = third_party/p6/p6_sdk/libs/bluetooth-freertos
 	url = https://github.com/Infineon/bluetooth-freertos
 	branch  = v2.X
+	platforms = p6
 [submodule "p6/btstack"]
 	path = third_party/p6/p6_sdk/libs/btstack
 	url = https://github.com/Infineon/btstack
+	platforms = p6
 [submodule "p6/clib-support"]
 	path = third_party/p6/p6_sdk/libs/clib-support
 	url = https://github.com/Infineon/clib-support
+	platforms = p6
 [submodule "p6/connectivity-utilities"]
 	path = third_party/p6/p6_sdk/libs/connectivity-utilities
 	url = https://github.com/Infineon/connectivity-utilities
+	platforms = p6
 [submodule "p6/core-lib"]
 	path = third_party/p6/p6_sdk/libs/core-lib
 	url = https://github.com/Infineon/core-lib
+	platforms = p6
 [submodule "p6/core-make"]
 	path = third_party/p6/p6_sdk/libs/core-make
 	url = https://github.com/Infineon/core-make
+	platforms = p6
 [submodule "p6/kv-store"]
 	path = third_party/p6/p6_sdk/libs/kv-store
 	url = https://github.com/Infineon/kv-store
+	platforms = p6
 [submodule "p6/mtb-hal-cat1"]
 	path = third_party/p6/p6_sdk/libs/mtb-hal-cat1
 	url = https://github.com/Infineon/mtb-hal-cat1
+	platforms = p6
 [submodule "p6/mtb-pdl-cat1"]
 	path = third_party/p6/p6_sdk/libs/mtb-pdl-cat1
 	url = https://github.com/Infineon/mtb-pdl-cat1
+	platforms = p6
 [submodule "p6/psoc6cm0p"]
 	path = third_party/p6/p6_sdk/libs/psoc6cm0p
 	url = https://github.com/Infineon/psoc6cm0p
+	platforms = p6
 [submodule "p6/whd-bsp-integration"]
 	path = third_party/p6/p6_sdk/libs/whd-bsp-integration
 	url = https://github.com/Infineon/whd-bsp-integration
+	platforms = p6
 [submodule "p6/wifi-connection-manager"]
 	path = third_party/p6/p6_sdk/libs/wifi-connection-manager
 	url = https://github.com/Infineon/wifi-connection-manager
+	platforms = p6
 [submodule "p6/wifi-host-driver"]
 	path = third_party/p6/p6_sdk/libs/wifi-host-driver
 	url = https://github.com/Infineon/wifi-host-driver
+	platforms = p6
 [submodule "p6/wifi-mw-core"]
 	path = third_party/p6/p6_sdk/libs/wifi-mw-core
 	url = https://github.com/Infineon/wifi-mw-core
+	platforms = p6
 [submodule "p6/TARGET_CY8CKIT-062S2-43012"]
 	path = third_party/p6/p6_sdk/libs/TARGET_CY8CKIT-062S2-43012
 	url = https://github.com/Infineon/TARGET_CY8CKIT-062S2-43012
+	platforms = p6
 [submodule "p6/freertos"]
 	path = third_party/p6/p6_sdk/libs/freertos
 	url = https://github.com/Infineon/freertos
+	platforms = p6
 [submodule "p6/retarget-io"]
 	path = third_party/p6/p6_sdk/libs/retarget-io
 	url = https://github.com/Infineon/retarget-io
+	platforms = p6
 [submodule "p6/mbedtls"]
 	path = third_party/p6/p6_sdk/libs/mbedtls
 	url = https://github.com/ARMmbed/mbedtls
+	platforms = p6
 [submodule "p6/secure-sockets"]
 	path = third_party/p6/p6_sdk/libs/secure-sockets
 	url = https://github.com/Infineon/secure-sockets
+	platforms = p6
 [submodule "p6/recipe-make-cat1a"]
 	path = third_party/p6/p6_sdk/libs/recipe-make-cat1a
 	url = https://github.com/Infineon/recipe-make-cat1a
+	platforms = p6
 [submodule "third_party/pybind11/repo"]
 	path = third_party/pybind11/repo
 	url = https://github.com/pybind/pybind11
@@ -166,44 +202,56 @@
 [submodule "p6/lwip"]
 	path = third_party/p6/p6_sdk/libs/lwip
 	url = https://github.com/lwip-tcpip/lwip.git
+	platforms = p6
 [submodule "third_party/jsoncpp/repo"]
 	path = third_party/jsoncpp/repo
 	url = https://github.com/open-source-parsers/jsoncpp.git
 [submodule "cyw30739_sdk/30739A0"]
 	path = third_party/cyw30739_sdk/repos/30739A0
 	url = https://github.com/Infineon/30739A0.git
+	platforms = cyw30739
 [submodule "cyw30739_sdk/include"]
 	path = third_party/cyw30739_sdk/repos/btsdk-include
 	url = https://github.com/Infineon/btsdk-include.git
+	platforms = cyw30739
 [submodule "cyw30739_sdk/target"]
 	path = third_party/cyw30739_sdk/repos/CYW930739M2EVB-01
 	url = https://github.com/Infineon/TARGET_CYW930739M2EVB-01.git
+	platforms = cyw30739
 [submodule "cyw30739_sdk/tools"]
 	path = third_party/cyw30739_sdk/repos/btsdk-tools
 	url = https://github.com/Infineon/btsdk-tools.git
+	platforms = cyw30739
 [submodule "third_party/p6/p6_sdk/libs/anycloud-ota"]
 	path = third_party/p6/p6_sdk/libs/anycloud-ota
 	url = https://github.com/Infineon/anycloud-ota
+	platforms = p6
 [submodule "third_party/mbed-mcu-boot/repo"]
 	path = third_party/mbed-mcu-boot/repo
 	url = https://github.com/ATmobica/mcuboot.git
+	platforms = mbed
 [submodule "perfetto"]
 	path = third_party/perfetto/repo
 	url = https://github.com/google/perfetto
 [submodule "p6/serial-flash"]
 	path = third_party/p6/p6_sdk/libs/serial-flash
 	url = https://github.com/Infineon/serial-flash
+	platforms = p6
 [submodule "third_party/telink_sdk/repo"]
 	path = third_party/telink_sdk/repo
 	url = https://github.com/rikorsev/telink_b91_ble_sdk
+	platforms = telink
 [submodule "ti_simplelink_sdk"]
 	path = third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx
 	url = https://github.com/TexasInstruments/cc13xx_cc26xx_sdk.git
 	branch = main
+	platforms = cc13x2_26x2
 [submodule "third_party/efr32_sdk/wiseconnect-wifi-bt-sdk"]
 	path = third_party/efr32_sdk/wiseconnect-wifi-bt-sdk
 	url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk
+	platforms = efr32
 [submodule "third_party/bouffalolab/bl602"]
 	path = third_party/bouffalolab/bl602_sdk/repo
 	url = https://github.com/bouffalolab/bl_iot_sdk_matter.git
 	branch = bl602_release
+	platforms = bl602