[FL-2859,2838] fbt: improvements for FAPs (#1813)
* fbt: assets builder for apps WIP * fbt: automatically building private fap assets * docs: details on how to use image assets * fbt: renamed fap_assets -> fap_icons * fbt: support for fap_extbuild field * docs: info on fap_extbuild * fbt: added --proxy-env parame ter * fbt: made firmware_cdb & updater_cdb targets always available * fbt: renamed fap_icons -> fap_icon_assets * fbt: deprecated firmware_* target names for faps; new alias is "fap_APPID" * fbt: changed intermediate file locations for external apps * fbt: support for fap_private_libs; docs: updates * restored mbedtls as global lib * scripts: lint.py: skip "lib" subfolder * fbt: Sanity checks for building advanced faps as part of fw * docs: info on fap_private_libs; fbt: optimized *.fam indexing * fbt: cleanup; samples: added sample_icons app * fbt: moved example app to applications/examples * linter fix * docs: readme fixes * added applications/examples/application.fam stub * docs: more info on private libs Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@ ICONS_TEMPLATE_H_HEADER = """#pragma once
|
||||
"""
|
||||
ICONS_TEMPLATE_H_ICON_NAME = "extern const Icon {name};\n"
|
||||
|
||||
ICONS_TEMPLATE_C_HEADER = """#include \"assets_icons.h\"
|
||||
ICONS_TEMPLATE_C_HEADER = """#include "{assets_filename}.h"
|
||||
|
||||
#include <gui/icon_i.h>
|
||||
|
||||
@@ -33,6 +33,13 @@ class Main(App):
|
||||
)
|
||||
self.parser_icons.add_argument("input_directory", help="Source directory")
|
||||
self.parser_icons.add_argument("output_directory", help="Output directory")
|
||||
self.parser_icons.add_argument(
|
||||
"--filename",
|
||||
help="Base filename for file with icon data",
|
||||
required=False,
|
||||
default="assets_icons",
|
||||
)
|
||||
|
||||
self.parser_icons.set_defaults(func=self.icons)
|
||||
|
||||
self.parser_manifest = self.subparsers.add_parser(
|
||||
@@ -102,13 +109,15 @@ class Main(App):
|
||||
return extension in ICONS_SUPPORTED_FORMATS
|
||||
|
||||
def icons(self):
|
||||
self.logger.debug(f"Converting icons")
|
||||
self.logger.debug("Converting icons")
|
||||
icons_c = open(
|
||||
os.path.join(self.args.output_directory, "assets_icons.c"),
|
||||
os.path.join(self.args.output_directory, f"{self.args.filename}.c"),
|
||||
"w",
|
||||
newline="\n",
|
||||
)
|
||||
icons_c.write(ICONS_TEMPLATE_C_HEADER)
|
||||
icons_c.write(
|
||||
ICONS_TEMPLATE_C_HEADER.format(assets_filename=self.args.filename)
|
||||
)
|
||||
icons = []
|
||||
# Traverse icons tree, append image data to source file
|
||||
for dirpath, dirnames, filenames in os.walk(self.args.input_directory):
|
||||
@@ -194,7 +203,7 @@ class Main(App):
|
||||
# Create Public Header
|
||||
self.logger.debug(f"Creating header")
|
||||
icons_h = open(
|
||||
os.path.join(self.args.output_directory, "assets_icons.h"),
|
||||
os.path.join(self.args.output_directory, f"{self.args.filename}.h"),
|
||||
"w",
|
||||
newline="\n",
|
||||
)
|
||||
|
@@ -54,6 +54,10 @@ class Main(App):
|
||||
output = []
|
||||
for folder in folders:
|
||||
for dirpath, dirnames, filenames in os.walk(folder):
|
||||
# Skipping 3rd-party code - usually resides in subfolder "lib"
|
||||
if "lib" in dirnames:
|
||||
dirnames.remove("lib")
|
||||
|
||||
for filename in filenames:
|
||||
ext = os.path.splitext(filename.lower())[1]
|
||||
if not ext in SOURCE_CODE_FILE_EXTENSIONS:
|
||||
|
Reference in New Issue
Block a user