Skip to content

Commit

Permalink
fbt: add fap_deploy target to build and copy all .fap apps to flipp…
Browse files Browse the repository at this point in the history
…er (flipperdevices#2146)

* fbt: add `faps_copy` target to build and copy all .fap apps to flipper
* fbt: restore default runfap.py invocation behavior, use -n for copy only
* fbt: proper implementation of fap_deploy target

Co-authored-by: hedger <[email protected]>
  • Loading branch information
smkent and hedger authored Jan 11, 2023
1 parent 8d2143a commit d2df35a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
16 changes: 14 additions & 2 deletions .vscode/example/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,26 @@
"Serial Console"
]
},
{
"label": "[Debug] Build and upload all FAPs to Flipper over USB",
"group": "build",
"type": "shell",
"command": "./fbt fap_deploy"
},
{
"label": "[Release] Build and upload all FAPs to Flipper over USB",
"group": "build",
"type": "shell",
"command": "./fbt COMPACT=1 DEBUG=0 fap_deploy"
},
{
// Press Ctrl+] to quit
"label": "Serial Console",
"type": "shell",
"command": "./fbt cli",
"group": "none",
"isBackground": true,
"options": {
"options": {
"env": {
"FBT_NO_SYNC": "0"
}
Expand All @@ -162,4 +174,4 @@
}
}
]
}
}
8 changes: 8 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ Alias("fap_dist", fap_dist)

distenv.Depends(firmware_env["FW_RESOURCES"], firmware_env["FW_EXTAPPS"].resources_dist)

# Copy all faps to device

fap_deploy = distenv.PhonyTarget(
"fap_deploy",
"${PYTHON3} ${ROOT_DIR}/scripts/storage.py send ${SOURCE} /ext/apps",
source=Dir("#/assets/resources/apps"),
)


# Target for bundling core2 package for qFlipper
copro_dist = distenv.CoproBuilder(
Expand Down
2 changes: 2 additions & 0 deletions scripts/fbt_tools/fbt_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
Build all FAP apps
fap_{APPID}, launch_app APPSRC={APPID}:
Build FAP app with appid={APPID}; upload & start it over USB
fap_deploy:
Build and upload all FAP apps over USB
Flashing & debugging:
flash, flash_blackmagic, jflash:
Expand Down
20 changes: 15 additions & 5 deletions scripts/runfap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
class Main(App):
def init(self):
self.parser.add_argument("-p", "--port", help="CDC Port", default="auto")
self.parser.add_argument(
"-n",
"--no-launch",
dest="launch_app",
action="store_false",
help="Don't launch app",
)

self.parser.add_argument("fap_src_path", help="App file to upload")
self.parser.add_argument(
Expand Down Expand Up @@ -84,11 +91,14 @@ def install(self):
self.logger.error(f"Error: upload failed: {storage.last_error}")
return -3

storage.send_and_wait_eol(f'loader open "Applications" {fap_dst_path}\r')
result = storage.read.until(storage.CLI_EOL)
if len(result):
self.logger.error(f"Unexpected response: {result.decode('ascii')}")
return -4
if self.args.launch_app:
storage.send_and_wait_eol(
f'loader open "Applications" {fap_dst_path}\r'
)
result = storage.read.until(storage.CLI_EOL)
if len(result):
self.logger.error(f"Unexpected response: {result.decode('ascii')}")
return -4

return 0
finally:
Expand Down

0 comments on commit d2df35a

Please sign in to comment.