The matter-sdk plugin

The matter-sdk plugin is useful when building parts that use the connectedhomeip Matter SDK. It abstracts away bootstrapping and tweaking of the SDK for creating a snapped Matter application.

ⓘ This plugin is only available starting with core22 based snaps. See Base snaps for details. It is supported on Snapcraft 8.1.0 and later.

:warning: The plugin is experimental and subject to change. It can only be used when setting --enable-experimental-plugins flag during the build.

This plugin uses the common plugin keywords as well as those for “sources”. For more information, see Snapcraft parts metadata.

Additionally, this plugin uses the following plugin-specific keywords:

  • matter-sdk-version (string, required) The value must match one of the existing tags on the SDK repository.

The snapcraft.yaml for a snap using this plugin, should include the following:

Plugin part

Bootstrapping the SDK involved resource consuming operations such as cloning several repositories, pulling and building various artifacts. To allow caching and save resources while re-iterating over the application build, the plugin should be used in a standalone part. The following is an example for using a released version of the SDK:

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 needs to be made aware of the directories where the SDK has been built. This can be done by sourcing the bash script produced by the Matter SDK plugin at $CRAFT_STAGE/matter-sdk-env.sh.

For example:

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 replaces the SDK’s default paths from /tmp to /mnt for writing storage and platform configurations. This makes it possible to run the applications with persistency across reboots. To make this work as expected, declare the following layout to bind mount a writable directory within the snap to /mnt.

layout:
  /mnt:
    bind: $SNAP_COMMON/mnt

For details on the above definition syntax, refer to Layouts.


For complete examples, search GitHub for projects already using the plugin.

ⓘ This is a snapcraft plugin. See Snapcraft plugins and Supported plugins for further details on how plugins are used.

1 Like