From 644d2427b3ebfc77f6e18f3acec64821cae47ce2 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:35:09 +0100 Subject: [PATCH 01/16] Unused icons to check later --- scripts/check_unused_icons.py | 31 +++++++++++++++++++++++++++++++ targets/f7/api_symbols.csv | 20 ++++++++++---------- 2 files changed, 41 insertions(+), 10 deletions(-) create mode 100755 scripts/check_unused_icons.py diff --git a/scripts/check_unused_icons.py b/scripts/check_unused_icons.py new file mode 100755 index 000000000..3a97a4f91 --- /dev/null +++ b/scripts/check_unused_icons.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +import pathlib + +root = pathlib.Path(__file__).parent / ".." +icons = root / "assets/icons" + +def source_dir_uses_icon(dir: str, name: str): + count = 0 + name = name.encode() + for file in (root / dir).glob("**/*.c"): + try: + if name in file.read_bytes(): + count += 1 + except Exception: + print(f"Faield to read {file}") + return count + +for category in icons.iterdir(): + if not category.is_dir(): + continue + for icon in category.iterdir(): + if icon.is_dir() and (icon / "frame_rate").is_file(): + name = "&A_" + icon.name.replace("-", "_") + else: + name = "&I_" + "_".join(icon.name.split(".")[:-1]).replace("-", "_") + count = 0 + for dir in ("applications", "furi", "lib", "targets"): + count += source_dir_uses_icon(dir, name) + print(f"{name} used {count} times") + if count == 0: + print(f"====== {name} is not used! ======") diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index af8ab3f60..9f1829367 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -3990,11 +3990,11 @@ Variable,+,I_Percent_10x14,const Icon, Variable,+,I_Pin_arrow_up_7x9,const Icon, Variable,+,I_Pin_attention_dpad_29x29,const Icon, Variable,+,I_Pin_back_arrow_10x8,const Icon, -Variable,+,I_Pin_cell_13x13,const Icon, +Variable,-,I_Pin_cell_13x13,const Icon, Variable,+,I_Pin_pointer_5x3,const Icon, Variable,+,I_Pin_star_7x7,const Icon, -Variable,+,I_Play_25x27,const Icon, -Variable,+,I_Play_hvr_25x27,const Icon, +Variable,-,I_Play_25x27,const Icon, +Variable,-,I_Play_hvr_25x27,const Icon, Variable,+,I_Pressed_Button_13x13,const Icon, Variable,+,I_Quest_7x8,const Icon, Variable,+,I_RFIDDolphinReceive_97x61,const Icon, @@ -4077,13 +4077,13 @@ Variable,+,I_floppydisk_10px,const Icon, Variable,+,I_green_19x20,const Icon, Variable,+,I_green_hover_19x20,const Icon, Variable,+,I_heat_30x51,const Icon, -Variable,+,I_hourglass0_24x24,const Icon, -Variable,+,I_hourglass1_24x24,const Icon, -Variable,+,I_hourglass2_24x24,const Icon, -Variable,+,I_hourglass3_24x24,const Icon, -Variable,+,I_hourglass4_24x24,const Icon, -Variable,+,I_hourglass5_24x24,const Icon, -Variable,+,I_hourglass6_24x24,const Icon, +Variable,-,I_hourglass0_24x24,const Icon, +Variable,-,I_hourglass1_24x24,const Icon, +Variable,-,I_hourglass2_24x24,const Icon, +Variable,-,I_hourglass3_24x24,const Icon, +Variable,-,I_hourglass4_24x24,const Icon, +Variable,-,I_hourglass5_24x24,const Icon, +Variable,-,I_hourglass6_24x24,const Icon, Variable,+,I_iButtonDolphinVerySuccess_92x55,const Icon, Variable,+,I_iButtonKey_49x44,const Icon, Variable,+,I_ibutt_10px,const Icon, From 541ddaa2b8433f91d96b9ef168da9760c4222144 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:35:41 +0100 Subject: [PATCH 02/16] Exclude disabled icons from firmware --- scripts/assets.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/assets.py b/scripts/assets.py index ce4df3bf5..557d913df 100755 --- a/scripts/assets.py +++ b/scripts/assets.py @@ -154,7 +154,8 @@ def icons(self): if "frame_rate" in filenames: self.logger.debug("Folder contains animation") icon_name = "A_" + os.path.split(dirpath)[1].replace("-", "_") - if not is_main_assets and api_has_icon(icon_name): + icon_in_api = api_has_icon(icon_name) + if not is_main_assets and icon_in_api: self.logger.info( f"{self.args.filename}: ignoring duplicate icon {icon_name}" ) @@ -194,7 +195,8 @@ def icons(self): icons_c.write("\n") icons.append((icon_name, width, height, frame_rate, frame_count)) p = dirpath.removeprefix(self.args.input_directory)[1:] - paths.append((icon_name, p.replace("\\", "/"))) + if icon_in_api: + paths.append((icon_name, p.replace("\\", "/"))) else: # process icons for filename in filenames: @@ -204,7 +206,8 @@ def icons(self): icon_name = "I_" + "_".join(filename.split(".")[:-1]).replace( "-", "_" ) - if not is_main_assets and api_has_icon(icon_name): + icon_in_api = api_has_icon(icon_name) + if not is_main_assets and icon_in_api: self.logger.info( f"{self.args.filename}: ignoring duplicate icon {icon_name}" ) @@ -223,7 +226,8 @@ def icons(self): icons_c.write("\n") icons.append((icon_name, width, height, 0, 1)) p = fullfilename.removeprefix(self.args.input_directory)[1:] - paths.append((icon_name, p.replace("\\", "/").rsplit(".", 1)[0])) + if icon_in_api: + paths.append((icon_name, p.replace("\\", "/").rsplit(".", 1)[0])) # Create array of images: self.logger.debug("Finalizing source file") for name, width, height, frame_rate, frame_count in icons: From 0de6e2086bbc01976bdfe65e6a16a761451a387e Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Mon, 4 Nov 2024 07:21:07 +0000 Subject: [PATCH 03/16] Format --- scripts/assets.py | 4 +++- scripts/check_unused_icons.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/assets.py b/scripts/assets.py index 557d913df..8778671db 100755 --- a/scripts/assets.py +++ b/scripts/assets.py @@ -227,7 +227,9 @@ def icons(self): icons.append((icon_name, width, height, 0, 1)) p = fullfilename.removeprefix(self.args.input_directory)[1:] if icon_in_api: - paths.append((icon_name, p.replace("\\", "/").rsplit(".", 1)[0])) + paths.append( + (icon_name, p.replace("\\", "/").rsplit(".", 1)[0]) + ) # Create array of images: self.logger.debug("Finalizing source file") for name, width, height, frame_rate, frame_count in icons: diff --git a/scripts/check_unused_icons.py b/scripts/check_unused_icons.py index 3a97a4f91..22d81f77b 100755 --- a/scripts/check_unused_icons.py +++ b/scripts/check_unused_icons.py @@ -4,6 +4,7 @@ root = pathlib.Path(__file__).parent / ".." icons = root / "assets/icons" + def source_dir_uses_icon(dir: str, name: str): count = 0 name = name.encode() @@ -15,6 +16,7 @@ def source_dir_uses_icon(dir: str, name: str): print(f"Faield to read {file}") return count + for category in icons.iterdir(): if not category.is_dir(): continue From 85983a4b399813b8dbb735551ec232c8bb34f6fa Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 01:26:44 +0000 Subject: [PATCH 04/16] Also report free flash in gh comment --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d221e9524..a4afa1f62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -128,10 +128,14 @@ jobs: dfu_size_new=$(du --apparent-size -B 1 artifacts/flipper-z-${TARGET}-full-*.dfu | cut -f1) dfu_size_dev=$(du --apparent-size -B 1 dev.dfu | cut -f1) dfu_size_diff=$((dfu_size_new - dfu_size_dev)) + dfu_free_hex=$(grep free_flash -m 1 build/latest/firmware.elf.map | rev | cut -d' ' -f1 | rev) + dfu_free_min=$((2 * 4 * 1024)) DFU_SIZE=$(echo ${dfu_size_new}B | sed -r 's/^([0-9]+)([0-9]{2})([0-9])B/\1.\2K/') DFU_DIFF=$(echo ${dfu_size_diff}B | sed -r 's/^(-?[0-9]+)([0-9]{2})([0-9])B/\1.\2K/' | sed -r 's/^([^-])/+\1/') + DFU_FREE=$(echo $((dfu_free_hex - dfu_free_min))B | sed -r 's/^(-?[0-9]+)([0-9]{2})([0-9])B/\1.\2K/' | sed -r 's/^([^-])/+\1/') echo "DFU_SIZE=$DFU_SIZE" >> $GITHUB_ENV echo "DFU_DIFF=$DFU_DIFF" >> $GITHUB_ENV + echo "DFU_FREE=$DFU_FREE" >> $GITHUB_ENV - name: "Upload artifacts to update server" env: @@ -169,7 +173,7 @@ jobs: **Compiled ${{ matrix.target }} firmware for commit `${{steps.names.outputs.commit_sha}}`:** - [☁️ Flipper Lab/App](https://lab.flipper.net/?url=${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=mntm-${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}}) - [📦 qFlipper Package](${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz) - - DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev) + - DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev), `${{ env.DFU_FREE }}` free flash edit-mode: replace - name: Send devbuild webhook From 89b792ccf48540fe336f2ac8e3e684e7ca522392 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 02:23:51 +0000 Subject: [PATCH 05/16] Fix free flash calc --- .github/workflows/build.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a4afa1f62..31de7344a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -128,14 +128,21 @@ jobs: dfu_size_new=$(du --apparent-size -B 1 artifacts/flipper-z-${TARGET}-full-*.dfu | cut -f1) dfu_size_dev=$(du --apparent-size -B 1 dev.dfu | cut -f1) dfu_size_diff=$((dfu_size_new - dfu_size_dev)) - dfu_free_hex=$(grep free_flash -m 1 build/latest/firmware.elf.map | rev | cut -d' ' -f1 | rev) - dfu_free_min=$((2 * 4 * 1024)) - DFU_SIZE=$(echo ${dfu_size_new}B | sed -r 's/^([0-9]+)([0-9]{2})([0-9])B/\1.\2K/') - DFU_DIFF=$(echo ${dfu_size_diff}B | sed -r 's/^(-?[0-9]+)([0-9]{2})([0-9])B/\1.\2K/' | sed -r 's/^([^-])/+\1/') - DFU_FREE=$(echo $((dfu_free_hex - dfu_free_min))B | sed -r 's/^(-?[0-9]+)([0-9]{2})([0-9])B/\1.\2K/' | sed -r 's/^([^-])/+\1/') + DFU_SIZE=$(echo $dfu_size_new | numfmt --to=iec --format=%.2f) + DFU_DIFF=$(echo $dfu_size_diff | numfmt --to=iec --format=%.2f | sed -r 's/^([^-])/+\1/') echo "DFU_SIZE=$DFU_SIZE" >> $GITHUB_ENV echo "DFU_DIFF=$DFU_DIFF" >> $GITHUB_ENV - echo "DFU_FREE=$DFU_FREE" >> $GITHUB_ENV + + tar xzf build/core2_firmware.tgz + radio_addr=$(jq -r '.copro.radio.files.[0].address' core2_firmware/Manifest.json) + flash_base=0x8000000 + min_gap=$((2 * 4 * 1024)) + flash_free_total=$((radio_addr - flash_base - dfu_size_new)) + flash_free_usable$((flash_free_total - min_gap)) + FLASH_FREE=$(echo $flash_free_total | numfmt --to=iec --format=%.2f) + FLASH_USABLE=$(echo $flash_free_usable | numfmt --to=iec --format=%.2f) + echo "FLASH_FREE=$FLASH_FREE" >> $GITHUB_ENV + echo "FLASH_USABLE=$FLASH_USABLE" >> $GITHUB_ENV - name: "Upload artifacts to update server" env: @@ -173,7 +180,7 @@ jobs: **Compiled ${{ matrix.target }} firmware for commit `${{steps.names.outputs.commit_sha}}`:** - [☁️ Flipper Lab/App](https://lab.flipper.net/?url=${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=mntm-${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}}) - [📦 qFlipper Package](${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz) - - DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev), `${{ env.DFU_FREE }}` free flash + - DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev), `${{ env.FLASH_FREE }}` free flash (`${{ env.FLASH_USABLE }}` usable) edit-mode: replace - name: Send devbuild webhook From 7028c12051f7c726ff69ec33368f65f71d8a5cf9 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 02:37:32 +0000 Subject: [PATCH 06/16] Fix? --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31de7344a..677d278f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -134,7 +134,7 @@ jobs: echo "DFU_DIFF=$DFU_DIFF" >> $GITHUB_ENV tar xzf build/core2_firmware.tgz - radio_addr=$(jq -r '.copro.radio.files.[0].address' core2_firmware/Manifest.json) + radio_addr=$(jq -r '.copro.radio.files[0].address' core2_firmware/Manifest.json) flash_base=0x8000000 min_gap=$((2 * 4 * 1024)) flash_free_total=$((radio_addr - flash_base - dfu_size_new)) From 62cb8ab3690a37298adabaf3368aa6e0843b457d Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 02:48:41 +0000 Subject: [PATCH 07/16] Fix?? --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 677d278f4..c3881e6bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -138,7 +138,7 @@ jobs: flash_base=0x8000000 min_gap=$((2 * 4 * 1024)) flash_free_total=$((radio_addr - flash_base - dfu_size_new)) - flash_free_usable$((flash_free_total - min_gap)) + flash_free_usable=$((flash_free_total - min_gap)) FLASH_FREE=$(echo $flash_free_total | numfmt --to=iec --format=%.2f) FLASH_USABLE=$(echo $flash_free_usable | numfmt --to=iec --format=%.2f) echo "FLASH_FREE=$FLASH_FREE" >> $GITHUB_ENV From e458955e6cec12a53f3566ca99cee9f0a0768dc6 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 03:22:06 +0000 Subject: [PATCH 08/16] Split to next line --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3881e6bb..fcad25108 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -180,7 +180,8 @@ jobs: **Compiled ${{ matrix.target }} firmware for commit `${{steps.names.outputs.commit_sha}}`:** - [☁️ Flipper Lab/App](https://lab.flipper.net/?url=${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=mntm-${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}}) - [📦 qFlipper Package](${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz) - - DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev), `${{ env.FLASH_FREE }}` free flash (`${{ env.FLASH_USABLE }}` usable) + - DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev) + - Free Flash: `${{ env.FLASH_FREE }}` (`${{ env.FLASH_USABLE }}` usable) edit-mode: replace - name: Send devbuild webhook From 428cd2ae48956be6041f176545f161d08685cde3 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 03:24:49 +0000 Subject: [PATCH 09/16] Remove dead icons --- assets/icons/Infrared/Play_25x27.png | Bin 137 -> 0 bytes assets/icons/Infrared/Play_hvr_25x27.png | Bin 128 -> 0 bytes assets/icons/Infrared/hourglass0_24x24.png | Bin 138 -> 0 bytes assets/icons/Infrared/hourglass1_24x24.png | Bin 143 -> 0 bytes assets/icons/Infrared/hourglass2_24x24.png | Bin 137 -> 0 bytes assets/icons/Infrared/hourglass3_24x24.png | Bin 136 -> 0 bytes assets/icons/Infrared/hourglass4_24x24.png | Bin 144 -> 0 bytes assets/icons/Infrared/hourglass5_24x24.png | Bin 136 -> 0 bytes assets/icons/Infrared/hourglass6_24x24.png | Bin 145 -> 0 bytes assets/icons/PIN/Pin_cell_13x13.png | Bin 79 -> 0 bytes targets/f7/api_symbols.csv | 10 ---------- 11 files changed, 10 deletions(-) delete mode 100644 assets/icons/Infrared/Play_25x27.png delete mode 100644 assets/icons/Infrared/Play_hvr_25x27.png delete mode 100644 assets/icons/Infrared/hourglass0_24x24.png delete mode 100644 assets/icons/Infrared/hourglass1_24x24.png delete mode 100644 assets/icons/Infrared/hourglass2_24x24.png delete mode 100644 assets/icons/Infrared/hourglass3_24x24.png delete mode 100644 assets/icons/Infrared/hourglass4_24x24.png delete mode 100644 assets/icons/Infrared/hourglass5_24x24.png delete mode 100644 assets/icons/Infrared/hourglass6_24x24.png delete mode 100644 assets/icons/PIN/Pin_cell_13x13.png diff --git a/assets/icons/Infrared/Play_25x27.png b/assets/icons/Infrared/Play_25x27.png deleted file mode 100644 index f1064d7b164140b9fc048e77956ad9c8789728f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^l0YoY2qYL5MoAt8QURVWjv*CuSPvfLZ3^QQF_ZuR diff --git a/assets/icons/Infrared/Play_hvr_25x27.png b/assets/icons/Infrared/Play_hvr_25x27.png deleted file mode 100644 index fa234ba172fb30e69115683a9d374e1406387c8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 zcmeAS@N?(olHy`uVBq!ia0vp^l0YoY2qYL5MoAt8QtqBEjv*CuLeFdzY*1i0df|Dw zpnIW-Te67Tf+ZggFi8h5IptbB%_Ml$)5T8Be9Uq)HgLG^NWI>jzopr01!_wxc~qF diff --git a/assets/icons/Infrared/hourglass1_24x24.png b/assets/icons/Infrared/hourglass1_24x24.png deleted file mode 100644 index ef048a7bdab260080ce7c6458fc4c9a3a946a57d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^5+KY7Bp6QcFoXiBFi#i9kcv5~CpQYZ28g&`tX(I4 zxj}NPhOhSij`>21m>cDKIwU{$9q^jY6Jrwj(_>}uMG*%BfiFwybpJ`e=gZn>&1p6% qHE`$i1XYQ^i$|QNe>>=^e3<*0tjyFa!Eb(mZ1QyVb6Mw<&;$UKTroNT diff --git a/assets/icons/Infrared/hourglass2_24x24.png b/assets/icons/Infrared/hourglass2_24x24.png deleted file mode 100644 index 918bd79d869be1a4d5a2c6689cc237033ba408ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^5+KY7Bp6QcFoXiB08bakkcv6FCpHQ?1cFDRxUX)i z(=g?!M9WD9q2LX!E>oGFYBU@=J2`cM;nIVqo{_Pt4fd6+`FutPfBbYUP}1N0>tgfY i+TC2{mN%y!Q#s6R(=72Xy)At&$O=zaKbLh*2~7ZC9xhq{ diff --git a/assets/icons/Infrared/hourglass4_24x24.png b/assets/icons/Infrared/hourglass4_24x24.png deleted file mode 100644 index 7ed58a5b4b0e92001f865ceb21af031bc7d8ea38..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^5+KY7Bp6QcFoXiBa8DPW0o68rx#%5Z6MpZT}^1js5+S3j3^P6TPj=N$AxAsa*?OUm95H&5xM88q Date: Tue, 5 Nov 2024 03:47:08 +0000 Subject: [PATCH 10/16] Some spring cleaning of icons cooker --- scripts/assets.py | 65 ++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/scripts/assets.py b/scripts/assets.py index 8778671db..cc05eb06f 100755 --- a/scripts/assets.py +++ b/scripts/assets.py @@ -11,11 +11,20 @@ ICONS_TEMPLATE_H_HEADER = """#pragma once -#include +#include #include """ ICONS_TEMPLATE_H_ICON_NAME = "extern const Icon {name};\n" +ICONS_TEMPLATE_H_ICON_PATHS = """ +typedef struct { + const Icon* icon; + const char* path; +} IconPath; + +extern const IconPath ICON_PATHS[]; +extern const size_t ICON_PATHS_COUNT; +""" ICONS_TEMPLATE_C_HEADER = """#include "{assets_filename}.h" @@ -25,6 +34,15 @@ ICONS_TEMPLATE_C_FRAME = "const uint8_t {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_ICON_PATH = ' {{&{name}, "{path}"}},\n' +ICONS_TEMPLATE_C_ICON_PATHS = """ +const IconPath ICON_PATHS[] = {{ +#ifndef FURI_RAM_EXEC +{icon_paths} +#endif +}}; +const size_t ICON_PATHS_COUNT = COUNT_OF(ICON_PATHS); +""" MAX_IMAGE_WIDTH = 2**16 - 1 MAX_IMAGE_HEIGHT = 2**16 - 1 @@ -194,9 +212,9 @@ def icons(self): ) icons_c.write("\n") icons.append((icon_name, width, height, frame_rate, frame_count)) - p = dirpath.removeprefix(self.args.input_directory)[1:] - if icon_in_api: - paths.append((icon_name, p.replace("\\", "/"))) + if is_main_assets and icon_in_api: + path = dirpath.removeprefix(self.args.input_directory)[1:] + paths.append((icon_name, path.replace("\\", "/"))) else: # process icons for filename in filenames: @@ -225,10 +243,10 @@ def icons(self): ) icons_c.write("\n") icons.append((icon_name, width, height, 0, 1)) - p = fullfilename.removeprefix(self.args.input_directory)[1:] - if icon_in_api: + if is_main_assets and icon_in_api: + path = fullfilename.removeprefix(self.args.input_directory)[1:] paths.append( - (icon_name, p.replace("\\", "/").rsplit(".", 1)[0]) + (icon_name, path.replace("\\", "/").rsplit(".", 1)[0]) ) # Create array of images: self.logger.debug("Finalizing source file") @@ -242,21 +260,14 @@ def icons(self): frame_count=frame_count, ) ) - if is_main_assets: - icons_c.write( - """ -const IconPath ICON_PATHS[] = { -#ifndef FURI_RAM_EXEC -""" - ) - for name, path in paths: - icons_c.write(f' {{&{name}, "{path}"}},\n') - icons_c.write( - """#endif -}; -const size_t ICON_PATHS_COUNT = COUNT_OF(ICON_PATHS); -""" + if not is_main_assets: + icons_c.write("\n") + else: + icon_paths = "\n".join( + ICONS_TEMPLATE_C_ICON_PATH.format(name=name, path=path) + for name, path in paths ) + icons_c.write(ICONS_TEMPLATE_C_ICON_PATHS.format(icon_paths=icon_paths)) icons_c.close() # Create Public Header @@ -270,17 +281,7 @@ def icons(self): for name, width, height, frame_rate, frame_count in icons: icons_h.write(ICONS_TEMPLATE_H_ICON_NAME.format(name=name)) if is_main_assets: - icons_h.write( - """ -typedef struct { - const Icon* icon; - const char* path; -} IconPath; - -extern const IconPath ICON_PATHS[]; -extern const size_t ICON_PATHS_COUNT; -""" - ) + icons_h.write(ICONS_TEMPLATE_H_ICON_PATHS) else: icons_h.write("#include \n") icons_h.close() From ed046882276c330eedb9cd7f5d3fedf5420defb7 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 04:17:05 +0000 Subject: [PATCH 11/16] Improve unused icons script --- scripts/check_unused_icons.py | 46 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/scripts/check_unused_icons.py b/scripts/check_unused_icons.py index 22d81f77b..0f7967db3 100755 --- a/scripts/check_unused_icons.py +++ b/scripts/check_unused_icons.py @@ -5,29 +5,35 @@ icons = root / "assets/icons" -def source_dir_uses_icon(dir: str, name: str): +def count_icon_usages(name: str): count = 0 name = name.encode() - for file in (root / dir).glob("**/*.c"): - try: - if name in file.read_bytes(): - count += 1 - except Exception: - print(f"Faield to read {file}") + # EXTREMELY wasteful, but who cares + for dir in ("applications", "furi", "lib", "targets"): + for filetype in (".c", ".cpp", ".h", ".fam"): + for file in (root / dir).glob(f"**/*{filetype}"): + try: + if name in file.read_bytes(): + count += 1 + except Exception: + print(f"Failed to read {file}") return count -for category in icons.iterdir(): - if not category.is_dir(): - continue - for icon in category.iterdir(): - if icon.is_dir() and (icon / "frame_rate").is_file(): - name = "&A_" + icon.name.replace("-", "_") - else: - name = "&I_" + "_".join(icon.name.split(".")[:-1]).replace("-", "_") - count = 0 - for dir in ("applications", "furi", "lib", "targets"): - count += source_dir_uses_icon(dir, name) +if __name__ == "__main__": + counts = {} + + for category in icons.iterdir(): + if not category.is_dir(): + continue + for icon in category.iterdir(): + if icon.is_dir() and (icon / "frame_rate").is_file(): + name = "A_" + icon.name.replace("-", "_") + elif icon.is_file() and icon.suffix == ".png": + name = "I_" + "_".join(icon.name.split(".")[:-1]).replace("-", "_") + else: + continue + counts[name[2:]] = count_icon_usages(name) + + for name, count in sorted(counts.items(), key=lambda x: x[1], reverse=True): print(f"{name} used {count} times") - if count == 0: - print(f"====== {name} is not used! ======") From 314556f399027d0c1a9a00f2f2cf0fcead4977d4 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 04:19:30 +0000 Subject: [PATCH 12/16] Disable icons that cant be used in asset packs --- targets/f7/api_symbols.csv | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 1c5aaa6f3..cd892e373 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -3919,12 +3919,12 @@ Variable,+,I_CC_LefthandedMode_16x16,const Icon, Variable,+,I_CC_Lock_16x16,const Icon, Variable,+,I_CC_Momentum_16x16,const Icon, Variable,+,I_CC_Settings_16x16,const Icon, -Variable,+,I_Certification1_103x56,const Icon, -Variable,+,I_Certification2_46x33,const Icon, -Variable,+,I_CertificationChina0_121x41,const Icon, -Variable,+,I_CertificationChina1_124x47,const Icon, -Variable,+,I_CertificationMexico_98x41,const Icon, -Variable,+,I_CertificationTaiwan_33x32,const Icon, +Variable,-,I_Certification1_103x56,const Icon, +Variable,-,I_Certification2_46x33,const Icon, +Variable,-,I_CertificationChina0_121x41,const Icon, +Variable,-,I_CertificationChina1_124x47,const Icon, +Variable,-,I_CertificationMexico_98x41,const Icon, +Variable,-,I_CertificationTaiwan_33x32,const Icon, Variable,+,I_Charging_lightning_9x10,const Icon, Variable,+,I_Charging_lightning_mask_9x10,const Icon, Variable,+,I_Circles_47x47,const Icon, @@ -3932,7 +3932,7 @@ Variable,+,I_Clock_18x18,const Icon, Variable,+,I_Connect_me_62x31,const Icon, Variable,+,I_Connected_62x31,const Icon, Variable,+,I_Cos_9x7,const Icon, -Variable,+,I_DFU_128x50,const Icon, +Variable,-,I_DFU_128x50,const Icon, Variable,+,I_DolphinDone_80x58,const Icon, Variable,+,I_DolphinMafia_119x62,const Icon, Variable,+,I_DolphinReadingSuccess_59x63,const Icon, @@ -3941,7 +3941,7 @@ Variable,+,I_DolphinSuccess_91x55,const Icon, Variable,+,I_DolphinWait_59x54,const Icon, Variable,+,I_Drive_112x35,const Icon, Variable,+,I_Dynamic_9x7,const Icon, -Variable,+,I_Erase_pin_128x64,const Icon, +Variable,-,I_Erase_pin_128x64,const Icon, Variable,+,I_Error_18x18,const Icon, Variable,+,I_Error_62x31,const Icon, Variable,+,I_EviSmile1_18x21,const Icon, @@ -3975,7 +3975,7 @@ Variable,+,I_Left_mouse_icon_9x9,const Icon, Variable,+,I_LoadingHourglass_24x24,const Icon, Variable,+,I_Lock_7x8,const Icon, Variable,+,I_Lockscreen,const Icon, -Variable,+,I_MFKey_qr_25x25,const Icon, +Variable,-,I_MFKey_qr_25x25,const Icon, Variable,+,I_MHz_25x11,const Icon, Variable,+,I_Modern_reader_18x34,const Icon, Variable,+,I_More_data_placeholder_5x7,const Icon, @@ -4002,7 +4002,7 @@ Variable,+,I_Release_arrow_18x15,const Icon, Variable,+,I_Right_mouse_icon_9x9,const Icon, Variable,+,I_Rpc_active_7x8,const Icon, Variable,+,I_SDQuestion_35x43,const Icon, -Variable,+,I_SDcardFail_11x8,const Icon, +Variable,-,I_SDcardFail_11x8,const Icon, Variable,+,I_SDcardMounted_11x8,const Icon, Variable,+,I_Sats_6x9,const Icon, Variable,+,I_Scanning_123x52,const Icon, @@ -4015,15 +4015,15 @@ Variable,+,I_Temperature_16x16,const Icon, Variable,+,I_Unlock_7x8,const Icon, Variable,+,I_Unplug_bg_bottom_128x10,const Icon, Variable,+,I_Unplug_bg_top_128x14,const Icon, -Variable,+,I_Updating_32x40,const Icon, -Variable,+,I_Updating_Logo_62x15,const Icon, +Variable,-,I_Updating_32x40,const Icon, +Variable,-,I_Updating_Logo_62x15,const Icon, Variable,+,I_UsbTree_48x22,const Icon, Variable,+,I_Voldwn_6x6,const Icon, Variable,+,I_Voltage_16x16,const Icon, Variable,+,I_Volup_8x6,const Icon, Variable,+,I_WarningDolphinFlip_45x42,const Icon, Variable,+,I_WarningDolphin_45x42,const Icon, -Variable,+,I_Warning_30x23,const Icon, +Variable,-,I_Warning_30x23,const Icon, Variable,+,I_Weather_7x8,const Icon, Variable,+,I_arrow_nano_down,const Icon, Variable,+,I_arrow_nano_up,const Icon, @@ -4050,14 +4050,14 @@ Variable,+,I_dry_text_15x5,const Icon, Variable,+,I_eject_19x20,const Icon, Variable,+,I_eject_hover_19x20,const Icon, Variable,+,I_eject_text_19x5,const Icon, -Variable,+,I_err_01,const Icon, -Variable,+,I_err_02,const Icon, -Variable,+,I_err_03,const Icon, -Variable,+,I_err_04,const Icon, -Variable,+,I_err_05,const Icon, -Variable,+,I_err_06,const Icon, -Variable,+,I_err_07,const Icon, -Variable,+,I_err_09,const Icon, +Variable,-,I_err_01,const Icon, +Variable,-,I_err_02,const Icon, +Variable,-,I_err_03,const Icon, +Variable,-,I_err_04,const Icon, +Variable,-,I_err_05,const Icon, +Variable,-,I_err_06,const Icon, +Variable,-,I_err_07,const Icon, +Variable,-,I_err_09,const Icon, Variable,+,I_exit_19x20,const Icon, Variable,+,I_exit_hover_19x20,const Icon, Variable,+,I_exit_text_18x5,const Icon, @@ -4126,7 +4126,7 @@ Variable,+,I_power_text_24x5,const Icon, Variable,+,I_prev_19x20,const Icon, Variable,+,I_prev_hover_19x20,const Icon, Variable,+,I_prev_text_19x5,const Icon, -Variable,+,I_qr_benchmark_25x25,const Icon, +Variable,-,I_qr_benchmark_25x25,const Icon, Variable,+,I_red_19x20,const Icon, Variable,+,I_red_hover_19x20,const Icon, Variable,+,I_rotate_19x20,const Icon, From fb23d97952a7f10f263ed8c8b339443d831a5b06 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 04:42:05 +0000 Subject: [PATCH 13/16] These will need a workaround for external --- targets/f7/api_symbols.csv | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index cd892e373..65bffbb76 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -3919,12 +3919,12 @@ Variable,+,I_CC_LefthandedMode_16x16,const Icon, Variable,+,I_CC_Lock_16x16,const Icon, Variable,+,I_CC_Momentum_16x16,const Icon, Variable,+,I_CC_Settings_16x16,const Icon, -Variable,-,I_Certification1_103x56,const Icon, -Variable,-,I_Certification2_46x33,const Icon, -Variable,-,I_CertificationChina0_121x41,const Icon, -Variable,-,I_CertificationChina1_124x47,const Icon, -Variable,-,I_CertificationMexico_98x41,const Icon, -Variable,-,I_CertificationTaiwan_33x32,const Icon, +Variable,+,I_Certification1_103x56,const Icon, +Variable,+,I_Certification2_46x33,const Icon, +Variable,+,I_CertificationChina0_121x41,const Icon, +Variable,+,I_CertificationChina1_124x47,const Icon, +Variable,+,I_CertificationMexico_98x41,const Icon, +Variable,+,I_CertificationTaiwan_33x32,const Icon, Variable,+,I_Charging_lightning_9x10,const Icon, Variable,+,I_Charging_lightning_mask_9x10,const Icon, Variable,+,I_Circles_47x47,const Icon, @@ -3975,7 +3975,7 @@ Variable,+,I_Left_mouse_icon_9x9,const Icon, Variable,+,I_LoadingHourglass_24x24,const Icon, Variable,+,I_Lock_7x8,const Icon, Variable,+,I_Lockscreen,const Icon, -Variable,-,I_MFKey_qr_25x25,const Icon, +Variable,+,I_MFKey_qr_25x25,const Icon, Variable,+,I_MHz_25x11,const Icon, Variable,+,I_Modern_reader_18x34,const Icon, Variable,+,I_More_data_placeholder_5x7,const Icon, @@ -4023,7 +4023,7 @@ Variable,+,I_Voltage_16x16,const Icon, Variable,+,I_Volup_8x6,const Icon, Variable,+,I_WarningDolphinFlip_45x42,const Icon, Variable,+,I_WarningDolphin_45x42,const Icon, -Variable,-,I_Warning_30x23,const Icon, +Variable,+,I_Warning_30x23,const Icon, Variable,+,I_Weather_7x8,const Icon, Variable,+,I_arrow_nano_down,const Icon, Variable,+,I_arrow_nano_up,const Icon, @@ -4057,7 +4057,7 @@ Variable,-,I_err_04,const Icon, Variable,-,I_err_05,const Icon, Variable,-,I_err_06,const Icon, Variable,-,I_err_07,const Icon, -Variable,-,I_err_09,const Icon, +Variable,+,I_err_09,const Icon, Variable,+,I_exit_19x20,const Icon, Variable,+,I_exit_hover_19x20,const Icon, Variable,+,I_exit_text_18x5,const Icon, @@ -4126,7 +4126,7 @@ Variable,+,I_power_text_24x5,const Icon, Variable,+,I_prev_19x20,const Icon, Variable,+,I_prev_hover_19x20,const Icon, Variable,+,I_prev_text_19x5,const Icon, -Variable,-,I_qr_benchmark_25x25,const Icon, +Variable,+,I_qr_benchmark_25x25,const Icon, Variable,+,I_red_19x20,const Icon, Variable,+,I_red_hover_19x20,const Icon, Variable,+,I_rotate_19x20,const Icon, From 9921ce334f16ae68ea6f01523b506604cd740dca Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 05:27:38 +0000 Subject: [PATCH 14/16] Revert "These will need a workaround for external" This reverts commit fb23d97952a7f10f263ed8c8b339443d831a5b06. --- targets/f7/api_symbols.csv | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 65bffbb76..cd892e373 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -3919,12 +3919,12 @@ Variable,+,I_CC_LefthandedMode_16x16,const Icon, Variable,+,I_CC_Lock_16x16,const Icon, Variable,+,I_CC_Momentum_16x16,const Icon, Variable,+,I_CC_Settings_16x16,const Icon, -Variable,+,I_Certification1_103x56,const Icon, -Variable,+,I_Certification2_46x33,const Icon, -Variable,+,I_CertificationChina0_121x41,const Icon, -Variable,+,I_CertificationChina1_124x47,const Icon, -Variable,+,I_CertificationMexico_98x41,const Icon, -Variable,+,I_CertificationTaiwan_33x32,const Icon, +Variable,-,I_Certification1_103x56,const Icon, +Variable,-,I_Certification2_46x33,const Icon, +Variable,-,I_CertificationChina0_121x41,const Icon, +Variable,-,I_CertificationChina1_124x47,const Icon, +Variable,-,I_CertificationMexico_98x41,const Icon, +Variable,-,I_CertificationTaiwan_33x32,const Icon, Variable,+,I_Charging_lightning_9x10,const Icon, Variable,+,I_Charging_lightning_mask_9x10,const Icon, Variable,+,I_Circles_47x47,const Icon, @@ -3975,7 +3975,7 @@ Variable,+,I_Left_mouse_icon_9x9,const Icon, Variable,+,I_LoadingHourglass_24x24,const Icon, Variable,+,I_Lock_7x8,const Icon, Variable,+,I_Lockscreen,const Icon, -Variable,+,I_MFKey_qr_25x25,const Icon, +Variable,-,I_MFKey_qr_25x25,const Icon, Variable,+,I_MHz_25x11,const Icon, Variable,+,I_Modern_reader_18x34,const Icon, Variable,+,I_More_data_placeholder_5x7,const Icon, @@ -4023,7 +4023,7 @@ Variable,+,I_Voltage_16x16,const Icon, Variable,+,I_Volup_8x6,const Icon, Variable,+,I_WarningDolphinFlip_45x42,const Icon, Variable,+,I_WarningDolphin_45x42,const Icon, -Variable,+,I_Warning_30x23,const Icon, +Variable,-,I_Warning_30x23,const Icon, Variable,+,I_Weather_7x8,const Icon, Variable,+,I_arrow_nano_down,const Icon, Variable,+,I_arrow_nano_up,const Icon, @@ -4057,7 +4057,7 @@ Variable,-,I_err_04,const Icon, Variable,-,I_err_05,const Icon, Variable,-,I_err_06,const Icon, Variable,-,I_err_07,const Icon, -Variable,+,I_err_09,const Icon, +Variable,-,I_err_09,const Icon, Variable,+,I_exit_19x20,const Icon, Variable,+,I_exit_hover_19x20,const Icon, Variable,+,I_exit_text_18x5,const Icon, @@ -4126,7 +4126,7 @@ Variable,+,I_power_text_24x5,const Icon, Variable,+,I_prev_19x20,const Icon, Variable,+,I_prev_hover_19x20,const Icon, Variable,+,I_prev_text_19x5,const Icon, -Variable,+,I_qr_benchmark_25x25,const Icon, +Variable,-,I_qr_benchmark_25x25,const Icon, Variable,+,I_red_19x20,const Icon, Variable,+,I_red_hover_19x20,const Icon, Variable,+,I_rotate_19x20,const Icon, From bc68ef15e1932f932c8c9130d9eab5198bb31da7 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 07:01:14 +0000 Subject: [PATCH 15/16] Here's the workaround: split assets lib now there is "assets" and "fwassets" firmware links with fwassets and includes all icons however not all of them are exposed to api if an app needs a firmware icon not in api, it can use fap_libs=["assets"] this will link against this dummy assets lib it only contains the icons that arent exposed to api this way, an app using assets lib will still benefit from asset packs but at same time, we can remove pointless icons from dfu blob --- applications/main/nfc/application.fam | 2 +- applications/settings/about/application.fam | 1 + .../power_settings_app/application.fam | 1 + .../settings/storage_settings/application.fam | 1 + applications/system/js_app/application.fam | 2 ++ assets/SConscript | 26 ++++++++++++++-- scripts/assets.py | 31 ++++++++++++++----- scripts/fbt_tools/fbt_assets.py | 16 +++++++++- scripts/fbt_tools/fbt_extapps.py | 1 + targets/f7/target.json | 2 +- 10 files changed, 70 insertions(+), 13 deletions(-) diff --git a/applications/main/nfc/application.fam b/applications/main/nfc/application.fam index 13c26b7aa..3878fc2e8 100644 --- a/applications/main/nfc/application.fam +++ b/applications/main/nfc/application.fam @@ -13,7 +13,7 @@ App( "!plugins", "!nfc_cli.c", ], - fap_libs=["mbedtls"], + fap_libs=["assets", "mbedtls"], fap_icon="icon.png", fap_category="NFC", ) diff --git a/applications/settings/about/application.fam b/applications/settings/about/application.fam index 055933544..e7b474c22 100644 --- a/applications/settings/about/application.fam +++ b/applications/settings/about/application.fam @@ -12,4 +12,5 @@ App( stack_size=1 * 1024, order=1000, fap_category="assets", + fap_libs=["assets"], ) diff --git a/applications/settings/power_settings_app/application.fam b/applications/settings/power_settings_app/application.fam index 65f90b14f..23cfdfabc 100644 --- a/applications/settings/power_settings_app/application.fam +++ b/applications/settings/power_settings_app/application.fam @@ -12,4 +12,5 @@ App( stack_size=1 * 1024, order=40, fap_category="assets", + fap_libs=["assets"], ) diff --git a/applications/settings/storage_settings/application.fam b/applications/settings/storage_settings/application.fam index eba847ddb..560f1f56c 100644 --- a/applications/settings/storage_settings/application.fam +++ b/applications/settings/storage_settings/application.fam @@ -8,4 +8,5 @@ App( stack_size=2 * 1024, order=30, fap_category="assets", + fap_libs=["assets"], ) diff --git a/applications/system/js_app/application.fam b/applications/system/js_app/application.fam index 988fedb03..6d2b4fe80 100644 --- a/applications/system/js_app/application.fam +++ b/applications/system/js_app/application.fam @@ -5,6 +5,7 @@ App( cdefines=["JS_RUNNER_FAP"], fap_icon="icon.png", fap_category="assets", + fap_libs=["assets"], entry_point="js_app", stack_size=2 * 1024, resources="examples", @@ -35,6 +36,7 @@ App( "modules/js_flipper.c", "modules/js_tests.c", ], + fap_libs=["assets"], ) App( diff --git a/assets/SConscript b/assets/SConscript index a5454fffa..7aefdc0a5 100644 --- a/assets/SConscript +++ b/assets/SConscript @@ -14,9 +14,26 @@ icons_path = ( if assetsenv["IS_BASE_FIRMWARE"] else assetsenv["ASSETS_WORK_DIR"] ) -icons = assetsenv.CompileIcons(icons_path, assetsenv["ASSETS_SRC_DIR"].Dir("icons")) +icons = assetsenv.CompileIcons( + icons_path, + assetsenv["ASSETS_SRC_DIR"].Dir("icons"), + fw_bundle=True, +) assetsenv.Alias("icons", icons) +# Extra icons lib so apps don't override asset packs to use fw icons not exposed to api +# Not used anywhere in code, apps still reference assets_icons.h, but if one of the +# icons they need is not exposed in api, they can link with fap_libs=["assets"] which +# will use this lib purely for linking as a drop-in for missing symbols. +# Should mean that apps made for OFW with fap_libs=["assets"], when compiled with +# this FBT, will still use asset packs at runtime and only link non-exposed icons. +if assetsenv["IS_BASE_FIRMWARE"]: + dropin_icons = assetsenv.CompileIcons( + assetsenv["ASSETS_WORK_DIR"], + assetsenv["ASSETS_SRC_DIR"].Dir("icons"), + icon_bundle_name="_assets_icons_dropin", + ) + # Protobuf .proto -> .c + .h proto_src = assetsenv.Glob("protobuf/*.proto", source=True) @@ -59,9 +76,14 @@ assetsenv.Alias("proto_ver", proto_ver) assets_parts = (icons, proto, dolphin_blocking, dolphin_internal, proto_ver) env.Replace(FW_ASSETS_HEADERS=assets_parts) -assetslib = assetsenv.Library("${FW_LIB_NAME}", assets_parts) +assetslib = assetsenv.Library("fw${FW_LIB_NAME}", assets_parts) assetsenv.Install("${LIB_DIST_DIR}", assetslib) +if assetsenv["IS_BASE_FIRMWARE"]: + dropin_parts = (dropin_icons, proto, dolphin_blocking, dolphin_internal, proto_ver) + dropin_assetslib = assetsenv.Library("${FW_LIB_NAME}", dropin_parts) + assetsenv.Install("${LIB_DIST_DIR}", dropin_assetslib) + # Resources for SD card if assetsenv["IS_BASE_FIRMWARE"]: diff --git a/scripts/assets.py b/scripts/assets.py index cc05eb06f..6eb83b66f 100755 --- a/scripts/assets.py +++ b/scripts/assets.py @@ -63,6 +63,22 @@ def init(self): required=False, default="assets_icons", ) + self.parser_icons.add_argument( + "--fw-bundle", + dest="fw_bundle", + help="Bundle all icons and path info, only for use in firmware blob", + default=0, + type=int, + required=False, + ) + self.parser_icons.add_argument( + "--add-include", + dest="add_include", + help="Add assets_icons.h include drop-in for apps", + default=0, + type=int, + required=False, + ) self.parser_icons.set_defaults(func=self.icons) @@ -156,7 +172,6 @@ def icons(self): ) icons = [] paths = [] - is_main_assets = self.args.filename == "assets_icons" symbols = pathlib.Path(__file__).parent.parent if "UFBT_HOME" in os.environ: symbols /= "sdk_headers/f7_sdk" @@ -173,7 +188,7 @@ def icons(self): self.logger.debug("Folder contains animation") icon_name = "A_" + os.path.split(dirpath)[1].replace("-", "_") icon_in_api = api_has_icon(icon_name) - if not is_main_assets and icon_in_api: + if not self.args.fw_bundle and icon_in_api: self.logger.info( f"{self.args.filename}: ignoring duplicate icon {icon_name}" ) @@ -212,7 +227,7 @@ def icons(self): ) icons_c.write("\n") icons.append((icon_name, width, height, frame_rate, frame_count)) - if is_main_assets and icon_in_api: + if self.args.fw_bundle and icon_in_api: path = dirpath.removeprefix(self.args.input_directory)[1:] paths.append((icon_name, path.replace("\\", "/"))) else: @@ -225,7 +240,7 @@ def icons(self): "-", "_" ) icon_in_api = api_has_icon(icon_name) - if not is_main_assets and icon_in_api: + if not self.args.fw_bundle and icon_in_api: self.logger.info( f"{self.args.filename}: ignoring duplicate icon {icon_name}" ) @@ -243,7 +258,7 @@ def icons(self): ) icons_c.write("\n") icons.append((icon_name, width, height, 0, 1)) - if is_main_assets and icon_in_api: + if self.args.fw_bundle and icon_in_api: path = fullfilename.removeprefix(self.args.input_directory)[1:] paths.append( (icon_name, path.replace("\\", "/").rsplit(".", 1)[0]) @@ -260,7 +275,7 @@ def icons(self): frame_count=frame_count, ) ) - if not is_main_assets: + if not self.args.fw_bundle: icons_c.write("\n") else: icon_paths = "\n".join( @@ -280,9 +295,9 @@ def icons(self): icons_h.write(ICONS_TEMPLATE_H_HEADER) for name, width, height, frame_rate, frame_count in icons: icons_h.write(ICONS_TEMPLATE_H_ICON_NAME.format(name=name)) - if is_main_assets: + if self.args.fw_bundle: icons_h.write(ICONS_TEMPLATE_H_ICON_PATHS) - else: + if self.args.add_include: icons_h.write("#include \n") icons_h.close() self.logger.debug("Done") diff --git a/scripts/fbt_tools/fbt_assets.py b/scripts/fbt_tools/fbt_assets.py index 012ff5329..b3e70ab05 100644 --- a/scripts/fbt_tools/fbt_assets.py +++ b/scripts/fbt_tools/fbt_assets.py @@ -181,7 +181,15 @@ def describe(): file.write("\n".join(version_file_data)) -def CompileIcons(env, target_dir, source_dir, *, icon_bundle_name="assets_icons"): +def CompileIcons( + env, + target_dir, + source_dir, + *, + icon_bundle_name="assets_icons", + fw_bundle=False, + add_include=False, +): try: os.mkdir(str(source_dir)) except FileExistsError: @@ -191,6 +199,8 @@ def CompileIcons(env, target_dir, source_dir, *, icon_bundle_name="assets_icons" None, ICON_SRC_DIR=source_dir, ICON_FILE_NAME=icon_bundle_name, + ICON_FW_BUNDLE=int(fw_bundle), + ICON_ADD_INCLUDE=int(add_include), ) @@ -223,6 +233,10 @@ def generate(env): "${TARGET.dir}", "--filename", "${ICON_FILE_NAME}", + "--fw-bundle", + "${ICON_FW_BUNDLE}", + "--add-include", + "${ICON_ADD_INCLUDE}", ], ], "${ICONSCOMSTR}", diff --git a/scripts/fbt_tools/fbt_extapps.py b/scripts/fbt_tools/fbt_extapps.py index da5e272a8..26b1025d9 100644 --- a/scripts/fbt_tools/fbt_extapps.py +++ b/scripts/fbt_tools/fbt_extapps.py @@ -90,6 +90,7 @@ def _compile_assets(self): self.app_work_dir, self.app._appdir.Dir(self.app.fap_icon_assets), icon_bundle_name=f"{self.app.fap_icon_assets_symbol or self.app.appid }_icons", + add_include=True, ) self.app_env.Alias("_fap_icons", fap_icons) self.fw_env.Append(_APP_ICONS=[fap_icons]) diff --git a/targets/f7/target.json b/targets/f7/target.json index c5a65704a..810c76d95 100644 --- a/targets/f7/target.json +++ b/targets/f7/target.json @@ -35,7 +35,7 @@ "microtar", "usb_stm32", "infrared", - "assets", + "fwassets", "one_wire", "ibutton", "music_worker", From 3c61a9aa1e0267efe79e571bf174773b2ef101fc Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 5 Nov 2024 07:24:36 +0000 Subject: [PATCH 16/16] Update changelog --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6507b0bce..3720d3ac5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -133,9 +133,6 @@ - UL: W5500 Ethernet: Various fixes and improvements (by @xMasterX) - OFW: SPI Mem Manager: Fixed UI rendering bug related to line breaks (by @portasynthinca3) - OFW: USB/BT Remote: Mouse clicker option to click as fast as possible (by @sumukhj1219) -- CLI: - - Print plugin name on load fail (by @Willy-JL) - - Move more commands as plugins on SD, refactor plugin wrapper (#276 by @Willy-JL) - NFC: - NDEF Parser: - Mifare Classic support (#265 by @luu176), protocol-agnostic rewrite and more improvements (#265 by @Willy-JL) @@ -166,6 +163,10 @@ - OFW: Add TCL 75S451 to TV universal remote (by @christhetech131) - OFW: Universal remote additions (by @jaylikesbunda) - OFW: Heavily Expand Universal Remotes (by @jaylikesbunda) +- CLI: + - Print plugin name on load fail (by @Willy-JL) + - Move more commands as plugins on SD, refactor plugin wrapper (#276 by @Willy-JL) +- FBT: Optimize icons blob, scrub unused icons (#291 by @Willy-JL) - OFW: BadKB: Improve ChromeOS and GNOME demo scripts (by @kowalski7cc) - OFW: GUI: Change dialog_ex text ownership model (by @skotopes) - OFW: CCID: App changes and improvements (by @kidbomb)