From 1067423644b0cfaa262cc60cc8e38d17edb1537f Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 6 Jan 2023 18:59:46 -0500 Subject: [PATCH] Restrict the set of structs for which we generate legacy definitions. (#24309) * Restrict the set of structs for which we generate legacy definitions. Most of the things in af-structs.h are not used, and fixing the names of some of them causes bad name collisions due to lack of namespacing. Just stop generating all of them except the ones we really use. * Address review comment --- .github/workflows/zap_regeneration.yaml | 2 +- .github/workflows/zap_templates.yaml | 2 +- .../docker/images/chip-cert-bins/Dockerfile | 2 +- .../common/templates/legacy-struct-list.yaml | 4 + src/app/common/templates/templates.json | 3 +- .../templates/app/af-structs.zapt | 2 + .../app-common/zap-generated/af-structs.h | 580 ------------------ 7 files changed, 11 insertions(+), 584 deletions(-) create mode 100644 src/app/common/templates/legacy-struct-list.yaml diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 72cdc5fbc47808..0c48caf5e2fa83 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.28 + image: connectedhomeip/chip-build:0.6.30 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index 4a53d2b180a1df..eb885803e1f969 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.28 + image: connectedhomeip/chip-build:0.6.30 defaults: run: shell: sh diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index d7d7cfa113ae79..ac4d6302c8f0b9 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -7,7 +7,7 @@ ARG COMMITHASH=451e602649b8b37ba6c9aab8ba5e30747293f778 # ZAP Development install, so that it runs on both x64 and arm64 # Generally this should match with the ZAP version that is used for codegen within the # specified SHA -ARG ZAP_VERSION=v2023.01.05-nightly +ARG ZAP_VERSION=v2023.01.06-nightly # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ diff --git a/src/app/common/templates/legacy-struct-list.yaml b/src/app/common/templates/legacy-struct-list.yaml new file mode 100644 index 00000000000000..974298a68d61be --- /dev/null +++ b/src/app/common/templates/legacy-struct-list.yaml @@ -0,0 +1,4 @@ +# List of structs for which we output a legacy definition in af-structs.h +# Ideally this list should become empty. +- DlCredential +- ApplicationBasicApplication diff --git a/src/app/common/templates/templates.json b/src/app/common/templates/templates.json index 400511cce6ff86..a4081365ebb99a 100644 --- a/src/app/common/templates/templates.json +++ b/src/app/common/templates/templates.json @@ -9,7 +9,8 @@ "templates/chip/helper.js" ], "resources": { - "weak-enum-list": "weak-enum-list.yaml" + "weak-enum-list": "weak-enum-list.yaml", + "legacy-struct-list": "legacy-struct-list.yaml" }, "override": "../../zap-templates/common/override.js", "partials": [ diff --git a/src/app/zap-templates/templates/app/af-structs.zapt b/src/app/zap-templates/templates/app/af-structs.zapt index 73f06b56b28cf4..1336de2ea491b7 100644 --- a/src/app/zap-templates/templates/app/af-structs.zapt +++ b/src/app/zap-templates/templates/app/af-structs.zapt @@ -15,6 +15,7 @@ {{#zcl_structs}} +{{#if (isLegacyStruct (asUnderlyingType label))}} {{#if itemCnt}} // Struct for {{label}} typedef struct _{{asType label}} { @@ -27,4 +28,5 @@ typedef struct _{{asType label}} { // this will result in all the references to the data being as uint8_t* typedef uint8_t {{asUnderlyingType label}}; {{/if}} +{{/if}} {{/zcl_structs}} diff --git a/zzz_generated/app-common/app-common/zap-generated/af-structs.h b/zzz_generated/app-common/app-common/zap-generated/af-structs.h index d64c50ff29177d..7beca18ed91d05 100644 --- a/zzz_generated/app-common/app-common/zap-generated/af-structs.h +++ b/zzz_generated/app-common/app-common/zap-generated/af-structs.h @@ -30,202 +30,6 @@ #include "enums.h" -// Struct for SimpleStruct -typedef struct _SimpleStruct -{ - uint8_t a; - bool b; - uint8_t c; - chip::ByteSpan d; - chip::CharSpan e; - uint8_t f; - float g; - double h; -} SimpleStruct; - -// Struct for TestFabricScoped -typedef struct _TestFabricScoped -{ - uint8_t fabricSensitiveInt8u; - uint8_t optionalFabricSensitiveInt8u; - uint8_t nullableFabricSensitiveInt8u; - uint8_t nullableOptionalFabricSensitiveInt8u; - chip::CharSpan fabricSensitiveCharString; - SimpleStruct fabricSensitiveStruct; - /* TYPE WARNING: array array defaults to */ uint8_t * fabricSensitiveInt8uList; - chip::FabricIndex FabricIndex; -} TestFabricScoped; - -// Struct for Dimension -typedef struct _Dimension -{ - double width; - double height; - uint8_t metric; -} Dimension; - -// Struct for AdditionalInfo -typedef struct _AdditionalInfo -{ - chip::CharSpan name; - chip::CharSpan value; -} AdditionalInfo; - -// Struct for NullablesAndOptionalsStruct -typedef struct _NullablesAndOptionalsStruct -{ - uint16_t NullableInt; - uint16_t OptionalInt; - uint16_t NullableOptionalInt; - chip::CharSpan NullableString; - chip::CharSpan OptionalString; - chip::CharSpan NullableOptionalString; - SimpleStruct NullableStruct; - SimpleStruct OptionalStruct; - SimpleStruct NullableOptionalStruct; - /* TYPE WARNING: array array defaults to */ uint8_t * NullableList; - /* TYPE WARNING: array array defaults to */ uint8_t * OptionalList; - /* TYPE WARNING: array array defaults to */ uint8_t * NullableOptionalList; -} NullablesAndOptionalsStruct; - -// Struct for NestedStruct -typedef struct _NestedStruct -{ - uint8_t a; - bool b; - SimpleStruct c; -} NestedStruct; - -// Struct for SemanticTag -typedef struct _SemanticTag -{ - uint16_t MfgCode; - uint16_t Value; -} SemanticTag; - -// Struct for ModeOptionStruct -typedef struct _ModeOptionStruct -{ - chip::CharSpan Label; - uint8_t Mode; - /* TYPE WARNING: array array defaults to */ uint8_t * SemanticTags; -} ModeOptionStruct; - -// Struct for AttributeValuePair -typedef struct _AttributeValuePair -{ - chip::AttributeId AttributeId; - /* TYPE WARNING: array array defaults to */ uint8_t * AttributeValue; -} AttributeValuePair; - -// Struct for ExtensionFieldSet -typedef struct _ExtensionFieldSet -{ - chip::ClusterId ClusterId; - /* TYPE WARNING: array array defaults to */ uint8_t * AttributeValueList; -} ExtensionFieldSet; - -// Struct for NestedStructList -typedef struct _NestedStructList -{ - uint8_t a; - bool b; - SimpleStruct c; - /* TYPE WARNING: array array defaults to */ uint8_t * d; - /* TYPE WARNING: array array defaults to */ uint8_t * e; - /* TYPE WARNING: array array defaults to */ uint8_t * f; - /* TYPE WARNING: array array defaults to */ uint8_t * g; -} NestedStructList; - -// Struct for DoubleNestedStructList -typedef struct _DoubleNestedStructList -{ - /* TYPE WARNING: array array defaults to */ uint8_t * a; -} DoubleNestedStructList; - -// Struct for Parameter -typedef struct _Parameter -{ - uint8_t type; - chip::CharSpan value; - /* TYPE WARNING: array array defaults to */ uint8_t * externalIDList; -} Parameter; - -// Struct for ContentSearch -typedef struct _ContentSearch -{ - /* TYPE WARNING: array array defaults to */ uint8_t * parameterList; -} ContentSearch; - -// Struct for StyleInformation -typedef struct _StyleInformation -{ - chip::CharSpan imageUrl; - chip::CharSpan color; - Dimension size; -} StyleInformation; - -// Struct for BrandingInformation -typedef struct _BrandingInformation -{ - chip::CharSpan providerName; - StyleInformation background; - StyleInformation logo; - StyleInformation progressBar; - StyleInformation splash; - StyleInformation waterMark; -} BrandingInformation; - -// Struct for Application -typedef struct _Application -{ - uint16_t catalogVendorId; - chip::CharSpan applicationId; -} Application; - -// Struct for ApplicationEP -typedef struct _ApplicationEP -{ - Application application; - chip::EndpointId endpoint; -} ApplicationEP; - -// Struct for Target -typedef struct _Target -{ - chip::ClusterId Cluster; - chip::EndpointId Endpoint; - chip::DeviceTypeId DeviceType; -} Target; - -// Struct for AccessControlEntryStruct -typedef struct _AccessControlEntryStruct -{ - uint8_t Privilege; - uint8_t AuthMode; - /* TYPE WARNING: array array defaults to */ uint8_t * Subjects; - /* TYPE WARNING: array array defaults to */ uint8_t * Targets; - chip::FabricIndex FabricIndex; -} AccessControlEntryStruct; - -// Struct for AccessControlExtensionStruct -typedef struct _AccessControlExtensionStruct -{ - chip::ByteSpan Data; - chip::FabricIndex FabricIndex; -} AccessControlExtensionStruct; - -// Struct for ActionStruct -typedef struct _ActionStruct -{ - uint16_t ActionID; - chip::CharSpan Name; - uint8_t Type; - uint16_t EndpointListID; - uint16_t SupportedCommands; - uint8_t State; -} ActionStruct; - // Struct for ApplicationBasicApplication typedef struct _ApplicationBasicApplication { @@ -233,393 +37,9 @@ typedef struct _ApplicationBasicApplication chip::CharSpan applicationId; } ApplicationBasicApplication; -// Struct for BasicCommissioningInfo -typedef struct _BasicCommissioningInfo -{ - uint16_t FailSafeExpiryLengthSeconds; - uint16_t MaxCumulativeFailsafeSeconds; -} BasicCommissioningInfo; - -// Struct for BatChargeFaultChangeType -typedef struct _BatChargeFaultChangeType -{ - /* TYPE WARNING: array array defaults to */ uint8_t * current; - /* TYPE WARNING: array array defaults to */ uint8_t * previous; -} BatChargeFaultChangeType; - -// Struct for BatFaultChangeType -typedef struct _BatFaultChangeType -{ - /* TYPE WARNING: array array defaults to */ uint8_t * current; - /* TYPE WARNING: array array defaults to */ uint8_t * previous; -} BatFaultChangeType; - -// Struct for CapabilityMinimaStruct -typedef struct _CapabilityMinimaStruct -{ - uint16_t CaseSessionsPerFabric; - uint16_t SubscriptionsPerFabric; -} CapabilityMinimaStruct; - -// Struct for ChannelInfo -typedef struct _ChannelInfo -{ - uint16_t majorNumber; - uint16_t minorNumber; - chip::CharSpan name; - chip::CharSpan callSign; - chip::CharSpan affiliateCallSign; -} ChannelInfo; - -// Struct for DeviceTypeStruct -typedef struct _DeviceTypeStruct -{ - chip::DeviceTypeId DeviceType; - uint16_t Revision; -} DeviceTypeStruct; - // Struct for DlCredential typedef struct _DlCredential { uint8_t CredentialType; uint16_t CredentialIndex; } DlCredential; - -// Struct for DstOffsetType -typedef struct _DstOffsetType -{ - int32_t Offset; - uint64_t ValidStarting; - uint64_t ValidUntil; -} DstOffsetType; - -// Struct for EndpointListStruct -typedef struct _EndpointListStruct -{ - uint16_t EndpointListID; - chip::CharSpan Name; - uint8_t Type; - /* TYPE WARNING: array array defaults to */ uint8_t * Endpoints; -} EndpointListStruct; - -// Struct for FabricDescriptor -typedef struct _FabricDescriptor -{ - chip::ByteSpan RootPublicKey; - chip::VendorId VendorId; - chip::FabricId FabricId; - chip::NodeId NodeId; - chip::CharSpan Label; - chip::FabricIndex FabricIndex; -} FabricDescriptor; - -// Struct for GroupInfoMapStruct -typedef struct _GroupInfoMapStruct -{ - chip::GroupId GroupId; - /* TYPE WARNING: array array defaults to */ uint8_t * Endpoints; - chip::CharSpan GroupName; - chip::FabricIndex FabricIndex; -} GroupInfoMapStruct; - -// Struct for GroupKeyMapStruct -typedef struct _GroupKeyMapStruct -{ - chip::GroupId GroupId; - uint16_t GroupKeySetID; - chip::FabricIndex FabricIndex; -} GroupKeyMapStruct; - -// Struct for GroupKeySetStruct -typedef struct _GroupKeySetStruct -{ - uint16_t GroupKeySetID; - uint8_t GroupKeySecurityPolicy; - chip::ByteSpan EpochKey0; - uint64_t EpochStartTime0; - chip::ByteSpan EpochKey1; - uint64_t EpochStartTime1; - chip::ByteSpan EpochKey2; - uint64_t EpochStartTime2; -} GroupKeySetStruct; - -// Struct for InputInfo -typedef struct _InputInfo -{ - uint8_t index; - uint8_t inputType; - chip::CharSpan name; - chip::CharSpan description; -} InputInfo; - -// Struct for LabelStruct -typedef struct _LabelStruct -{ - chip::CharSpan label; - chip::CharSpan value; -} LabelStruct; - -// Struct for LineupInfo -typedef struct _LineupInfo -{ - chip::CharSpan operatorName; - chip::CharSpan lineupName; - chip::CharSpan postalCode; - uint8_t lineupInfoType; -} LineupInfo; - -// Struct for MonitoringRegistration -typedef struct _MonitoringRegistration -{ - chip::NodeId ClientNodeId; - uint64_t ICid; - chip::FabricIndex FabricIndex; -} MonitoringRegistration; - -// Struct for NOCStruct -typedef struct _NOCStruct -{ - chip::ByteSpan NOC; - chip::ByteSpan ICAC; - chip::FabricIndex FabricIndex; -} NOCStruct; - -// Struct for NeighborTable -typedef struct _NeighborTable -{ - uint64_t ExtAddress; - uint32_t Age; - uint16_t Rloc16; - uint32_t LinkFrameCounter; - uint32_t MleFrameCounter; - uint8_t LQI; - int8_t AverageRssi; - int8_t LastRssi; - uint8_t FrameErrorRate; - uint8_t MessageErrorRate; - bool RxOnWhenIdle; - bool FullThreadDevice; - bool FullNetworkData; - bool IsChild; -} NeighborTable; - -// Struct for NetworkInfo -typedef struct _NetworkInfo -{ - chip::ByteSpan NetworkID; - bool Connected; -} NetworkInfo; - -// Struct for NetworkInterfaceType -typedef struct _NetworkInterfaceType -{ - chip::CharSpan Name; - bool IsOperational; - bool OffPremiseServicesReachableIPv4; - bool OffPremiseServicesReachableIPv6; - chip::ByteSpan HardwareAddress; - /* TYPE WARNING: array array defaults to */ uint8_t * IPv4Addresses; - /* TYPE WARNING: array array defaults to */ uint8_t * IPv6Addresses; - uint8_t Type; -} NetworkInterfaceType; - -// Struct for Notification -typedef struct _Notification -{ - uint16_t contentId; - uint8_t statusFeedback; -} Notification; - -// Struct for OperationalDatasetComponents -typedef struct _OperationalDatasetComponents -{ - bool ActiveTimestampPresent; - bool PendingTimestampPresent; - bool MasterKeyPresent; - bool NetworkNamePresent; - bool ExtendedPanIdPresent; - bool MeshLocalPrefixPresent; - bool DelayPresent; - bool PanIdPresent; - bool ChannelPresent; - bool PskcPresent; - bool SecurityPolicyPresent; - bool ChannelMaskPresent; -} OperationalDatasetComponents; - -// Struct for OutputInfo -typedef struct _OutputInfo -{ - uint8_t index; - uint8_t outputType; - chip::CharSpan name; -} OutputInfo; - -// Struct for PlaybackPosition -typedef struct _PlaybackPosition -{ - uint64_t updatedAt; - uint64_t position; -} PlaybackPosition; - -// Struct for ProviderLocation -typedef struct _ProviderLocation -{ - chip::NodeId ProviderNodeID; - chip::EndpointId Endpoint; - chip::FabricIndex FabricIndex; -} ProviderLocation; - -// Struct for ReadAttributeStatusRecord -typedef struct _ReadAttributeStatusRecord -{ - chip::AttributeId attributeId; - uint8_t status; - uint8_t attributeType; - uint8_t * attributeLocation; -} ReadAttributeStatusRecord; - -// Struct for ReadStructuredAttributeRecord -typedef struct _ReadStructuredAttributeRecord -{ - chip::AttributeId attributeId; - uint8_t indicator; - /* TYPE WARNING: array array defaults to */ uint8_t * indicies; -} ReadStructuredAttributeRecord; - -// Struct for RouteTable -typedef struct _RouteTable -{ - uint64_t ExtAddress; - uint16_t Rloc16; - uint8_t RouterId; - uint8_t NextHop; - uint8_t PathCost; - uint8_t LQIIn; - uint8_t LQIOut; - uint8_t Age; - bool Allocated; - bool LinkEstablished; -} RouteTable; - -// Struct for SecurityPolicy -typedef struct _SecurityPolicy -{ - uint16_t RotationTime; - uint16_t Flags; -} SecurityPolicy; - -// Struct for TargetInfo -typedef struct _TargetInfo -{ - uint8_t identifier; - chip::CharSpan name; -} TargetInfo; - -// Struct for TargetStruct -typedef struct _TargetStruct -{ - chip::NodeId Node; - chip::GroupId Group; - chip::EndpointId Endpoint; - chip::ClusterId Cluster; - chip::FabricIndex FabricIndex; -} TargetStruct; - -// Struct for TestListStructOctet -typedef struct _TestListStructOctet -{ - uint64_t member1; - chip::ByteSpan member2; -} TestListStructOctet; - -// Struct for ThermostatScheduleTransition -typedef struct _ThermostatScheduleTransition -{ - uint16_t TransitionTime; - int16_t HeatSetpoint; - int16_t CoolSetpoint; -} ThermostatScheduleTransition; - -// Struct for ThreadInterfaceScanResult -typedef struct _ThreadInterfaceScanResult -{ - uint16_t PanId; - uint64_t ExtendedPanId; - chip::CharSpan NetworkName; - uint16_t Channel; - uint8_t Version; - chip::ByteSpan ExtendedAddress; - int8_t RSSI; - uint8_t LQI; -} ThreadInterfaceScanResult; - -// Struct for ThreadMetricsStruct -typedef struct _ThreadMetricsStruct -{ - uint64_t Id; - chip::CharSpan Name; - uint32_t StackFreeCurrent; - uint32_t StackFreeMinimum; - uint32_t StackSize; -} ThreadMetricsStruct; - -// Struct for TimeZoneType -typedef struct _TimeZoneType -{ - int32_t Offset; - uint64_t ValidAt; - chip::CharSpan Name; -} TimeZoneType; - -// Struct for WiFiInterfaceScanResult -typedef struct _WiFiInterfaceScanResult -{ - uint8_t Security; - chip::ByteSpan SSID; - chip::ByteSpan BSSID; - uint16_t Channel; - uint8_t WiFiBand; - int8_t RSSI; -} WiFiInterfaceScanResult; - -// Struct for WiredFaultChangeType -typedef struct _WiredFaultChangeType -{ - /* TYPE WARNING: array array defaults to */ uint8_t * current; - /* TYPE WARNING: array array defaults to */ uint8_t * previous; -} WiredFaultChangeType; - -// Struct for WriteAttributeRecord -typedef struct _WriteAttributeRecord -{ - chip::AttributeId attributeId; - uint8_t attributeType; - uint8_t * attributeLocation; -} WriteAttributeRecord; - -// Struct for WriteAttributeStatusRecord -typedef struct _WriteAttributeStatusRecord -{ - uint8_t status; - chip::AttributeId attributeId; -} WriteAttributeStatusRecord; - -// Struct for WriteStructuredAttributeRecord -typedef struct _WriteStructuredAttributeRecord -{ - chip::AttributeId attributeId; - uint8_t indicator; - /* TYPE WARNING: array array defaults to */ uint8_t * indicies; - uint8_t attributeType; - uint8_t * attributeLocation; -} WriteStructuredAttributeRecord; - -// Struct for WriteStructuredAttributeStatusRecord -typedef struct _WriteStructuredAttributeStatusRecord -{ - uint8_t status; - chip::AttributeId attributeId; - uint8_t indicator; - /* TYPE WARNING: array array defaults to */ uint8_t * indicies; -} WriteStructuredAttributeStatusRecord;