Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion scripts/fbt/appmanifest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import re
from dataclasses import dataclass, field
from enum import Enum
from typing import Callable, List, Optional, Tuple, Union
from typing import Callable, ClassVar, List, Optional, Tuple, Union


class FlipperManifestException(Exception):
Expand All @@ -23,6 +24,8 @@ class FlipperAppType(Enum):

@dataclass
class FlipperApplication:
APP_ID_REGEX: ClassVar[re.Pattern] = re.compile(r"^[a-z0-9_]+$")

@dataclass
class ExternallyBuiltFile:
path: str
Expand Down Expand Up @@ -84,6 +87,10 @@ def is_default_deployable(self):
def __post_init__(self):
if self.apptype == FlipperAppType.PLUGIN:
self.stack_size = 0
if not self.APP_ID_REGEX.match(self.appid):
raise FlipperManifestException(
f"Invalid appid '{self.appid}'. Must match regex '{self.APP_ID_REGEX}'"
)
if isinstance(self.fap_version, str):
try:
self.fap_version = tuple(int(v) for v in self.fap_version.split("."))
Expand Down
8 changes: 7 additions & 1 deletion scripts/ufbt/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ from fbt.util import (
wrap_tempfile,
path_as_posix,
)
from fbt.appmanifest import FlipperAppType
from fbt.appmanifest import FlipperAppType, FlipperApplication
from fbt.sdk.cache import SdkCache

# Base environment with all tools loaded from SDK
Expand Down Expand Up @@ -410,6 +410,12 @@ dist_env.Alias("vscode_dist", vscode_dist)
# Creating app from base template

dist_env.SetDefault(FBT_APPID=appenv.subst("$APPID") or "template")
if fbt_appid := dist_env.subst("$FBT_APPID"):
if not FlipperApplication.APP_ID_REGEX.match(fbt_appid):
raise UserError(
f"Invalid app id '{fbt_appid}'. App id must match {FlipperApplication.APP_ID_REGEX.pattern}"
)

app_template_dir = project_template_dir.Dir("app_template")
app_template_dist = []
for template_file in app_template_dir.glob("*"):
Expand Down