Skip to content

Commit

Permalink
assets: checking limits on image size; ufbt: cdb target (#3359)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
hedger and skotopes authored Jan 12, 2024
1 parent d289545 commit 0789cbd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ vscode_dist = distenv.Install(
)
distenv.Precious(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
distenv.PhonyTarget(
Expand Down
2 changes: 1 addition & 1 deletion firmware.scons
Original file line number Diff line number Diff line change
Expand Up @@ -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
fwenv.Replace(
COMPILATIONDB_PATH_FILTER=fwenv.subst("*${FW_FLAVOR}*"),
Expand Down
7 changes: 7 additions & 0 deletions scripts/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
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"

MAX_IMAGE_WIDTH = 128
MAX_IMAGE_HEIGHT = 64


class Main(App):
def init(self):
Expand Down Expand Up @@ -102,6 +105,10 @@ def init(self):

def _icon2header(self, 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()

def _iconIsSupported(self, filename):
Expand Down
13 changes: 7 additions & 6 deletions scripts/ufbt/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,16 @@ Default(install_and_check)

# Compilation database

fwcdb = appenv.CompilationDatabase(
app_cdb = appenv.CompilationDatabase(
original_app_dir.Dir(".vscode").File("compile_commands.json")
)

AlwaysBuild(fwcdb)
Precious(fwcdb)
NoClean(fwcdb)
AlwaysBuild(app_cdb)
Precious(app_cdb)
NoClean(app_cdb)
if len(apps_artifacts):
Default(fwcdb)
Default(app_cdb)
Alias("cdb", app_cdb)


# launch handler
Expand Down Expand Up @@ -381,7 +382,7 @@ for config_file in project_template_dir.glob(".*"):

dist_env.Precious(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
Expand Down
2 changes: 2 additions & 0 deletions scripts/ufbt/site_tools/ufbt_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
Build all FAP apps
fap_{APPID}, launch APPSRC={APPID}:
Build FAP app with appid={APPID}; upload & start it over USB
cdb:
regenerate "compile_commands.json" file (for IDE integration)
Flashing & debugging:
flash, *jflash:
Expand Down

0 comments on commit 0789cbd

Please sign in to comment.