assets: checking limits on image size; ufbt: cdb target (#3359)

* scripts: assets: checking limits on image size
* ufbt: added "cdb" target for regenerating; also generating cdb on "vscode_dist"
* fbt: now also creating cdb for vscode_dist

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
hedger 2024-01-12 11:58:37 +03:00 committed by GitHub
parent d289545bf8
commit 0789cbdefa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 8 deletions

View File

@ -369,7 +369,7 @@ vscode_dist = distenv.Install(
) )
distenv.Precious(vscode_dist) distenv.Precious(vscode_dist)
distenv.NoClean(vscode_dist) distenv.NoClean(vscode_dist)
distenv.Alias("vscode_dist", vscode_dist) distenv.Alias("vscode_dist", (vscode_dist, firmware_env["FW_CDB"]))
# Configure shell with build tools # Configure shell with build tools
distenv.PhonyTarget( distenv.PhonyTarget(

View File

@ -249,7 +249,7 @@ fw_artifacts.extend(
) )
fwcdb = fwenv.CompilationDatabase() fwcdb = fwenv["FW_CDB"] = fwenv.CompilationDatabase()
# without filtering, both updater & firmware commands would be generated in same file # without filtering, both updater & firmware commands would be generated in same file
fwenv.Replace( fwenv.Replace(
COMPILATIONDB_PATH_FILTER=fwenv.subst("*${FW_FLAVOR}*"), COMPILATIONDB_PATH_FILTER=fwenv.subst("*${FW_FLAVOR}*"),

View File

@ -24,6 +24,9 @@ ICONS_TEMPLATE_C_FRAME = "const uint8_t {name}[] = {data};\n"
ICONS_TEMPLATE_C_DATA = "const uint8_t* const {name}[] = {data};\n" ICONS_TEMPLATE_C_DATA = "const uint8_t* const {name}[] = {data};\n"
ICONS_TEMPLATE_C_ICONS = "const Icon {name} = {{.width={width},.height={height},.frame_count={frame_count},.frame_rate={frame_rate},.frames=_{name}}};\n" ICONS_TEMPLATE_C_ICONS = "const Icon {name} = {{.width={width},.height={height},.frame_count={frame_count},.frame_rate={frame_rate},.frames=_{name}}};\n"
MAX_IMAGE_WIDTH = 128
MAX_IMAGE_HEIGHT = 64
class Main(App): class Main(App):
def init(self): def init(self):
@ -102,6 +105,10 @@ class Main(App):
def _icon2header(self, file): def _icon2header(self, file):
image = file2image(file) image = file2image(file)
if image.width > MAX_IMAGE_WIDTH or image.height > MAX_IMAGE_HEIGHT:
raise Exception(
f"Image {file} is too big ({image.width}x{image.height} vs. {MAX_IMAGE_WIDTH}x{MAX_IMAGE_HEIGHT})"
)
return image.width, image.height, image.data_as_carray() return image.width, image.height, image.data_as_carray()
def _iconIsSupported(self, filename): def _iconIsSupported(self, filename):

View File

@ -275,15 +275,16 @@ Default(install_and_check)
# Compilation database # Compilation database
fwcdb = appenv.CompilationDatabase( app_cdb = appenv.CompilationDatabase(
original_app_dir.Dir(".vscode").File("compile_commands.json") original_app_dir.Dir(".vscode").File("compile_commands.json")
) )
AlwaysBuild(fwcdb) AlwaysBuild(app_cdb)
Precious(fwcdb) Precious(app_cdb)
NoClean(fwcdb) NoClean(app_cdb)
if len(apps_artifacts): if len(apps_artifacts):
Default(fwcdb) Default(app_cdb)
Alias("cdb", app_cdb)
# launch handler # launch handler
@ -381,7 +382,7 @@ for config_file in project_template_dir.glob(".*"):
dist_env.Precious(vscode_dist) dist_env.Precious(vscode_dist)
dist_env.NoClean(vscode_dist) dist_env.NoClean(vscode_dist)
dist_env.Alias("vscode_dist", vscode_dist) dist_env.Alias("vscode_dist", (vscode_dist, app_cdb))
# Creating app from base template # Creating app from base template

View File

@ -18,6 +18,8 @@ Building:
Build all FAP apps Build all FAP apps
fap_{APPID}, launch APPSRC={APPID}: fap_{APPID}, launch APPSRC={APPID}:
Build FAP app with appid={APPID}; upload & start it over USB Build FAP app with appid={APPID}; upload & start it over USB
cdb:
regenerate "compile_commands.json" file (for IDE integration)
Flashing & debugging: Flashing & debugging:
flash, *jflash: flash, *jflash: