2023-05-03 08:48:49 +03:00
|
|
|
import os
|
2023-06-07 05:14:33 +03:00
|
|
|
import re
|
2022-06-26 15:00:03 +03:00
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from enum import Enum
|
2023-06-07 05:14:33 +03:00
|
|
|
from typing import Callable, ClassVar, List, Optional, Tuple, Union
|
2022-06-26 15:00:03 +03:00
|
|
|
|
2023-08-22 20:11:53 +03:00
|
|
|
try:
|
|
|
|
from fbt.util import resolve_real_dir_node
|
|
|
|
except ImportError:
|
|
|
|
# When running outside of SCons, we don't have access to SCons.Node
|
|
|
|
def resolve_real_dir_node(node):
|
|
|
|
return node
|
|
|
|
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
class FlipperManifestException(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class FlipperAppType(Enum):
|
|
|
|
SERVICE = "Service"
|
|
|
|
SYSTEM = "System"
|
|
|
|
APP = "App"
|
|
|
|
DEBUG = "Debug"
|
|
|
|
ARCHIVE = "Archive"
|
|
|
|
SETTINGS = "Settings"
|
|
|
|
STARTUP = "StartupHook"
|
|
|
|
EXTERNAL = "External"
|
2023-07-10 11:03:41 +03:00
|
|
|
MENUEXTERNAL = "MenuExternal"
|
2022-06-26 15:00:03 +03:00
|
|
|
METAPACKAGE = "Package"
|
2023-03-14 17:29:28 +03:00
|
|
|
PLUGIN = "Plugin"
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class FlipperApplication:
|
2023-06-07 05:14:33 +03:00
|
|
|
APP_ID_REGEX: ClassVar[re.Pattern] = re.compile(r"^[a-z0-9_]+$")
|
2023-11-15 19:27:35 +03:00
|
|
|
PRIVATE_FIELD_PREFIX: ClassVar[str] = "_"
|
|
|
|
APP_MANIFEST_DEFAULT_NAME: ClassVar[str] = "application.fam"
|
2023-06-07 05:14:33 +03:00
|
|
|
|
2022-10-06 16:55:57 +03:00
|
|
|
@dataclass
|
|
|
|
class ExternallyBuiltFile:
|
|
|
|
path: str
|
|
|
|
command: str
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Library:
|
|
|
|
name: str
|
|
|
|
fap_include_paths: List[str] = field(default_factory=lambda: ["."])
|
|
|
|
sources: List[str] = field(default_factory=lambda: ["*.c*"])
|
|
|
|
cflags: List[str] = field(default_factory=list)
|
|
|
|
cdefines: List[str] = field(default_factory=list)
|
|
|
|
cincludes: List[str] = field(default_factory=list)
|
|
|
|
|
2022-06-26 15:00:03 +03:00
|
|
|
appid: str
|
|
|
|
apptype: FlipperAppType
|
2022-09-14 19:11:38 +03:00
|
|
|
name: Optional[str] = ""
|
2022-06-26 15:00:03 +03:00
|
|
|
entry_point: Optional[str] = None
|
|
|
|
flags: List[str] = field(default_factory=lambda: ["Default"])
|
|
|
|
cdefines: List[str] = field(default_factory=list)
|
|
|
|
requires: List[str] = field(default_factory=list)
|
|
|
|
conflicts: List[str] = field(default_factory=list)
|
|
|
|
provides: List[str] = field(default_factory=list)
|
|
|
|
stack_size: int = 2048
|
|
|
|
icon: Optional[str] = None
|
|
|
|
order: int = 0
|
2022-09-14 19:11:38 +03:00
|
|
|
sdk_headers: List[str] = field(default_factory=list)
|
2022-11-10 14:55:11 +03:00
|
|
|
targets: List[str] = field(default_factory=lambda: ["all"])
|
2023-10-30 18:17:30 +03:00
|
|
|
resources: Optional[str] = None
|
2022-11-10 14:55:11 +03:00
|
|
|
|
2022-09-19 15:39:00 +03:00
|
|
|
# .fap-specific
|
2022-09-14 19:11:38 +03:00
|
|
|
sources: List[str] = field(default_factory=lambda: ["*.c*"])
|
2023-05-21 20:50:38 +03:00
|
|
|
fap_version: Union[str, Tuple[int]] = "0.1"
|
2022-09-14 19:11:38 +03:00
|
|
|
fap_icon: Optional[str] = None
|
|
|
|
fap_libs: List[str] = field(default_factory=list)
|
|
|
|
fap_category: str = ""
|
2022-09-19 15:39:00 +03:00
|
|
|
fap_description: str = ""
|
|
|
|
fap_author: str = ""
|
|
|
|
fap_weburl: str = ""
|
2022-10-06 16:55:57 +03:00
|
|
|
fap_icon_assets: Optional[str] = None
|
2022-11-28 19:27:16 +03:00
|
|
|
fap_icon_assets_symbol: Optional[str] = None
|
2022-10-06 16:55:57 +03:00
|
|
|
fap_extbuild: List[ExternallyBuiltFile] = field(default_factory=list)
|
|
|
|
fap_private_libs: List[Library] = field(default_factory=list)
|
2023-03-09 18:01:53 +03:00
|
|
|
fap_file_assets: Optional[str] = None
|
2023-09-21 15:56:00 +03:00
|
|
|
fal_embedded: bool = False
|
2022-09-19 15:39:00 +03:00
|
|
|
# Internally used by fbt
|
2023-03-14 17:29:28 +03:00
|
|
|
_appmanager: Optional["AppManager"] = None
|
2022-09-14 19:11:38 +03:00
|
|
|
_appdir: Optional[object] = None
|
|
|
|
_apppath: Optional[str] = None
|
2023-03-14 17:29:28 +03:00
|
|
|
_plugins: List["FlipperApplication"] = field(default_factory=list)
|
2023-09-21 15:56:00 +03:00
|
|
|
_assets_dirs: List[object] = field(default_factory=list)
|
|
|
|
_section_fapmeta: Optional[object] = None
|
|
|
|
_section_fapfileassets: Optional[object] = None
|
|
|
|
|
|
|
|
@property
|
|
|
|
def embeds_plugins(self):
|
|
|
|
return any(plugin.fal_embedded for plugin in self._plugins)
|
2022-06-26 15:00:03 +03:00
|
|
|
|
2023-02-07 19:33:05 +03:00
|
|
|
def supports_hardware_target(self, target: str):
|
|
|
|
return target in self.targets or "all" in self.targets
|
|
|
|
|
2023-03-14 17:29:28 +03:00
|
|
|
@property
|
|
|
|
def is_default_deployable(self):
|
|
|
|
return self.apptype != FlipperAppType.DEBUG and self.fap_category != "Examples"
|
|
|
|
|
2023-10-23 12:55:36 +03:00
|
|
|
@property
|
|
|
|
def do_strict_import_checks(self):
|
|
|
|
return self.apptype != FlipperAppType.PLUGIN
|
|
|
|
|
2023-03-14 17:29:28 +03:00
|
|
|
def __post_init__(self):
|
|
|
|
if self.apptype == FlipperAppType.PLUGIN:
|
|
|
|
self.stack_size = 0
|
2023-06-07 05:14:33 +03:00
|
|
|
if not self.APP_ID_REGEX.match(self.appid):
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"Invalid appid '{self.appid}'. Must match regex '{self.APP_ID_REGEX}'"
|
|
|
|
)
|
2023-05-14 14:49:52 +03:00
|
|
|
if isinstance(self.fap_version, str):
|
|
|
|
try:
|
|
|
|
self.fap_version = tuple(int(v) for v in self.fap_version.split("."))
|
|
|
|
except ValueError:
|
|
|
|
raise FlipperManifestException(
|
2023-11-15 19:27:35 +03:00
|
|
|
f"Invalid version '{self.fap_version}'. Must be in the form 'major.minor'"
|
2023-05-14 14:49:52 +03:00
|
|
|
)
|
2023-11-15 19:27:35 +03:00
|
|
|
if len(self.fap_version) < 2:
|
|
|
|
raise ValueError("Not enough version components")
|
2023-03-14 17:29:28 +03:00
|
|
|
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
class AppManager:
|
|
|
|
def __init__(self):
|
|
|
|
self.known_apps = {}
|
|
|
|
|
|
|
|
def get(self, appname: str):
|
|
|
|
try:
|
|
|
|
return self.known_apps[appname]
|
2023-05-03 08:48:49 +03:00
|
|
|
except KeyError:
|
2022-06-26 15:00:03 +03:00
|
|
|
raise FlipperManifestException(
|
|
|
|
f"Missing application manifest for '{appname}'"
|
|
|
|
)
|
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
def find_by_appdir(self, appdir: str):
|
|
|
|
for app in self.known_apps.values():
|
|
|
|
if app._appdir.name == appdir:
|
|
|
|
return app
|
|
|
|
return None
|
|
|
|
|
2023-03-14 17:29:28 +03:00
|
|
|
def _validate_app_params(self, *args, **kw):
|
|
|
|
apptype = kw.get("apptype")
|
|
|
|
if apptype == FlipperAppType.PLUGIN:
|
|
|
|
if kw.get("stack_size"):
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"Plugin {kw.get('appid')} cannot have stack (did you mean FlipperAppType.EXTERNAL?)"
|
|
|
|
)
|
|
|
|
if not kw.get("requires"):
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"Plugin {kw.get('appid')} must have 'requires' in manifest"
|
|
|
|
)
|
2023-09-21 15:56:00 +03:00
|
|
|
else:
|
|
|
|
if kw.get("fal_embedded"):
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"App {kw.get('appid')} cannot have fal_embedded set"
|
|
|
|
)
|
2023-11-15 19:27:35 +03:00
|
|
|
|
|
|
|
if apptype in AppBuildset.dist_app_types:
|
|
|
|
# For distributing .fap's resources, there's "fap_file_assets"
|
|
|
|
for app_property in ("resources",):
|
|
|
|
if kw.get(app_property):
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"App {kw.get('appid')} of type {apptype} cannot have '{app_property}' in manifest"
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
for app_property in ("fap_extbuild", "fap_private_libs", "fap_icon_assets"):
|
|
|
|
if kw.get(app_property):
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"App {kw.get('appid')} of type {apptype} must not have '{app_property}' in manifest"
|
|
|
|
)
|
2023-03-14 17:29:28 +03:00
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
def load_manifest(self, app_manifest_path: str, app_dir_node: object):
|
2022-06-26 15:00:03 +03:00
|
|
|
if not os.path.exists(app_manifest_path):
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"App manifest not found at path {app_manifest_path}"
|
|
|
|
)
|
|
|
|
# print("Loading", app_manifest_path)
|
|
|
|
|
|
|
|
app_manifests = []
|
|
|
|
|
|
|
|
def App(*args, **kw):
|
|
|
|
nonlocal app_manifests
|
2023-03-14 17:29:28 +03:00
|
|
|
self._validate_app_params(*args, **kw)
|
2022-09-14 19:11:38 +03:00
|
|
|
app_manifests.append(
|
|
|
|
FlipperApplication(
|
|
|
|
*args,
|
|
|
|
**kw,
|
2023-08-10 19:21:56 +03:00
|
|
|
_appdir=resolve_real_dir_node(app_dir_node),
|
2022-09-14 19:11:38 +03:00
|
|
|
_apppath=os.path.dirname(app_manifest_path),
|
2023-03-14 17:29:28 +03:00
|
|
|
_appmanager=self,
|
2022-09-14 19:11:38 +03:00
|
|
|
),
|
|
|
|
)
|
2022-06-26 15:00:03 +03:00
|
|
|
|
2022-10-06 16:55:57 +03:00
|
|
|
def ExtFile(*args, **kw):
|
|
|
|
return FlipperApplication.ExternallyBuiltFile(*args, **kw)
|
|
|
|
|
|
|
|
def Lib(*args, **kw):
|
|
|
|
return FlipperApplication.Library(*args, **kw)
|
|
|
|
|
2022-07-14 19:24:26 +03:00
|
|
|
try:
|
|
|
|
with open(app_manifest_path, "rt") as manifest_file:
|
|
|
|
exec(manifest_file.read())
|
|
|
|
except Exception as e:
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"Failed parsing manifest '{app_manifest_path}' : {e}"
|
|
|
|
)
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
if len(app_manifests) == 0:
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"App manifest '{app_manifest_path}' is malformed"
|
|
|
|
)
|
|
|
|
|
|
|
|
# print("Built", app_manifests)
|
|
|
|
for app in app_manifests:
|
|
|
|
self._add_known_app(app)
|
|
|
|
|
|
|
|
def _add_known_app(self, app: FlipperApplication):
|
|
|
|
if self.known_apps.get(app.appid, None):
|
|
|
|
raise FlipperManifestException(f"Duplicate app declaration: {app.appid}")
|
|
|
|
self.known_apps[app.appid] = app
|
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
def filter_apps(
|
|
|
|
self,
|
|
|
|
*,
|
|
|
|
applist: List[str],
|
|
|
|
ext_applist: List[str],
|
|
|
|
hw_target: str,
|
|
|
|
):
|
|
|
|
return AppBuildset(
|
|
|
|
self,
|
|
|
|
hw_target=hw_target,
|
|
|
|
appnames=applist,
|
|
|
|
extra_ext_appnames=ext_applist,
|
|
|
|
)
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
class AppBuilderException(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class AppBuildset:
|
|
|
|
BUILTIN_APP_TYPES = (
|
|
|
|
FlipperAppType.SERVICE,
|
|
|
|
FlipperAppType.SYSTEM,
|
|
|
|
FlipperAppType.APP,
|
|
|
|
FlipperAppType.DEBUG,
|
|
|
|
FlipperAppType.ARCHIVE,
|
|
|
|
FlipperAppType.SETTINGS,
|
|
|
|
FlipperAppType.STARTUP,
|
|
|
|
)
|
2023-11-02 16:28:39 +03:00
|
|
|
EXTERNAL_APP_TYPES_MAP = {
|
2023-11-15 19:27:35 +03:00
|
|
|
# AppType -> bool: true if always deploy, false if obey app set
|
2023-11-02 16:28:39 +03:00
|
|
|
FlipperAppType.EXTERNAL: True,
|
|
|
|
FlipperAppType.PLUGIN: True,
|
|
|
|
FlipperAppType.DEBUG: True,
|
|
|
|
FlipperAppType.MENUEXTERNAL: False,
|
|
|
|
}
|
2022-06-26 15:00:03 +03:00
|
|
|
|
2023-11-15 19:27:35 +03:00
|
|
|
@classmethod
|
|
|
|
@property
|
|
|
|
def dist_app_types(cls):
|
|
|
|
"""Applications that are installed on SD card"""
|
|
|
|
return list(
|
|
|
|
entry[0] for entry in cls.EXTERNAL_APP_TYPES_MAP.items() if entry[1]
|
|
|
|
)
|
|
|
|
|
2023-02-07 19:33:05 +03:00
|
|
|
@staticmethod
|
|
|
|
def print_writer(message):
|
|
|
|
print(message)
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
appmgr: AppManager,
|
|
|
|
hw_target: str,
|
2023-09-05 14:49:39 +03:00
|
|
|
appnames: List[str],
|
|
|
|
*,
|
|
|
|
extra_ext_appnames: List[str],
|
2023-07-10 11:03:41 +03:00
|
|
|
message_writer: Callable | None = None,
|
2023-02-07 19:33:05 +03:00
|
|
|
):
|
2022-06-26 15:00:03 +03:00
|
|
|
self.appmgr = appmgr
|
|
|
|
self.appnames = set(appnames)
|
2023-09-05 14:49:39 +03:00
|
|
|
self.incompatible_extapps, self.extapps = [], []
|
|
|
|
self._extra_ext_appnames = extra_ext_appnames
|
2022-06-26 15:00:03 +03:00
|
|
|
self._orig_appnames = appnames
|
2023-02-07 19:33:05 +03:00
|
|
|
self.hw_target = hw_target
|
|
|
|
self._writer = message_writer if message_writer else self.print_writer
|
2022-06-26 15:00:03 +03:00
|
|
|
self._process_deps()
|
2023-09-05 14:49:39 +03:00
|
|
|
self._process_ext_apps()
|
2022-06-26 15:00:03 +03:00
|
|
|
self._check_conflicts()
|
|
|
|
self._check_unsatisfied() # unneeded?
|
2023-02-07 19:33:05 +03:00
|
|
|
self._check_target_match()
|
2023-03-14 17:29:28 +03:00
|
|
|
self._group_plugins()
|
2023-10-30 18:17:30 +03:00
|
|
|
self._apps = sorted(
|
2022-06-26 15:00:03 +03:00
|
|
|
list(map(self.appmgr.get, self.appnames)),
|
|
|
|
key=lambda app: app.appid,
|
|
|
|
)
|
|
|
|
|
2023-10-30 18:17:30 +03:00
|
|
|
@property
|
|
|
|
def apps(self):
|
|
|
|
return list(self._apps)
|
|
|
|
|
2022-06-26 15:00:03 +03:00
|
|
|
def _is_missing_dep(self, dep_name: str):
|
|
|
|
return dep_name not in self.appnames
|
|
|
|
|
2023-02-07 19:33:05 +03:00
|
|
|
def _check_if_app_target_supported(self, app_name: str):
|
|
|
|
return self.appmgr.get(app_name).supports_hardware_target(self.hw_target)
|
|
|
|
|
|
|
|
def _get_app_depends(self, app_name: str) -> List[str]:
|
2023-05-03 08:48:49 +03:00
|
|
|
app_def = self.appmgr.get(app_name)
|
2023-02-07 19:33:05 +03:00
|
|
|
# Skip app if its target is not supported by the target we are building for
|
|
|
|
if not self._check_if_app_target_supported(app_name):
|
|
|
|
self._writer(
|
|
|
|
f"Skipping {app_name} due to target mismatch (building for {self.hw_target}, app supports {app_def.targets}"
|
|
|
|
)
|
|
|
|
return []
|
|
|
|
|
|
|
|
return list(
|
|
|
|
filter(
|
|
|
|
self._check_if_app_target_supported,
|
|
|
|
filter(self._is_missing_dep, app_def.provides + app_def.requires),
|
|
|
|
)
|
|
|
|
)
|
2022-11-10 14:55:11 +03:00
|
|
|
|
2022-06-26 15:00:03 +03:00
|
|
|
def _process_deps(self):
|
|
|
|
while True:
|
|
|
|
provided = []
|
2023-02-07 19:33:05 +03:00
|
|
|
for app_name in self.appnames:
|
|
|
|
provided.extend(self._get_app_depends(app_name))
|
|
|
|
|
|
|
|
# print("provides round: ", provided)
|
2022-06-26 15:00:03 +03:00
|
|
|
if len(provided) == 0:
|
|
|
|
break
|
|
|
|
self.appnames.update(provided)
|
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
def _process_ext_apps(self):
|
|
|
|
extapps = [
|
|
|
|
app
|
2023-11-02 16:28:39 +03:00
|
|
|
for (apptype, global_lookup) in self.EXTERNAL_APP_TYPES_MAP.items()
|
|
|
|
for app in self.get_apps_of_type(apptype, global_lookup)
|
2023-09-05 14:49:39 +03:00
|
|
|
]
|
|
|
|
extapps.extend(map(self.appmgr.get, self._extra_ext_appnames))
|
|
|
|
|
|
|
|
for app in extapps:
|
|
|
|
(
|
|
|
|
self.extapps
|
|
|
|
if app.supports_hardware_target(self.hw_target)
|
|
|
|
else self.incompatible_extapps
|
|
|
|
).append(app)
|
|
|
|
|
|
|
|
def get_ext_apps(self):
|
|
|
|
return self.extapps
|
|
|
|
|
|
|
|
def get_incompatible_ext_apps(self):
|
|
|
|
return self.incompatible_extapps
|
|
|
|
|
2022-06-26 15:00:03 +03:00
|
|
|
def _check_conflicts(self):
|
|
|
|
conflicts = []
|
|
|
|
for app in self.appnames:
|
|
|
|
if conflict_app_name := list(
|
|
|
|
filter(
|
|
|
|
lambda dep_name: dep_name in self.appnames,
|
|
|
|
self.appmgr.get(app).conflicts,
|
|
|
|
)
|
|
|
|
):
|
|
|
|
conflicts.append((app, conflict_app_name))
|
|
|
|
|
|
|
|
if len(conflicts):
|
|
|
|
raise AppBuilderException(
|
|
|
|
f"App conflicts for {', '.join(f'{conflict_dep[0]}: {conflict_dep[1]}' for conflict_dep in conflicts)}"
|
|
|
|
)
|
|
|
|
|
|
|
|
def _check_unsatisfied(self):
|
|
|
|
unsatisfied = []
|
|
|
|
for app in self.appnames:
|
|
|
|
if missing_dep := list(
|
|
|
|
filter(self._is_missing_dep, self.appmgr.get(app).requires)
|
|
|
|
):
|
|
|
|
unsatisfied.append((app, missing_dep))
|
|
|
|
|
|
|
|
if len(unsatisfied):
|
|
|
|
raise AppBuilderException(
|
|
|
|
f"Unsatisfied dependencies for {', '.join(f'{missing_dep[0]}: {missing_dep[1]}' for missing_dep in unsatisfied)}"
|
|
|
|
)
|
|
|
|
|
2023-02-07 19:33:05 +03:00
|
|
|
def _check_target_match(self):
|
|
|
|
incompatible = []
|
|
|
|
for app in self.appnames:
|
|
|
|
if not self.appmgr.get(app).supports_hardware_target(self.hw_target):
|
|
|
|
incompatible.append(app)
|
|
|
|
|
|
|
|
if len(incompatible):
|
|
|
|
raise AppBuilderException(
|
|
|
|
f"Apps incompatible with target {self.hw_target}: {', '.join(incompatible)}"
|
|
|
|
)
|
|
|
|
|
2023-03-14 17:29:28 +03:00
|
|
|
def _group_plugins(self):
|
|
|
|
known_extensions = self.get_apps_of_type(FlipperAppType.PLUGIN, all_known=True)
|
|
|
|
for extension_app in known_extensions:
|
|
|
|
for parent_app_id in extension_app.requires:
|
|
|
|
try:
|
|
|
|
parent_app = self.appmgr.get(parent_app_id)
|
|
|
|
parent_app._plugins.append(extension_app)
|
2023-05-03 08:48:49 +03:00
|
|
|
except FlipperManifestException:
|
2023-03-14 17:29:28 +03:00
|
|
|
self._writer(
|
|
|
|
f"Module {extension_app.appid} has unknown parent {parent_app_id}"
|
|
|
|
)
|
|
|
|
|
2022-06-26 15:00:03 +03:00
|
|
|
def get_apps_cdefs(self):
|
|
|
|
cdefs = set()
|
2023-10-30 18:17:30 +03:00
|
|
|
for app in self._apps:
|
2022-06-26 15:00:03 +03:00
|
|
|
cdefs.update(app.cdefines)
|
|
|
|
return sorted(list(cdefs))
|
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
def get_sdk_headers(self):
|
|
|
|
sdk_headers = []
|
2023-10-30 18:17:30 +03:00
|
|
|
for app in self._apps:
|
2023-07-17 10:51:15 +03:00
|
|
|
sdk_headers.extend(
|
|
|
|
[
|
|
|
|
src._appdir.File(header)
|
2023-07-18 12:39:30 +03:00
|
|
|
for src in [app, *app._plugins]
|
2023-07-17 10:51:15 +03:00
|
|
|
for header in src.sdk_headers
|
|
|
|
]
|
|
|
|
)
|
2022-09-14 19:11:38 +03:00
|
|
|
return sdk_headers
|
|
|
|
|
|
|
|
def get_apps_of_type(self, apptype: FlipperAppType, all_known: bool = False):
|
2023-11-02 16:28:39 +03:00
|
|
|
"""Looks up apps of given type in current app set. If all_known is true,
|
|
|
|
ignores app set and checks all loaded apps' manifests."""
|
2022-06-26 15:00:03 +03:00
|
|
|
return sorted(
|
2022-09-14 19:11:38 +03:00
|
|
|
filter(
|
|
|
|
lambda app: app.apptype == apptype,
|
2023-11-02 16:28:39 +03:00
|
|
|
self.appmgr.known_apps.values()
|
|
|
|
if all_known
|
|
|
|
else map(self.appmgr.get, self.appnames),
|
2022-09-14 19:11:38 +03:00
|
|
|
),
|
2022-06-26 15:00:03 +03:00
|
|
|
key=lambda app: app.order,
|
|
|
|
)
|
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
def get_builtin_apps(self):
|
|
|
|
return list(
|
2023-10-30 18:17:30 +03:00
|
|
|
filter(lambda app: app.apptype in self.BUILTIN_APP_TYPES, self._apps)
|
2022-09-14 19:11:38 +03:00
|
|
|
)
|
|
|
|
|
2022-06-26 15:00:03 +03:00
|
|
|
def get_builtin_app_folders(self):
|
|
|
|
return sorted(
|
|
|
|
set(
|
2022-09-14 19:11:38 +03:00
|
|
|
(app._appdir, source_type)
|
|
|
|
for app in self.get_builtin_apps()
|
|
|
|
for source_type in app.sources
|
2022-06-26 15:00:03 +03:00
|
|
|
)
|
|
|
|
)
|