Skip to content

Commit

Permalink
ufbt: deploying sample ufbt automation for new apps; added `source "u…
Browse files Browse the repository at this point in the history
…fbt -s env"` for toolchain access (flipperdevices#2648)
  • Loading branch information
hedger authored May 8, 2023
1 parent 954780e commit f7dd777
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 3 deletions.
6 changes: 6 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,9 @@ vscode_dist = distenv.Install("#.vscode", distenv.Glob("#.vscode/example/*"))
distenv.Precious(vscode_dist)
distenv.NoClean(vscode_dist)
distenv.Alias("vscode_dist", vscode_dist)

# Configure shell with build tools
distenv.PhonyTarget(
"env",
"@echo $( ${FBT_SCRIPT_DIR}/toolchain/fbtenv.sh $)",
)
1 change: 1 addition & 0 deletions documentation/fbt.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ To use `fbt`, you only need `git` installed in your system.
> However, if you wish to use tools supplied with the toolchain outside `fbt`, you can open an *fbt shell*, with properly configured environment.
> - On Windows, simply run `scripts/toolchain/fbtenv.cmd`.
> - On Linux & MacOS, run `source scripts/toolchain/fbtenv.sh` in a new shell.
> - You can also type ```. `./fbt -s env` ``` in your shell. (Keep the "." at the beginning.)
If your system is not supported by pre-built toolchain variants or you want to use custom versions of dependencies, you can `set FBT_NOENV=1`. `fbt` will skip toolchain & environment configuration and will expect all tools to be available on your system's `PATH`. *(this option is not available on Windows)*

Expand Down
4 changes: 3 additions & 1 deletion scripts/fbt_tools/fbt_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from SCons.Builder import Builder
from SCons.Errors import StopError
from SCons.Warnings import WarningOnByDefault, warn
from SCons.Script import GetOption

# Adding objects for application management to env
# AppManager env["APPMGR"] - loads all manifests; manages list of known apps
Expand All @@ -28,7 +29,8 @@ def LoadAppManifest(env, entry):
env["APPMGR"].load_manifest(app_manifest_file_path, entry)
env.Append(PY_LINT_SOURCES=[app_manifest_file_path])
except FlipperManifestException as e:
warn(WarningOnByDefault, str(e))
if not GetOption("silent"):
warn(WarningOnByDefault, str(e))


def PrepareApplicationsBuild(env):
Expand Down
3 changes: 3 additions & 0 deletions scripts/fbt_tools/fbt_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
firmware_pvs:
generate a PVS-Studio report
How to open a shell with toolchain environment and other build tools:
In your shell, type "source `./fbt -s env`". You can also use "." instead of "source".
For more targets & info, see documentation/fbt.md
"""

Expand Down
11 changes: 9 additions & 2 deletions scripts/ufbt/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,9 @@ dist_env.Alias("vscode_dist", vscode_dist)
# Creating app from base template

dist_env.SetDefault(FBT_APPID=appenv.subst("$APPID") or "template")
app_template_dir = project_template_dir.Dir("app_template")
app_template_dist = []
for template_file in project_template_dir.Dir("app_template").glob("*"):
for template_file in app_template_dir.glob("*"):
dist_file_name = dist_env.subst(template_file.name)
if template_file.name.endswith(".png"):
app_template_dist.append(
Expand All @@ -397,12 +398,13 @@ for template_file in project_template_dir.Dir("app_template").glob("*"):
},
)
)

AddPostAction(
app_template_dist[-1],
[
Mkdir(original_app_dir.Dir("images")),
Touch(original_app_dir.Dir("images").File(".gitkeep")),
# scons' glob ignores .dot directories, so we need to copy .github manually
Copy(original_app_dir.Dir(".github"), app_template_dir.Dir(".github")),
],
)
dist_env.Precious(app_template_dist)
Expand Down Expand Up @@ -440,3 +442,8 @@ else:
raise UserError(f"Dolphin folder not found: {dolphin_src_dir}")

dist_env.PhonyTarget("dolphin_ext", Action(missing_dolphin_folder, None))

dist_env.PhonyTarget(
"env",
"@echo $( ${FBT_SCRIPT_DIR}/toolchain/fbtenv.sh $)",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "FAP: Build for multiple SDK sources"
# This will build your app for dev and release channels on GitHub.
# It will also build your app every day to make sure it's up to date with the latest SDK changes.
# See https://github.com/marketplace/actions/build-flipper-application-package-fap for more information

on:
push:
## put your main branch name under "braches"
#branches:
# - master
pull_request:
schedule:
# do a build every day
- cron: "1 1 * * *"

jobs:
ufbt-build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: dev channel
sdk-channel: dev
- name: release channel
sdk-channel: release
# You can add unofficial channels here. See ufbt action docs for more info.
name: 'ufbt: Build for ${{ matrix.name }}'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build with ufbt
uses: flipperdevices/[email protected]
id: build-app
with:
sdk-channel: ${{ matrix.sdk-channel }}
- name: Upload app artifacts
uses: actions/upload-artifact@v3
with:
# See ufbt action docs for other output variables
name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }}
path: ${{ steps.build-app.outputs.fap-artifacts }}
3 changes: 3 additions & 0 deletions scripts/ufbt/site_tools/ufbt_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
2. Run `ufbt vscode_dist create APPID=myapp`
3. In VSCode, open the folder and start editing.
4. Run `ufbt launch` to build and upload your application.
How to open a shell with toolchain environment and other build tools:
In your shell, type "source `ufbt -s env`". You can also use "." instead of "source".
"""


Expand Down

0 comments on commit f7dd777

Please sign in to comment.