Skip to content

Commit

Permalink
Support CPP codegen at compile time (#23614)
Browse files Browse the repository at this point in the history
* Start having a codegen logic for callback_stub.cpp. Note content does not FULLY match, but only minor diffs exist

* Make the output code be basically already clang-formatted

* generate for ALL clusters

* Fix unit tests, make sure acronyms are normalized for wifi

* Start adding callbacks-stub as an output file that is expected

* Remove callback-stub from all build instructions. Will let codegen take care of this

* Remove generated callback-stub.cpp from zzz_generated

* Fix data model gni to not try pregen callback stub usage

* Fix output: output names should not be quoted

* Make sure codegen files are included in the build files: this makes nrf compile

* Add sources to component library

* Added large codegen tests for PluginApplicationCallbacks and callback-stub to ensure no regressions

* Add blacklist from linting the newly added large idl test inputs

* Remove callback-stub-src template

* Fix mbed shell compilation

* Update scripts/idl/generators/filters.py

Co-authored-by: Boris Zbarsky <[email protected]>

Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 14, 2023
1 parent 50cb39b commit d405f08
Show file tree
Hide file tree
Showing 86 changed files with 7,238 additions and 9,564 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ jobs:
if [ "$idl_file" = "./scripts/idl/tests/inputs/optional_argument.matter" ]; then continue; fi
if [ "$idl_file" = "./scripts/idl/tests/inputs/several_clusters.matter" ]; then continue; fi
if [ "$idl_file" = "./scripts/idl/tests/inputs/simple_attribute.matter" ]; then continue; fi
if [ "$idl_file" = "./scripts/idl/tests/inputs/large_lighting_app.matter" ]; then continue; fi
if [ "$idl_file" = "./scripts/idl/tests/inputs/large_all_clusters_app.matter" ]; then continue; fi
./scripts/run_in_build_env.sh "./scripts/idl_lint.py --log-level warn $idl_file" >/dev/null || exit 1
done
Expand Down
2 changes: 1 addition & 1 deletion build/chip/chip_codegen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function(chip_codegen TARGET_NAME)
#
# find_package(Python3 REQUIRED)
add_custom_command(
OUTPUT "${OUT_NAMES}"
OUTPUT ${OUT_NAMES}
COMMAND "${CHIP_ROOT}/scripts/codegen.py"
ARGS "--generator" "${ARG_GENERATOR}"
"--output-dir" "${GEN_FOLDER}"
Expand Down
3 changes: 3 additions & 0 deletions build/chip/esp32/esp32_codegen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ macro(chip_app_component_codegen IDL_NAME)
GENERATOR "cpp-app"
OUTPUTS
"app/PluginApplicationCallbacks.h"
"app/callback-stub.cpp"
OUTPUT_PATH APP_GEN_DIR
OUTPUT_FILES APP_GEN_FILES
)

target_include_directories(${COMPONENT_LIB} PUBLIC "${APP_GEN_DIR}")

add_dependencies(${COMPONENT_LIB} app-codegen)

target_sources(${COMPONENT_LIB} PRIVATE ${APP_GEN_FILES})
endif()
endmacro()
17 changes: 5 additions & 12 deletions config/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -489,18 +489,11 @@ if (NOT ${APP_TARGET} MATCHES "shell")
${CHIP_ROOT}/src/app/clusters/ota-requestor/ota-requestor-server.cpp
)
else()
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)
chip_configure_data_model(${APP_TARGET}
ZAP_FILE ${CHIP_ROOT}/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap
GEN_DIR ${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated
)
target_include_directories(${APP_TARGET} PRIVATE
${GEN_DIR}/ota-requestor-app
)
target_sources(${APP_TARGET} PRIVATE
${GEN_DIR}//ota-requestor-app/zap-generated/callback-stub.cpp
${GEN_DIR}/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp
)
target_include_directories(${APP_TARGET}
PRIVATE ${GEN_DIR}/ota-requestor-app)

target_sources(${APP_TARGET}
PRIVATE ${GEN_DIR}/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp)
endif()

list(APPEND CHIP_DEFINES
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ endif (matter_enable_ota_requestor)
list(
APPEND ${list_chip_main_sources}

${chip_dir}/zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp
${chip_dir}/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp

${chip_dir}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ target_include_directories(${APP_TARGET} PRIVATE
target_sources(${APP_TARGET} PRIVATE
main/main.cpp
main/AppTask.cpp
${GEN_DIR}/all-clusters-app/zap-generated/callback-stub.cpp
${GEN_DIR}/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp
${MBED_COMMON}/util/LEDWidget.cpp
${MBED_COMMON}/util/DFUManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ target_sources(app PRIVATE
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
${GEN_DIR}/all-clusters-app/zap-generated/callback-stub.cpp
${GEN_DIR}/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp)

Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-app/nxp/mw320/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI
uint16_t maxReadLength)
{
// Added for the pairing of TE9 to report the commission_info
// default function (in zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp)
// default function (in callback-stub.cpp)
//
PRINTF("-> %s()\n\r", __FUNCTION__);
return EMBER_ZCL_STATUS_SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ target_sources(app PRIVATE
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
${GEN_DIR}/all-clusters-app/zap-generated/callback-stub.cpp
${GEN_DIR}/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp
${TELINK_COMMON}/util/src/LEDWidget.cpp
${TELINK_COMMON}/util/src/ButtonManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-minimal-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ endif (matter_enable_ota_requestor)
list(
APPEND ${list_chip_main_sources}

${chip_dir}/zzz_generated/all-clusters-minimal-app/zap-generated/callback-stub.cpp
${chip_dir}/zzz_generated/all-clusters-minimal-app/zap-generated/IMClusterCommandHandler.cpp

${chip_dir}/examples/all-clusters-minimal-app/all-clusters-common/src/bridged-actions-stub.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-minimal-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ target_include_directories(${APP_TARGET} PRIVATE
target_sources(${APP_TARGET} PRIVATE
main/main.cpp
main/AppTask.cpp
${GEN_DIR}/all-clusters-minimal-app/zap-generated/callback-stub.cpp
${GEN_DIR}/all-clusters-minimal-app/zap-generated/IMClusterCommandHandler.cpp
${MBED_COMMON}/util/LEDWidget.cpp
${MBED_COMMON}/util/DFUManager.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ target_sources(app PRIVATE
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
${GEN_DIR}/all-clusters-minimal-app/zap-generated/callback-stub.cpp
${GEN_DIR}/all-clusters-minimal-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp)

Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-minimal-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ target_sources(app PRIVATE
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
${GEN_DIR}/all-clusters-minimal-app/zap-generated/callback-stub.cpp
${GEN_DIR}/all-clusters-minimal-app/zap-generated/IMClusterCommandHandler.cpp
${TELINK_COMMON}/util/src/LEDWidget.cpp
${TELINK_COMMON}/util/src/ButtonManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/chef/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ endif (matter_enable_ota_requestor)
list(
APPEND ${list_chip_main_sources}

${chip_dir}/examples/chef/out/${SAMPLE_NAME}/zap-generated/callback-stub.cpp
${chip_dir}/examples/chef/out/${SAMPLE_NAME}/zap-generated/IMClusterCommandHandler.cpp

${matter_example_path}//main/chipinterface.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/chef/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ endif (CONFIG_ENABLE_CHIP_SHELL)
target_sources(app PRIVATE
${CHEF}/nrfconnect/main.cpp
${CHEF}/common/stubs.cpp
${GEN_DIR}/callback-stub.cpp
${GEN_DIR}/IMClusterCommandHandler.cpp
)

Expand Down
1 change: 0 additions & 1 deletion examples/light-switch-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ endif (matter_enable_ota_requestor)
list(
APPEND ${list_chip_main_sources}

${chip_dir}/zzz_generated/light-switch-app/zap-generated/callback-stub.cpp
${chip_dir}/zzz_generated/light-switch-app/zap-generated/IMClusterCommandHandler.cpp

${chip_dir}/examples/light-switch-app/ameba/main/chipinterface.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/light-switch-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ target_sources(app PRIVATE
main/LightSwitch.cpp
main/ShellCommands.cpp
main/BindingHandler.cpp
${GEN_DIR}/light-switch-app/zap-generated/callback-stub.cpp
${GEN_DIR}/light-switch-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp)

Expand Down
1 change: 0 additions & 1 deletion examples/light-switch-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ target_sources(app PRIVATE
src/main.cpp
src/ZclCallbacks.cpp
src/binding-handler.cpp
${GEN_DIR}/light-switch-app/zap-generated/callback-stub.cpp
${GEN_DIR}/light-switch-app/zap-generated/IMClusterCommandHandler.cpp
${TELINK_COMMON}/util/src/LEDWidget.cpp
${TELINK_COMMON}/util/src/ButtonManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ endif (matter_enable_ota_requestor)
list(
APPEND ${list_chip_main_sources}

${chip_dir}/zzz_generated/lighting-app/zap-generated/callback-stub.cpp
${chip_dir}/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp

${chip_dir}/examples/lighting-app/lighting-common/src/ColorFormat.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ target_sources(${APP_TARGET} PRIVATE
main/LightingManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/lighting-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp
${MBED_COMMON}/util/LEDWidget.cpp
${MBED_COMMON}/util/DFUManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ target_sources(app PRIVATE
main/AppTask.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/lighting-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp
${NRFCONNECT_COMMON}/util/PWMDevice.cpp)
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ target_sources(app PRIVATE
src/LightingManager.cpp
src/main.cpp
src/ZclCallbacks.cpp
${GEN_DIR}/lighting-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp
${TELINK_COMMON}/util/src/LEDWidget.cpp
${TELINK_COMMON}/util/src/ButtonManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ target_sources(${APP_TARGET} PRIVATE
main/BoltLockManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/lock-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lock-app/zap-generated/IMClusterCommandHandler.cpp
${MBED_COMMON}/util/LEDWidget.cpp
${MBED_COMMON}/util/DFUManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ target_sources(app PRIVATE
main/BoltLockManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/lock-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lock-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp)

Expand Down
1 change: 0 additions & 1 deletion examples/ota-requestor-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ include(${prj_root}/GCC-RELEASE/project_hp/asdk/includepath.cmake)
list(
APPEND ${list_chip_main_sources}

${chip_dir}/zzz_generated/ota-requestor-app/zap-generated/callback-stub.cpp
${chip_dir}/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp

${chip_dir}/examples/ota-requestor-app/ameba/main/chipinterface.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/ota-requestor-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ target_include_directories(${APP_TARGET} PRIVATE
target_sources(${APP_TARGET} PRIVATE
main/main.cpp
main/AppTask.cpp
${GEN_DIR}//ota-requestor-app/zap-generated/callback-stub.cpp
${GEN_DIR}/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp
${MBED_COMMON}/util/LEDWidget.cpp
${MBED_COMMON}/util/DFUManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/ota-requestor-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ target_sources(app PRIVATE
src/AppTask.cpp
src/main.cpp
src/ZclCallbacks.cpp
${GEN_DIR}/ota-requestor-app/zap-generated/callback-stub.cpp
${GEN_DIR}/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp
${TELINK_COMMON}/util/src/LEDWidget.cpp
${TELINK_COMMON}/util/src/ButtonManager.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/pump-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ target_sources(app PRIVATE
main/PumpManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/pump-app/zap-generated/callback-stub.cpp
${GEN_DIR}/pump-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp)

Expand Down
1 change: 0 additions & 1 deletion examples/pump-controller-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ target_sources(app PRIVATE
main/PumpManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/pump-controller-app/zap-generated/callback-stub.cpp
${GEN_DIR}/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp)

Expand Down
6 changes: 6 additions & 0 deletions examples/shell/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if(MBED_TARGET STREQUAL "CY8CPROTO_062_4343W" AND BOOT_ENABLED)
list(REMOVE_ITEM MBED_TARGET_LABELS CM0P_SLEEP)
list(REMOVE_ITEM MBED_TARGET_DEFINITIONS COMPONENT_CM0P_SLEEP=1)
endif()
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)

project(${APP_TARGET})

Expand Down Expand Up @@ -62,6 +63,11 @@ target_sources(${APP_TARGET} PRIVATE
${MBED_COMMON}/util/DFUManager.cpp
)

chip_configure_data_model(${APP_TARGET}
ZAP_FILE ${CHIP_ROOT}/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap
GEN_DIR ${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated
)

target_link_libraries(${APP_TARGET} mbed-os-posix-socket mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip)

if(MBED_TARGET STREQUAL "CY8CPROTO_062_4343W")
Expand Down
1 change: 0 additions & 1 deletion examples/window-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ target_sources(app PRIVATE
main/main.cpp
main/ZclCallbacks.cpp
main/WindowCovering.cpp
${GEN_DIR}/window-app/zap-generated/callback-stub.cpp
${GEN_DIR}/window-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp
${NRFCONNECT_COMMON}/util/PWMDevice.cpp)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{> header}}

#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/cluster-id.h>
#include <lib/support/Span.h>
Expand All @@ -12,21 +10,21 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
{
switch (clusterId)
{
{{#all_user_clusters_names}}
case ZCL_{{asDelimitedMacro define}}_ID :
emberAf{{asUpperCamelCase name}}ClusterInitCallback(endpoint);
{%- for name in clusters | sort(attribute='name') | map(attribute='name') | unique %}
case ZCL_{{name | normalize_acronyms | constcase}}_CLUSTER_ID:
emberAf{{name}}ClusterInitCallback(endpoint);
break;
{{/all_user_clusters_names}}
{%- endfor %}
default:
// Unrecognized cluster ID
break;
}
}

{{#all_user_clusters_names}}
void __attribute__((weak)) emberAf{{asUpperCamelCase name}}ClusterInitCallback(EndpointId endpoint)
{%- for name in clusters | sort(attribute='name') | map(attribute='name') | unique %}
void __attribute__((weak)) emberAf{{name}}ClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
{{/all_user_clusters_names}}
{%- endfor %}
10 changes: 10 additions & 0 deletions scripts/idl/generators/cpp/application/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ def internal_render_all(self):
'clusters': self.idl.clusters,
}
)

# Source for __attribute__(weak) implementations of all cluster
# initialization methods
self.internal_render_one_output(
template_path="cpp/application/CallbackStubSource.jinja",
output_file_name="app/callback-stub.cpp",
vars={
'clusters': self.idl.clusters,
}
)
12 changes: 11 additions & 1 deletion scripts/idl/generators/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import stringcase


def normalize_acronyms(s: str) -> str:
"""Replaces variations of acronyms when converting various words.
Specifically when considering how to generate a CONST_CASE constant,
strings such as WiFi should not be WI_FI but rather WIFI
"""
return s.replace('WiFi', 'Wifi').replace('WI_FI', 'WIFI')


def RegisterCommonFilters(filtermap):
"""
Register filters that are NOT considered platform-generator specific.
Expand All @@ -32,3 +40,5 @@ def RegisterCommonFilters(filtermap):
filtermap['pascalcase'] = stringcase.pascalcase
filtermap['snakecase'] = stringcase.snakecase
filtermap['spinalcase'] = stringcase.spinalcase

filtermap['normalize_acronyms'] = normalize_acronyms
9 changes: 9 additions & 0 deletions scripts/idl/tests/available_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,12 @@ bridge:
cpp-app:
inputs/several_clusters.matter:
app/PluginApplicationCallbacks.h: outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h
app/callback-stub.cpp: outputs/several_clusters/cpp-app/callback-stub.cpp

inputs/large_all_clusters_app.matter:
app/PluginApplicationCallbacks.h: outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h
app/callback-stub.cpp: outputs/large_all_clusters_app/cpp-app/callback-stub.cpp

inputs/large_lighting_app.matter:
app/PluginApplicationCallbacks.h: outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h
app/callback-stub.cpp: outputs/large_lighting_app/cpp-app/callback-stub.cpp
Loading

0 comments on commit d405f08

Please sign in to comment.