Matter SDK plugin

Experimental

The Matter SDK plugin is experimental and subject to change. It can only be used by setting the --enable-experimental-plugins flag during a build.

Note

This plugin is only available on snaps with base core22 or later. See Base snaps for more details. It is supported on Snapcraft 8.1.0 and later.

The Matter SDK plugin simplifies the building of parts that use the connectedhomeip Matter SDK. It abstracts away SDK setup and configuration when creating a snapped Matter application.

Keywords

In addition to the common plugin and sources keywords, this plugin provides the following plugin-specific keyword:

matter-sdk-version

Type: string

Required

The Matter SDK version the plugin will use. This value must match one of the existing tags <https://github.com/project-chip/connectedhomeip/tags> in the SDK repository.

Dependencies

This plugin has no dependencies.

How it works

The project file for a snap using this plugin should include the following:

Plugin part

Bootstrapping the SDK requires resource-intensive operations such as cloning several repositories and building the various artifacts. To save resources and allow for caching while iterating over the application build, the plugin should be used in a standalone part. For example:

snapcraft.yaml
parts:
  matter-sdk:
    plugin: matter-sdk
    matter-sdk-version: v1.3.0.0

Application part

The application’s part should be built after staging the SDK.

The application can use any of the existing Snapcraft plugins, but it must be made aware of the directories where the SDK was built. This can be done by sourcing the bash script generated by the Matter SDK plugin at $CRAFT_STAGE/matter-sdk-env.sh. For example:

snapcraft.yaml
parts:
  [...]
  my-app:
    after:
      - matter-sdk
    plugin: nil
    override-build: |
      # Prepare the environment for using the SDK
      source $CRAFT_STAGE/matter-sdk-env.sh

      # Build the Matter application
      [...]

Layout mapping

The plugin changes the SDK’s default paths from /tmp to /mnt for writing storage and platform configurations. This allows applications to retain data across reboots. To enable this functionality, declare the following layout to bind a writable directory inside the snap to /mnt.

snapcraft.yaml
layout:
  /mnt:
    bind: $SNAP_COMMON/mnt

For more details on defining layouts, refer to Layouts.