Merge branch 'ofwdev' into 420

This commit is contained in:
RogueMaster
2022-10-26 01:18:29 -04:00
48 changed files with 577 additions and 233 deletions
+169
View File
@@ -0,0 +1,169 @@
name: 'Build'
on:
push:
branches:
- dev
- "release*"
tags:
- '*'
pull_request:
env:
TARGETS: f7
DEFAULT_TARGET: f7
jobs:
main:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Make artifacts directory'
run: |
rm -rf artifacts
mkdir artifacts
- name: 'Get commit details'
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
TYPE="pull"
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
TYPE="tag"
else
TYPE="other"
fi
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
- name: 'Generate suffixes for comment'
id: names
run: |
echo "::set-output name=branch_name::${BRANCH_NAME}"
echo "::set-output name=commit_sha::${COMMIT_SHA}"
echo "::set-output name=default_target::${DEFAULT_TARGET}"
echo "::set-output name=suffix::${SUFFIX}"
- name: 'Bundle scripts'
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
tar czpf artifacts/flipper-z-any-scripts-${SUFFIX}.tgz scripts debug
- name: 'Build the firmware'
run: |
set -e
for TARGET in ${TARGETS}; do
FBT_TOOLCHAIN_PATH=/runner/_work ./fbt TARGET_HW="$(echo "${TARGET}" | sed 's/f//')" \
copro_dist updater_package ${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
done
- name: 'Move upload files'
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
set -e
for TARGET in ${TARGETS}; do
mv dist/${TARGET}-*/* artifacts/
done
- name: "Check for uncommitted changes"
run: |
git diff --exit-code
- name: 'Bundle resources'
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
tar czpf "artifacts/flipper-z-any-resources-${SUFFIX}.tgz" -C assets resources
- name: 'Bundle core2 firmware'
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
cp build/core2_firmware.tgz "artifacts/flipper-z-any-core2_firmware-${SUFFIX}.tgz"
- name: 'Copy .map file'
run: |
cp build/f7-firmware-*/firmware.elf.map "artifacts/flipper-z-f7-firmware-${SUFFIX}.elf.map"
- name: 'Upload artifacts to update server'
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
mkdir -p ~/.ssh
ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts
echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
chmod 600 ./deploy_key;
rsync -avzP --delete --mkpath \
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
artifacts/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${BRANCH_NAME}/";
rm ./deploy_key;
- name: 'Trigger update server reindex'
if: ${{ !github.event.pull_request.head.repo.fork }}
run: curl -X POST -F 'key=${{ secrets.REINDEX_KEY }}' ${{ secrets.REINDEX_URL }}
- name: 'Find Previous Comment'
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Compiled firmware for commit'
- name: 'Create or update comment'
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
**Compiled firmware for commit `${{steps.names.outputs.commit_sha}}`:**
- [📦 Update package](https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz)
- [📥 DFU file](https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-full-${{steps.names.outputs.suffix}}.dfu)
- [☁️ Web/App updater](https://lab.flipper.net/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
edit-mode: replace
compact:
if: ${{ !startsWith(github.ref, 'refs/tags') }}
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]
then
git submodule status \
|| git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
TYPE="pull"
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
TYPE="tag"
else
TYPE="other"
fi
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
- name: 'Build the firmware'
run: |
set -e
for TARGET in ${TARGETS}; do
FBT_TOOLCHAIN_PATH=/runner/_work ./fbt TARGET_HW="$(echo "${TARGET}" | sed 's/f//')" \
updater_package DEBUG=0 COMPACT=1
done
+105
View File
@@ -0,0 +1,105 @@
name: 'Static C/C++ analysis with PVS-Studio'
on:
push:
branches:
- dev
- "release*"
tags:
- '*'
pull_request:
env:
TARGETS: f7
DEFAULT_TARGET: f7
jobs:
analyse_c_cpp:
if: ${{ !github.event.pull_request.head.repo.fork }}
runs-on: [self-hosted, FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
TYPE="pull"
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
TYPE="tag"
else
TYPE="other"
fi
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
- name: 'Generate suffixes for comment'
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
id: names
run: |
echo "::set-output name=branch_name::${BRANCH_NAME}"
echo "::set-output name=commit_sha::${COMMIT_SHA}"
echo "::set-output name=default_target::${DEFAULT_TARGET}"
echo "::set-output name=suffix::${SUFFIX}"
- name: 'Make reports directory'
run: |
rm -rf reports/
mkdir reports
- name: 'Generate compile_comands.json'
run: |
FBT_TOOLCHAIN_PATH=/runner/_work ./fbt COMPACT=1 version_json proto_ver icons firmware_cdb dolphin_internal dolphin_blocking
- name: 'Static code analysis'
run: |
FBT_TOOLCHAIN_PATH=/runner/_work source scripts/toolchain/fbtenv.sh
pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
pvs-studio-analyzer analyze \
@.pvsoptions \
-j$(grep -c processor /proc/cpuinfo) \
-f build/f7-firmware-DC/compile_commands.json \
-o PVS-Studio.log
- name: 'Convert PVS-Studio output to html page'
run: plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o reports/${DEFAULT_TARGET}-${SUFFIX}
- name: 'Upload artifacts to update server'
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
mkdir -p ~/.ssh
ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts
echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
chmod 600 ./deploy_key;
rsync -avrzP --mkpath \
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
reports/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${BRANCH_NAME}/";
rm ./deploy_key;
- name: 'Find Previous Comment'
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'PVS-Studio report for commit'
- name: 'Create or update comment'
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
**PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
- [Report](https://update.flipperzero.one/builds/firmware-pvs-studio-report/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/index.html)
edit-mode: replace
-3
View File
@@ -22,9 +22,6 @@
[submodule "lib/microtar"]
path = lib/microtar
url = https://github.com/amachronic/microtar.git
[submodule "lib/scons"]
path = lib/scons
url = https://github.com/SCons/scons.git
[submodule "lib/mbedtls"]
path = lib/mbedtls
url = https://github.com/Mbed-TLS/mbedtls.git
+1 -1
View File
@@ -2,7 +2,7 @@
"configurations": [
{
"name": "Win32",
"compilerPath": "${workspaceFolder}/toolchain/i686-windows/bin/arm-none-eabi-gcc.exe",
"compilerPath": "${workspaceFolder}/toolchain/x86_64-windows/bin/arm-none-eabi-gcc.exe",
"intelliSenseMode": "gcc-arm",
"compileCommands": "${workspaceFolder}/build/latest/compile_commands.json",
"configurationProvider": "ms-vscode.cpptools",
+19
View File
@@ -79,6 +79,25 @@
]
// "showDevDebugOutput": "raw",
},
{
"name": "Attach FW (DAP)",
"cwd": "${workspaceFolder}",
"executable": "./build/latest/firmware.elf",
"request": "attach",
"type": "cortex-debug",
"servertype": "openocd",
"device": "cmsis-dap",
"svdFile": "./debug/STM32WB55_CM4.svd",
"rtos": "FreeRTOS",
"configFiles": [
"interface/cmsis-dap.cfg",
"./debug/stm32wbx.cfg",
],
"postAttachCommands": [
"source debug/flipperapps.py",
],
// "showDevDebugOutput": "raw",
},
{
"name": "fbt debug",
"type": "python",
+3 -3
View File
@@ -6,13 +6,13 @@
"cortex-debug.enableTelemetry": false,
"cortex-debug.variableUseNaturalFormat": true,
"cortex-debug.showRTOS": true,
"cortex-debug.armToolchainPath.windows": "${workspaceFolder}/toolchain/i686-windows/bin",
"cortex-debug.armToolchainPath.windows": "${workspaceFolder}/toolchain/x86_64-windows/bin",
"cortex-debug.armToolchainPath.linux": "${workspaceFolder}/toolchain/x86_64-linux/bin",
"cortex-debug.armToolchainPath.osx": "${workspaceFolder}/toolchain/x86_64-darwin/bin",
"cortex-debug.openocdPath.windows": "${workspaceFolder}/toolchain/i686-windows/openocd/bin/openocd.exe",
"cortex-debug.openocdPath.windows": "${workspaceFolder}/toolchain/x86_64-windows/openocd/bin/openocd.exe",
"cortex-debug.openocdPath.linux": "${workspaceFolder}/toolchain/x86_64-linux/openocd/bin/openocd",
"cortex-debug.openocdPath.osx": "${workspaceFolder}/toolchain/x86_64-darwin/openocd/bin/openocd",
"cortex-debug.gdbPath.windows": "${workspaceFolder}/toolchain/i686-windows/bin/arm-none-eabi-gdb-py.bat",
"cortex-debug.gdbPath.windows": "${workspaceFolder}/toolchain/x86_64-windows/bin/arm-none-eabi-gdb-py.bat",
"cortex-debug.gdbPath.linux": "${workspaceFolder}/toolchain/x86_64-linux/bin/arm-none-eabi-gdb-py",
"cortex-debug.gdbPath.osx": "${workspaceFolder}/toolchain/x86_64-darwin/bin/arm-none-eabi-gdb-py",
"editor.formatOnSave": true,
+12 -4
View File
@@ -156,11 +156,9 @@ Depends(fap_dist, firmware_env["FW_EXTAPPS"]["validators"].values())
Alias("fap_dist", fap_dist)
# distenv.Default(fap_dist)
plugin_resources_dist = list(
distenv.Install(f"#/assets/resources/apps/{dist_entry[0]}", dist_entry[1])
for dist_entry in firmware_env["FW_EXTAPPS"]["dist"].values()
distenv.Depends(
firmware_env["FW_RESOURCES"], firmware_env["FW_EXTAPPS"]["resources_dist"]
)
distenv.Depends(firmware_env["FW_RESOURCES"], plugin_resources_dist)
# Target for bundling core2 package for qFlipper
@@ -291,6 +289,16 @@ distenv.PhonyTarget(
"@echo $( ${BLACKMAGIC_ADDR} $)",
)
# Find STLink probe ids
distenv.PhonyTarget(
"get_stlink",
distenv.Action(
lambda **kw: distenv.GetDevices(),
None,
),
)
# Prepare vscode environment
vscode_dist = distenv.Install("#.vscode", distenv.Glob("#.vscode/example/*"))
distenv.Precious(vscode_dist)
+2 -1
View File
@@ -1,3 +1,4 @@
/core2_firmware
/resources/Manifest
/resources/apps/*
/resources/apps/*
/resources/dolphin/*
+4 -2
View File
@@ -68,15 +68,17 @@ if assetsenv["IS_BASE_FIRMWARE"]:
assetsenv.Dir("#/assets/dolphin"),
DOLPHIN_RES_TYPE="external",
)
assetsenv.NoClean(dolphin_external)
if assetsenv["FORCE"]:
assetsenv.AlwaysBuild(dolphin_external)
assetsenv.Alias("dolphin_ext", dolphin_external)
assetsenv.Clean(dolphin_external, assetsenv.Dir("#/assets/resources/dolphin"))
# Resources manifest
resources = assetsenv.Command(
"#/assets/resources/Manifest",
assetsenv.GlobRecursive("*", "resources", exclude="Manifest"),
assetsenv.GlobRecursive(
"*", assetsenv.Dir("resources").srcnode(), exclude="Manifest"
),
action=Action(
'${PYTHON3} "${ASSETS_COMPILER}" manifest "${TARGET.dir.posix}" --timestamp=${GIT_UNIX_TIMESTAMP}',
"${RESMANIFESTCOMSTR}",
@@ -1,32 +0,0 @@
Filetype: Flipper Animation
Version: 1
Width: 128
Height: 64
Passive frames: 9
Active frames: 13
Frames order: 0 1 2 3 4 5 2 3 4 10 6 7 8 7 8 7 8 7 8 9 10 11
Active cycles: 1
Frame rate: 2
Duration: 3600
Active cooldown: 7
Bubble slots: 1
Slot: 0
X: 57
Y: 24
Text: No mistakes,
AlignH: Left
AlignV: Center
StartFrame: 11
EndFrame: 14
Slot: 0
X: 57
Y: 21
Text: only happy\n accidents
AlignH: Left
AlignV: Center
StartFrame: 15
EndFrame: 18
-72
View File
@@ -1,72 +0,0 @@
Filetype: Flipper Animation Manifest
Version: 1
Name: Sasquach_Blaster_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 1
Max level: 30
Weight: 7
Name: Sasquach_Naruto_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 1
Max level: 30
Weight: 7
Name: Sasquach_RMCF_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 2
Max level: 30
Weight: 7
Name: Kuronons_RMCFW_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 2
Max level: 30
Weight: 7
Name: L3_Fireplace_128x64
Min butthurt: 0
Max butthurt: 13
Min level: 10
Max level: 30
Weight: 7
Name: L2_FlipperCity_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 2
Max level: 30
Weight: 7
Name: Sasquach_D1g1talRa1n_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 1
Max level: 30
Weight: 5
Name: L1_Purple_rain_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 1
Max level: 30
Weight: 5
Name: L1_Painting_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 1
Max level: 30
Weight: 3
Name: L1_Halloween_128x64
Min butthurt: 0
Max butthurt: 13
Min level: 1
Max level: 3
Weight: 8
+2 -2
View File
@@ -76,10 +76,10 @@ Each library is defined as a call to `Lib()` function, accepting the following p
- **name**: name of library's folder. Required.
- **fap_include_paths**: list of library's relative paths to add to parent fap's include path list. Default value is `["."]` meaning library's source root.
- **sources**: list of filename masks to be used for gathering include files for this library. Default value is `["*.c*"]`.
- **sources**: list of filename masks to be used for gathering include files for this library. Paths are relative to library's source root. Default value is `["*.c*"]`.
- **cflags**: list of additional compiler flags to be used for building this library. Default value is `[]`.
- **cdefines**: list of additional preprocessor definitions to be used for building this library. Default value is `[]`.
- **cincludes**: list of additional include paths to be used for building this library. Can be used for providing external search paths for this library's code - for configuration headers. Default value is `[]`.
- **cincludes**: list of additional include paths to be used for building this library. Paths are relative to application's root. Can be used for providing external search paths for this library's code - for configuration headers. Default value is `[]`.
Example for building an app with a private library:
+2 -1
View File
@@ -54,7 +54,8 @@ FBT keeps track of internal dependencies, so you only need to build the highest-
- `blackmagic` - debug firmware with Blackmagic probe (WiFi dev board)
- `openocd` - just start OpenOCD
- `get_blackmagic` - output blackmagic address in gdb remote format. Useful for IDE integration
- `lint`, `format` - run clang-tidy on C source code to check and reformat it according to `.clang-format` specs
- `get_stlink` - output serial numbers for attached STLink probes. Ued for `OPENOCD_ADAPTER_SERIAL=...`.
- `lint`, `format` - run clang-format on C source code to check and reformat it according to `.clang-format` specs
- `lint_py`, `format_py` - run [black](https://black.readthedocs.io/en/stable/index.html) on Python source code, build system files & application manifests
- `cli` - start Flipper CLI session over USB
+2 -1
View File
@@ -7,6 +7,7 @@ set -eu;
# private variables
SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd -P)";
SCONS_DEFAULT_FLAGS="-Q --warn=target-not-built";
SCONS_EP="python3 -m SCons"
# public variables
FBT_NOENV="${FBT_NOENV:-""}";
@@ -25,4 +26,4 @@ if [ -z "$FBT_NO_SYNC" ]; then
git submodule update --init;
fi
python3 "$SCRIPT_PATH/lib/scons/scripts/scons.py" $SCONS_DEFAULT_FLAGS "$@"
$SCONS_EP $SCONS_DEFAULT_FLAGS "$@"
+2 -2
View File
@@ -1,7 +1,7 @@
@echo off
call "%~dp0scripts\toolchain\fbtenv.cmd" env
set SCONS_EP=%~dp0\lib\scons\scripts\scons.py
set SCONS_EP=python -m SCons
if [%FBT_NO_SYNC%] == [] (
if exist ".git" (
@@ -13,4 +13,4 @@ if [%FBT_NO_SYNC%] == [] (
)
set "SCONS_DEFAULT_FLAGS=-Q --warn=target-not-built"
python lib\scons\scripts\scons.py %SCONS_DEFAULT_FLAGS% %*
%SCONS_EP% %SCONS_DEFAULT_FLAGS% %*
-2
View File
@@ -52,8 +52,6 @@ OPENOCD_OPTS = [
"debug/stm32wbx.cfg",
"-c",
"stm32wbx.cpu configure -rtos auto",
"-c",
"init",
]
SVD_FILE = "debug/STM32WB55_CM4.svd"
+6 -32
View File
@@ -86,21 +86,6 @@ env.AddMethod(ApplyLibFlags)
Export("env")
if not env["VERBOSE"]:
env.SetDefault(
HEXCOMSTR="\tHEX\t${TARGET}",
BINCOMSTR="\tBIN\t${TARGET}",
DFUCOMSTR="\tDFU\t${TARGET}",
SDK_PREGEN_COMSTR="\tPREGEN\t${TARGET}",
SDK_COMSTR="\tSDKSRC\t${TARGET}",
SDKSYM_UPDATER_COMSTR="\tSDKCHK\t${TARGET}",
SDKSYM_GENERATOR_COMSTR="\tSDKSYM\t${TARGET}",
APPMETA_COMSTR="\tAPPMETA\t${TARGET}",
APPMETAEMBED_COMSTR="\tFAP\t${TARGET}",
APPCHECK_COMSTR="\tAPPCHK\t${SOURCE}",
)
if env["IS_BASE_FIRMWARE"]:
env.Append(
FIRMWARE_BUILD_CFG="firmware",
@@ -149,9 +134,10 @@ fwenv.LoadApplicationManifests()
fwenv.PrepareApplicationsBuild()
# Build external apps
extapps = fwenv["FW_EXTAPPS"] = SConscript(
"site_scons/extapps.scons", exports={"ENV": fwenv}
)
if env["IS_BASE_FIRMWARE"]:
extapps = fwenv["FW_EXTAPPS"] = SConscript(
"site_scons/extapps.scons", exports={"ENV": fwenv}
)
# Add preprocessor definitions for current set of apps
@@ -306,21 +292,9 @@ Alias(fwenv["FIRMWARE_BUILD_CFG"] + "_all", fw_artifacts)
if fwenv["IS_BASE_FIRMWARE"]:
sdk_source = fwenv.SDKPrebuilder(
"sdk_origin",
[],
# Filtering out things cxxheaderparser cannot handle
SDK_PP_FLAGS=[
'-D"_Static_assert(x,y)="',
'-D"__asm__(x)="',
'-D"__attribute__(x)="',
"-Drestrict=",
"-D_Noreturn=",
"-D__restrict=",
"-D__extension__=",
"-D__inline=inline",
"-D__inline__=inline",
],
(fwenv["SDK_HEADERS"], fwenv["FW_ASSETS_HEADERS"]),
)
# Depends(sdk_source, (fwenv["SDK_HEADERS"], fwenv["FW_ASSETS_HEADERS"]))
# Extra deps for root headers and generated files
Depends(sdk_source, fwenv.ProcessSdkDepends("sdk_origin.d"))
fwenv["SDK_DIR"] = fwenv.Dir("sdk")
Submodule lib/scons deleted from c2d1f09f61
+16 -9
View File
@@ -7,6 +7,8 @@ from enum import Enum, auto
from typing import List, Set, ClassVar, Any
from dataclasses import dataclass, field
from ansi.color import fg
from cxxheaderparser.parser import CxxParser
@@ -394,21 +396,26 @@ class SdkCache:
if self._have_pending_entries():
self.new_entries.add(self.version)
print(
f"API version is still WIP: {self.version}. Review the changes and re-run command."
fg.red(
f"API version is still WIP: {self.version}. Review the changes and re-run command."
)
)
print(f"Entries to review:")
print(f"CSV file entries to mark up:")
print(
"\n".join(
map(
str,
filter(
lambda e: not isinstance(e, SdkVersion), self.new_entries
),
fg.yellow(
"\n".join(
map(
str,
filter(
lambda e: not isinstance(e, SdkVersion),
self.new_entries,
),
)
)
)
)
else:
print(f"API version {self.version} is up to date")
print(fg.green(f"API version {self.version} is up to date"))
regenerate_csv = (
self.loaded_dirty_version
+20 -10
View File
@@ -30,22 +30,25 @@ def dolphin_emitter(target, source, env):
res_root_dir = source[0].Dir(env["DOLPHIN_RES_TYPE"])
source = [res_root_dir]
source.extend(
env.GlobRecursive("*.*", res_root_dir),
env.GlobRecursive("*.*", res_root_dir.srcnode()),
)
target_base_dir = target[0]
env.Replace(_DOLPHIN_OUT_DIR=target[0])
if env["DOLPHIN_RES_TYPE"] == "external":
target = []
target.extend(
map(
lambda node: target_base_dir.File(
res_root_dir.rel_path(node).replace(".png", ".bm")
),
filter(lambda node: isinstance(node, SCons.Node.FS.File), source),
)
)
target = [target_base_dir.File("manifest.txt")]
## A detailed list of files to be generated
## works better if we just leave target the folder
# target = []
# target.extend(
# map(
# lambda node: target_base_dir.File(
# res_root_dir.rel_path(node).replace(".png", ".bm")
# ),
# filter(lambda node: isinstance(node, SCons.Node.FS.File), source),
# )
# )
else:
asset_basename = f"assets_dolphin_{env['DOLPHIN_RES_TYPE']}"
target = [
@@ -53,6 +56,13 @@ def dolphin_emitter(target, source, env):
target_base_dir.File(asset_basename + ".h"),
]
# Debug output
# print(
# f"Dolphin res type: {env['DOLPHIN_RES_TYPE']},\ntarget files:",
# list(f.path for f in target),
# f"\nsource files:",
# list(f.path for f in source),
# )
return target, source
+35
View File
@@ -1,4 +1,39 @@
from re import search
from SCons.Errors import UserError
from fbt_options import OPENOCD_OPTS
def _get_device_serials(search_str="STLink"):
import serial.tools.list_ports as list_ports
return set([device.serial_number for device in list_ports.grep(search_str)])
def GetDevices(env):
serials = _get_device_serials()
if len(serials) == 0:
raise UserError("No devices found")
print("\n".join(serials))
def generate(env, **kw):
env.AddMethod(GetDevices)
if (adapter_serial := env.subst("$OPENOCD_ADAPTER_SERIAL")) != "auto":
env.Append(
OPENOCD_OPTS=[
"-c",
f"adapter serial {adapter_serial}",
]
)
# Final command is "init", always explicitly added
env.Append(
OPENOCD_OPTS=["-c", "init"],
)
env.SetDefault(
OPENOCD_GDB_PIPE=[
"|openocd -c 'gdb_port pipe; log_output debug/openocd.log' ${[SINGLEQUOTEFUNC(OPENOCD_OPTS)]}"
+42 -2
View File
@@ -1,3 +1,4 @@
import shutil
from SCons.Builder import Builder
from SCons.Action import Action
from SCons.Errors import UserError
@@ -9,6 +10,7 @@ from fbt.elfmanifest import assemble_manifest_data
from fbt.appmanifest import FlipperApplication, FlipperManifestException
from fbt.sdk import SdkCache
import itertools
from ansi.color import fg
def BuildAppElf(env, app):
@@ -175,7 +177,8 @@ def validate_app_imports(target, source, env):
if unresolved_syms:
SCons.Warnings.warn(
SCons.Warnings.LinkWarning,
f"\033[93m{source[0].path}: app won't run. Unresolved symbols: \033[95m{unresolved_syms}\033[0m",
fg.brightyellow(f"{source[0].path}: app won't run. Unresolved symbols: ")
+ fg.brightmagenta(f"{unresolved_syms}"),
)
@@ -209,14 +212,51 @@ def GetExtAppFromPath(env, app_dir):
return (app, app_elf[0], app_validator[0])
def fap_dist_emitter(target, source, env):
target_dir = target[0]
target = []
for dist_entry in env["_extapps"]["dist"].values():
target.append(target_dir.Dir(dist_entry[0]).File(dist_entry[1][0].name))
for compact_entry in env["_extapps"]["compact"].values():
source.extend(compact_entry)
return (target, source)
def fap_dist_action(target, source, env):
# FIXME
target_dir = env.Dir("#/assets/resources/apps")
shutil.rmtree(target_dir.path, ignore_errors=True)
for src, target in zip(source, target):
os.makedirs(os.path.dirname(target.path), exist_ok=True)
shutil.copy(src.path, target.path)
def generate(env, **kw):
env.SetDefault(EXT_APPS_WORK_DIR=kw.get("EXT_APPS_WORK_DIR"))
# env.VariantDir(env.subst("$EXT_APPS_WORK_DIR"), env.Dir("#"), duplicate=False)
if not env["VERBOSE"]:
env.SetDefault(
FAPDISTCOMSTR="\tFAPDIST\t${TARGET}",
APPMETA_COMSTR="\tAPPMETA\t${TARGET}",
APPMETAEMBED_COMSTR="\tFAP\t${TARGET}",
APPCHECK_COMSTR="\tAPPCHK\t${SOURCE}",
)
env.AddMethod(BuildAppElf)
env.AddMethod(GetExtAppFromPath)
env.Append(
BUILDERS={
"FapDist": Builder(
action=Action(
fap_dist_action,
"$FAPDISTCOMSTR",
),
emitter=fap_dist_emitter,
),
"EmbedAppMetadata": Builder(
action=[
Action(prepare_app_metadata, "$APPMETA_COMSTR"),
+44 -28
View File
@@ -1,3 +1,4 @@
import shutil
from SCons.Builder import Builder
from SCons.Action import Action
from SCons.Errors import UserError
@@ -117,42 +118,30 @@ class SdkTreeBuilder:
target = [target_folder.File("sdk.opts")]
return target, source
def _create_deploy_commands(self):
def _run_deploy_commands(self):
dirs_to_create = set(
self.sdk_deploy_dir.Dir(dirpath) for dirpath in self.header_dirs
self.sdk_deploy_dir.Dir(dirpath).path for dirpath in self.header_dirs
)
actions = [
Delete(self.sdk_deploy_dir),
Mkdir(self.sdk_deploy_dir),
Copy(
self.sdk_root_dir,
self.env["SDK_DEFINITION"],
),
]
actions += [Mkdir(d) for d in dirs_to_create]
actions += [
Action(
Copy(self.sdk_deploy_dir.File(h).path, h),
# f"Copy {h} to {self.sdk_deploy_dir}",
)
for h in self.header_depends
]
return actions
shutil.rmtree(self.sdk_root_dir.path, ignore_errors=False)
def generate_actions(self):
for sdkdir in dirs_to_create:
os.makedirs(sdkdir, exist_ok=True)
shutil.copy2(self.env["SDK_DEFINITION"].path, self.sdk_root_dir.path)
for header in self.header_depends:
shutil.copy2(header, self.sdk_deploy_dir.File(header).path)
def deploy_action(self):
self._parse_sdk_depends()
self._run_deploy_commands()
self._generate_sdk_meta()
return self._create_deploy_commands()
def deploy_sdk_tree(target, source, env, for_signature):
if for_signature:
return []
def deploy_sdk_tree_action(target, source, env):
sdk_tree = SdkTreeBuilder(env, target, source)
return sdk_tree.generate_actions()
return sdk_tree.deploy_action()
def deploy_sdk_tree_emitter(target, source, env):
@@ -217,6 +206,30 @@ def generate_sdk_symbols(source, target, env):
def generate(env, **kw):
if not env["VERBOSE"]:
env.SetDefault(
SDK_PREGEN_COMSTR="\tPREGEN\t${TARGET}",
SDK_COMSTR="\tSDKSRC\t${TARGET}",
SDKSYM_UPDATER_COMSTR="\tSDKCHK\t${TARGET}",
SDKSYM_GENERATOR_COMSTR="\tSDKSYM\t${TARGET}",
SDKDEPLOY_COMSTR="\tSDKTREE\t${TARGET}",
)
# Filtering out things cxxheaderparser cannot handle
env.SetDefault(
SDK_PP_FLAGS=[
'-D"_Static_assert(x,y)="',
'-D"__asm__(x)="',
'-D"__attribute__(x)="',
"-Drestrict=",
"-D_Noreturn=",
"-D__restrict=",
"-D__extension__=",
"-D__inline=inline",
"-D__inline__=inline",
]
)
env.AddMethod(ProcessSdkDepends)
env.Append(
BUILDERS={
@@ -235,7 +248,10 @@ def generate(env, **kw):
suffix=".i",
),
"SDKTree": Builder(
generator=deploy_sdk_tree,
action=Action(
deploy_sdk_tree_action,
"$SDKDEPLOY_COMSTR",
),
emitter=deploy_sdk_tree_emitter,
src_suffix=".d",
),
+43
View File
@@ -0,0 +1,43 @@
import SCons.Warnings as Warnings
# from SCons.Script.Main import find_deepest_user_frame
from ansi.color import fg, bg, fx
import traceback
import sys
import os
def find_deepest_user_frame(tb):
tb.reverse()
# find the deepest traceback frame that is not part
# of SCons:
for frame in tb:
filename = frame[0]
if filename.find("fbt_tweaks") != -1:
continue
if filename.find(os.sep + "SCons" + os.sep) == -1:
return frame
return tb[0]
def fbt_warning(e):
filename, lineno, routine, dummy = find_deepest_user_frame(
traceback.extract_stack()
)
fbt_line = "\nfbt: warning: %s\n" % e.args[0]
sys.stderr.write(fg.boldmagenta(fbt_line))
fbt_line = (
fg.yellow("%s, line %d, " % (routine, lineno)) + 'in file "%s"\n' % filename
)
sys.stderr.write(fg.yellow(fbt_line))
def generate(env):
Warnings._warningOut = fbt_warning
def exists():
return True
+8
View File
@@ -12,6 +12,14 @@ def generate(env):
OBJCOPY=__OBJCOPY_ARM_BIN, # FIXME
NM=__NM_ARM_BIN, # FIXME
)
if not env["VERBOSE"]:
env.SetDefault(
HEXCOMSTR="\tHEX\t${TARGET}",
BINCOMSTR="\tBIN\t${TARGET}",
DFUCOMSTR="\tDFU\t${TARGET}",
)
env.Append(
BUILDERS={
"HEXBuilder": Builder(
-2
View File
@@ -6,8 +6,6 @@ def generate(env):
env.SetDefault(
GDB="gdb",
GDBPY="gdb-py",
GDBOPTS="",
GDBPYOPTS="",
GDBCOM="$GDB $GDBOPTS $SOURCES", # no $TARGET
GDBPYCOM="$GDBPY $GDBOPTS $GDBPYOPTS $SOURCES", # no $TARGET
)
+4 -1
View File
@@ -4,6 +4,7 @@ from flipper.app import App
import subprocess
import os
import math
from ansi.color import fg
class Main(App):
@@ -43,7 +44,9 @@ class Main(App):
pages = math.ceil(binsize / PAGE_SIZE)
last_page_state = (binsize % PAGE_SIZE) * 100 / PAGE_SIZE
print(
f"{os.path.basename(self.args.binname):<11}: {pages:>4} flash pages (last page {last_page_state:.02f}% full)"
fg.yellow(
f"{os.path.basename(self.args.binname):<11}: {pages:>4} flash pages (last page {last_page_state:.02f}% full)"
)
)
return 0
+5 -2
View File
@@ -7,6 +7,7 @@ from update import Main as UpdateMain
import shutil
import zipfile
import tarfile
from ansi.color import fg
class ProjectDir:
@@ -126,7 +127,7 @@ class Main(App):
self.copy_single_project(project)
self.logger.info(
f"Firmware binaries can be found at:\n\t{self.output_dir_path}"
fg.green(f"Firmware binaries can be found at:\n\t{self.output_dir_path}")
)
if self.args.version:
@@ -170,7 +171,9 @@ class Main(App):
if (bundle_result := UpdateMain(no_exit=True)(bundle_args)) == 0:
self.logger.info(
f"Use this directory to self-update your Flipper:\n\t{bundle_dir}"
fg.green(
f"Use this directory to self-update your Flipper:\n\t{bundle_dir}"
)
)
# Create tgz archive
+2 -2
View File
@@ -13,8 +13,8 @@ if not [%FBT_NOENV%] == [] (
exit /b 0
)
set "FLIPPER_TOOLCHAIN_VERSION=15"
set "FBT_TOOLCHAIN_ROOT=%FBT_ROOT%\toolchain\i686-windows"
set "FLIPPER_TOOLCHAIN_VERSION=16"
set "FBT_TOOLCHAIN_ROOT=%FBT_ROOT%\toolchain\x86_64-windows"
if not exist "%FBT_TOOLCHAIN_ROOT%" (
+1 -1
View File
@@ -5,7 +5,7 @@
# public variables
DEFAULT_SCRIPT_PATH="$(pwd -P)";
SCRIPT_PATH="${SCRIPT_PATH:-$DEFAULT_SCRIPT_PATH}";
FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"15"}";
FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"16"}";
FBT_TOOLCHAIN_PATH="${FBT_TOOLCHAIN_PATH:-$SCRIPT_PATH}";
fbtenv_show_usage()
@@ -3,13 +3,13 @@ $ErrorActionPreference = "Stop"
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
$repo_root = (Get-Item "$PSScriptRoot\..\..").FullName
$toolchain_version = $args[0]
$toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-i686-windows-flipper-$toolchain_version.zip"
$toolchain_zip = "gcc-arm-none-eabi-10.3-i686-windows-flipper-$toolchain_version.zip"
$toolchain_dir = "gcc-arm-none-eabi-10.3-i686-windows-flipper"
$toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-x86_64-windows-flipper-$toolchain_version.zip"
$toolchain_zip = "gcc-arm-none-eabi-10.3-x86_64-windows-flipper-$toolchain_version.zip"
$toolchain_dir = "gcc-arm-none-eabi-10.3-x86_64-windows-flipper"
if (Test-Path -LiteralPath "$repo_root\toolchain\i686-windows") {
if (Test-Path -LiteralPath "$repo_root\toolchain\x86_64-windows") {
Write-Host -NoNewline "Removing old Windows toolchain.."
Remove-Item -LiteralPath "$repo_root\toolchain\i686-windows" -Force -Recurse
Remove-Item -LiteralPath "$repo_root\toolchain\x86_64-windows" -Force -Recurse
Write-Host "done!"
}
if (!(Test-Path -Path "$repo_root\$toolchain_zip" -PathType Leaf)) {
@@ -26,7 +26,7 @@ if (!(Test-Path -LiteralPath "$repo_root\toolchain")) {
Write-Host -NoNewline "Unziping Windows toolchain.."
Add-Type -Assembly "System.IO.Compression.Filesystem"
[System.IO.Compression.ZipFile]::ExtractToDirectory("$toolchain_zip", "$repo_root\")
Move-Item -Path "$repo_root\$toolchain_dir" -Destination "$repo_root\toolchain\i686-windows"
Move-Item -Path "$repo_root\$toolchain_dir" -Destination "$repo_root\toolchain\x86_64-windows"
Write-Host "done!"
Write-Host -NoNewline "Clearing temporary files.."
+5
View File
@@ -176,6 +176,11 @@ vars.AddVariables(
"Blackmagic probe location",
"auto",
),
(
"OPENOCD_ADAPTER_SERIAL",
"OpenOCD adapter serial number",
"auto",
),
(
"UPDATE_SPLASH",
"Directory name with slideshow frames to render after installing update package",
+3 -1
View File
@@ -36,6 +36,7 @@ for env_value_name in variables_to_forward:
coreenv = VAR_ENV.Clone(
tools=[
"fbt_tweaks",
(
"crosscc",
{
@@ -81,8 +82,9 @@ if not coreenv["VERBOSE"]:
# Default value for commandline options
SetOption("num_jobs", multiprocessing.cpu_count())
## NB - disabled both caches since they seem to do more harm then good in our case
# Avoiding re-scan of all sources on every startup
SetOption("implicit_cache", True)
# SetOption("implicit_cache", True)
# SetOption("implicit_deps_unchanged", True)
# More aggressive caching
SetOption("max_drift", 1)
+3
View File
@@ -65,6 +65,7 @@ extapps = appenv["_extapps"] = {
"debug": {},
"validators": {},
"dist": {},
"resources_dist": None,
}
@@ -108,6 +109,8 @@ appenv.PhonyTarget("firmware_extapps", appenv.Action(legacy_app_build_stub, None
Alias("faps", extapps["compact"].values())
Alias("faps", extapps["validators"].values())
extapps["resources_dist"] = appenv.FapDist(appenv.Dir("#/assets/resources/apps"), [])
if appsrc := appenv.subst("$APPSRC"):
app_manifest, fap_file, app_validator = appenv.GetExtAppFromPath(appsrc)
appenv.PhonyTarget(
+3 -2
View File
@@ -1,10 +1,11 @@
from fbt.util import link_dir
from ansi.color import fg
def link_elf_dir_as_latest(env, elf_node):
elf_dir = elf_node.Dir(".")
latest_dir = env.Dir("#build/latest")
print(f"Setting {elf_dir} as latest built dir (./build/latest/)")
print(fg.green(f"Linking {elf_dir} as latest built dir (./build/latest/)"))
return link_dir(latest_dir.abspath, elf_dir.abspath, env["PLATFORM"] == "win32")
@@ -12,7 +13,7 @@ def should_gen_cdb_and_link_dir(env, requested_targets):
explicitly_building_updater = False
# Hacky way to check if updater-related targets were requested
for build_target in requested_targets:
if "updater" in str(build_target):
if "updater" in str(build_target) and "package" not in str(build_target):
explicitly_building_updater = True
is_updater = not env["IS_BASE_FIRMWARE"]
+8 -8
View File
@@ -3,6 +3,7 @@ from SCons.Script import GetBuildFailures
import sys
import os
import atexit
from ansi.color import fg, fx
sys.path.insert(0, os.path.join(os.getcwd(), "scripts"))
sys.path.insert(0, os.path.join(os.getcwd(), "lib/cxxheaderparser"))
@@ -16,12 +17,12 @@ def bf_to_str(bf):
if bf is None: # unknown targets product None in list
return "(unknown tgt)"
elif isinstance(bf, SCons.Errors.StopError):
return str(bf)
return fg.yellow(str(bf))
elif bf.node:
return str(bf.node) + ": " + bf.errstr
return fg.yellow(str(bf.node)) + ": " + bf.errstr
elif bf.filename:
return bf.filename + ": " + bf.errstr
return "unknown failure: " + bf.errstr
return fg.yellow(bf.filename) + ": " + bf.errstr
return fg.yellow("unknown failure: ") + bf.errstr
def display_build_status():
@@ -31,10 +32,9 @@ def display_build_status():
if bf:
# bf is normally a list of build failures; if an element is None,
# it's because of a target that scons doesn't know anything about.
failures_message = "\n".join(
["Failed building %s" % bf_to_str(x) for x in bf if x is not None]
)
print("*" * 10, "ERRORS", "*" * 10)
failures_message = "\n".join([bf_to_str(x) for x in bf if x is not None])
print()
print(fg.brightred(fx.bold("*" * 10 + " FBT ERRORS " + "*" * 10)))
print(failures_message)