[FL-3174] Dolphin builder in ufbt; minor ufbt/fbt improvements (#2601)

* ufbt: added "dolphin_ext" target (expects "external" subfolder in cwd with dolphin assets); cleaned up unused code
* ufbt: codestyle fixes
* scripts: fixed style according to ruff linter
* scripts: additional cleanup & codestyle fixes
* github: pass target hw code when installing local SDK with ufbt
* ufbt: added error message for missing folder in dolphin builder
* scripts: more linter fixes
* sdk: added flipper_format_stream; ufbt: support for --extra-define
* fbt: reduced amount of global defines
* scripts, fbt: rearranged imports

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
hedger
2023-05-03 08:48:49 +03:00
committed by GitHub
parent 015ab4a024
commit c3ececcf96
73 changed files with 311 additions and 382 deletions

View File

@@ -1,7 +1,6 @@
from SCons.Platform import TempFileMunge
from SCons.Node import FS
from SCons.Errors import UserError
from SCons.Warnings import warn, WarningOnByDefault
import os
@@ -14,6 +13,7 @@ SetOption("max_drift", 1)
ufbt_state_dir = Dir(os.environ.get("UFBT_STATE_DIR", "#.ufbt"))
ufbt_script_dir = Dir(os.environ.get("UFBT_SCRIPT_DIR"))
ufbt_build_dir = ufbt_state_dir.Dir("build")
ufbt_current_sdk_dir = ufbt_state_dir.Dir("current")
@@ -63,16 +63,7 @@ core_env = Environment(
],
)
if "update" in BUILD_TARGETS:
SConscript(
"update.scons",
exports={"core_env": core_env},
)
if "purge" in BUILD_TARGETS:
core_env.Execute(Delete(ufbt_state_dir))
print("uFBT state purged")
Exit(0)
core_env.Append(CPPDEFINES=GetOption("extra_defines"))
# Now we can import stuff bundled with SDK - it was added to sys.path by ufbt_state
@@ -109,7 +100,7 @@ env = core_env.Clone(
"fbt_assets",
("compilation_db", {"COMPILATIONDB_COMSTR": "\tCDB\t${TARGET}"}),
],
FBT_FAP_DEBUG_ELF_ROOT=ufbt_state_dir.Dir("build"),
FBT_FAP_DEBUG_ELF_ROOT=ufbt_build_dir,
TEMPFILE=TempFileMunge,
MAXLINELENGTH=2048,
PROGSUFFIX=".elf",
@@ -427,3 +418,25 @@ dist_env.PhonyTarget(
"get_apiversion",
"@echo $( ${UFBT_API_VERSION} $)",
)
# Dolphin animation builder. Expects "external" directory in current dir
# with animation sources & manifests. Builds & uploads them to connected Flipper
dolphin_src_dir = original_app_dir.Dir("external")
if dolphin_src_dir.exists():
dolphin_dir = ufbt_build_dir.Dir("dolphin")
dolphin_external = dist_env.DolphinExtBuilder(
ufbt_build_dir.Dir("dolphin"),
original_app_dir,
DOLPHIN_RES_TYPE="external",
)
dist_env.PhonyTarget(
"dolphin_ext",
'${PYTHON3} ${FBT_SCRIPT_DIR}/storage.py send "${SOURCE}" /ext/dolphin',
source=ufbt_build_dir.Dir("dolphin"),
)
else:
def missing_dolphin_folder(**kw):
raise UserError(f"Dolphin folder not found: {dolphin_src_dir}")
dist_env.PhonyTarget("dolphin_ext", Action(missing_dolphin_folder, None))