Skip to content

Commit

Permalink
fbt: moved SD card resources to owning apps
Browse files Browse the repository at this point in the history
  • Loading branch information
hedger committed Oct 19, 2023
1 parent e6a5fd9 commit 7e2e0a6
Show file tree
Hide file tree
Showing 54 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions applications/main/bad_usb/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ App(
stack_size=2 * 1024,
icon="A_BadUsb_14",
order=70,
resources="resources",
fap_libs=["assets"],
fap_icon="icon.png",
fap_category="USB",
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions applications/main/infrared/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ App(
icon="A_Infrared_14",
stack_size=3 * 1024,
order=40,
resources="resources",
fap_libs=["assets"],
fap_icon="icon.png",
fap_category="Infrared",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions applications/main/nfc/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ App(
icon="A_NFC_14",
stack_size=5 * 1024,
order=30,
resources="resources",
fap_libs=["assets"],
fap_icon="icon.png",
fap_category="NFC",
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions applications/main/subghz/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ App(
icon="A_Sub1ghz_14",
stack_size=3 * 1024,
order=10,
resources="resources",
fap_libs=["assets", "hwdrivers"],
fap_icon="icon.png",
fap_category="Sub-GHz",
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions applications/main/u2f/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ App(
stack_size=2 * 1024,
icon="A_U2F_14",
order=80,
resources="resources",
fap_libs=["assets"],
fap_category="USB",
fap_icon="icon.png",
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions assets/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ assetsenv = env.Clone(
tools=["fbt_assets"],
FW_LIB_NAME="assets",
GIT_UNIX_TIMESTAMP=get_git_commit_unix_timestamp(),
RESOURCES_STATIC_ROOT=env.Dir("#/assets/resources"),
)
assetsenv.ApplyLibFlags()

Expand Down Expand Up @@ -102,7 +101,6 @@ if assetsenv["IS_BASE_FIRMWARE"]:
"manifest",
"${TARGET.dir.posix}",
"--timestamp=${GIT_UNIX_TIMESTAMP}",
"--static-dir=${RESOURCES_STATIC_ROOT}",
]
],
"${RESMANIFESTCOMSTR}",
Expand Down
10 changes: 0 additions & 10 deletions scripts/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ def init(self):
type=int,
required=False,
)
self.parser_manifest.add_argument(
"--static-dir",
help="Static files to add to resources",
required=True,
)
self.parser_manifest.set_defaults(func=self.manifest)

self.parser_copro = self.subparsers.add_parser(
Expand Down Expand Up @@ -227,11 +222,6 @@ def manifest(self):
self.logger.error(f'"{directory_path}" is not a directory')
exit(255)

shutil.copytree(
self.args.static_dir,
directory_path,
dirs_exist_ok=True,
)
manifest_file = os.path.join(directory_path, "Manifest")
old_manifest = Manifest()
if os.path.exists(manifest_file):
Expand Down
15 changes: 10 additions & 5 deletions scripts/fbt/appmanifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Library:
order: int = 0
sdk_headers: List[str] = field(default_factory=list)
targets: List[str] = field(default_factory=lambda: ["all"])
resources: Optional[str] = None

# .fap-specific
sources: List[str] = field(default_factory=lambda: ["*.c*"])
Expand Down Expand Up @@ -268,11 +269,15 @@ def __init__(
self._check_unsatisfied() # unneeded?
self._check_target_match()
self._group_plugins()
self.apps = sorted(
self._apps = sorted(
list(map(self.appmgr.get, self.appnames)),
key=lambda app: app.appid,
)

@property
def apps(self):
return list(self._apps)

def _is_missing_dep(self, dep_name: str):
return dep_name not in self.appnames

Expand Down Expand Up @@ -381,13 +386,13 @@ def _group_plugins(self):

def get_apps_cdefs(self):
cdefs = set()
for app in self.apps:
for app in self._apps:
cdefs.update(app.cdefines)
return sorted(list(cdefs))

def get_sdk_headers(self):
sdk_headers = []
for app in self.apps:
for app in self._apps:
sdk_headers.extend(
[
src._appdir.File(header)
Expand All @@ -401,14 +406,14 @@ def get_apps_of_type(self, apptype: FlipperAppType, all_known: bool = False):
return sorted(
filter(
lambda app: app.apptype == apptype,
self.appmgr.known_apps.values() if all_known else self.apps,
self.appmgr.known_apps.values() if all_known else self._apps,
),
key=lambda app: app.order,
)

def get_builtin_apps(self):
return list(
filter(lambda app: app.apptype in self.BUILTIN_APP_TYPES, self.apps)
filter(lambda app: app.apptype in self.BUILTIN_APP_TYPES, self._apps)
)

def get_builtin_app_folders(self):
Expand Down
11 changes: 11 additions & 0 deletions scripts/fbt_tools/fbt_extapps.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,17 @@ def resources_fap_dist_emitter(target, source, env):
source.append(app_artifacts.compact)
target.append(resources_root.File(dist_path))

# Deploy apps' resources too
for app in env["APPBUILD"].apps:
if not app.resources:
continue
apps_resource_dir = app._appdir.Dir(app.resources)
for res_file in env.GlobRecursive("*", apps_resource_dir):
if not isinstance(res_file, File):
continue
source.append(res_file)
target.append(resources_root.File(res_file.get_path(apps_resource_dir)))

assert len(target) == len(source)
return (target, source)

Expand Down

0 comments on commit 7e2e0a6

Please sign in to comment.