Skip to content

Commit

Permalink
Enhance formatting and remove redundant copy command
Browse files Browse the repository at this point in the history
- address linter errors
- improve readability
  • Loading branch information
MonicaisHer committed Jan 2, 2024
1 parent 90740f3 commit 18b3a68
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion snapcraft/parts/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from .conda_plugin import CondaPlugin
from .flutter_plugin import FlutterPlugin
from .kernel_plugin import KernelPlugin
from .python_plugin import PythonPlugin
from .matter_plugin import MatterPlugin
from .python_plugin import PythonPlugin
from .register import register

__all__ = [
Expand Down
71 changes: 36 additions & 35 deletions snapcraft/parts/plugins/matter_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

"""The matter plugin."""
import os

from typing import Any, Dict, List, Set, cast

from craft_parts import infos, plugins
from overrides import overrides

# The repository where the matter SDK resides.
MATTER_REPO = "https://github.com/project-chip/connectedhomeip.git"
"""The repository where the matter SDK resides."""


class MatterPluginProperties(plugins.PluginProperties, plugins.PluginModel):
Expand All @@ -44,7 +43,9 @@ def unmarshal(cls, data: Dict[str, Any]) -> "MatterPluginProperties":
:raise pydantic.ValidationError: If validation fails.
"""
plugin_data = plugins.extract_plugin_properties(
data, plugin_name="matter", required=["matter_sdk_version", "matter_zap_version"]
data,
plugin_name="matter",
required=["matter_sdk_version", "matter_zap_version"],
)
return cls(**plugin_data)

Expand Down Expand Up @@ -80,24 +81,24 @@ def __init__(
@overrides
def get_build_packages(self) -> Set[str]:
return {
"wget",
"unzip",
"clang",
"pkg-config",
"git",
"cmake",
"ninja-build",
"libssl-dev",
"generate-ninja",
"git",
"libavahi-client-dev",
"libcairo2-dev",
"libdbus-1-dev",
"libgirepository1.0-dev",
"libglib2.0-dev",
"libavahi-client-dev",
"python3-venv",
"libreadline-dev",
"libssl-dev",
"ninja-build",
"pkg-config",
"python3-dev",
"python3-pip",
"libgirepository1.0-dev",
"libcairo2-dev",
"libreadline-dev",
"generate-ninja",
"python3-venv",
"unzip",
"wget",
}

@overrides
Expand Down Expand Up @@ -126,28 +127,33 @@ def get_build_commands(self) -> List[str]:
# Clone Matter repository if not present
commands.extend(
[
f"if [ ! -d matter ]; then git clone --depth 1 -b {options.matter_sdk_version} "
f"{MATTER_REPO} matter && cd matter; else cd matter || echo 'skip clone'; fi"
"if [ ! -d matter ]; then",
f" git clone --depth 1 -b {options.matter_sdk_version} {MATTER_REPO} matter;",
"else",
" echo 'Matter repository already exists, skip clone';",
"fi",
"cd matter;",
]
)

# Checkout submodules for Linux platform
commands.extend(["scripts/checkout_submodules.py --shallow --platform linux"])

"""
"""
The project writes its data to /tmp which isn't persisted.
Setting TMPDIR env var when running the app isn't sufficient as
chip_[config,counter,factory,kvs].ini still get written under /tmp.
The chip-tool currently has no way of overriding the default paths to
storage and security config files.
Setting TMPDIR env var when running the app isn't sufficient as
chip_[config,counter,factory,kvs].ini still get written under /tmp.
The chip-tool currently has no way of overriding the default paths to
storage and security config files.
Snap does not allow bind mounting a persistent directory on /tmp,
so we need to replace it in the source with another path, e.g. /mnt.
See the top-level layout definition which bind mounts a persisted
directory within the confined snap space on /mnt.
Snap does not allow bind mounting a persistent directory on /tmp,
so we need to replace it in the source with another path, e.g. /mnt.
See the top-level layout definition which bind mounts a persisted
directory within the confined snap space on /mnt.
"""
"""Replace storage paths"""

# Replace storage paths
commands.extend(
[
r"sed -i 's/\/tmp/\/mnt/g' src/platform/Linux/CHIPLinuxStorage.h",
Expand All @@ -156,18 +162,13 @@ def get_build_commands(self) -> List[str]:
)

"""
Bootstrapping script for building Matter SDK with minimal "build" requirements
and setting up the environment
Bootstrapping script for building Matter SDK with minimal "build" requirements
and setting up the environment.
"""
commands.extend(
["set +u && source setup/bootstrap.sh --platform build && set -u"]
)

commands.extend(
[
"cp -vr ./* $CRAFT_PART_INSTALL/",
"echo 'Cloned Matter repository and built Matter SDK'",
]
)
commands.extend(["echo 'Built Matter SDK'"])

return commands
2 changes: 1 addition & 1 deletion snapcraft/parts/plugins/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from .conda_plugin import CondaPlugin
from .flutter_plugin import FlutterPlugin
from .kernel_plugin import KernelPlugin
from .python_plugin import PythonPlugin
from .matter_plugin import MatterPlugin
from .python_plugin import PythonPlugin


def register() -> None:
Expand Down

0 comments on commit 18b3a68

Please sign in to comment.