mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-27 01:58:09 -07:00
[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:
+25
-12
@@ -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))
|
||||
|
||||
@@ -1,32 +1,18 @@
|
||||
AddOption(
|
||||
"--extra-define",
|
||||
action="append",
|
||||
dest="extra_defines",
|
||||
default=[],
|
||||
help="Extra global define that will be passed to C/C++ compiler, can be specified multiple times",
|
||||
)
|
||||
|
||||
AddOption(
|
||||
"--proxy-env",
|
||||
action="store",
|
||||
dest="proxy_env",
|
||||
default="",
|
||||
help="Comma-separated list of additional environment variables to pass to child SCons processes",
|
||||
)
|
||||
|
||||
AddOption(
|
||||
"--channel",
|
||||
action="store",
|
||||
dest="sdk_channel",
|
||||
choices=["dev", "rc", "release"],
|
||||
default="",
|
||||
help="Release channel to use for SDK",
|
||||
)
|
||||
|
||||
AddOption(
|
||||
"--branch",
|
||||
action="store",
|
||||
dest="sdk_branch",
|
||||
help="Custom main repo branch to use for SDK",
|
||||
)
|
||||
|
||||
AddOption(
|
||||
"--hw-target",
|
||||
action="store",
|
||||
dest="sdk_target",
|
||||
help="SDK Hardware target",
|
||||
help="Comma-separated list of additional environment variables to pass to "
|
||||
"child SCons processes",
|
||||
)
|
||||
|
||||
vars = Variables("ufbt_options.py", ARGUMENTS)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from SCons.Script import GetBuildFailures
|
||||
import SCons.Errors
|
||||
|
||||
import atexit
|
||||
|
||||
import SCons.Errors
|
||||
from ansi.color import fg, fx
|
||||
from SCons.Script import GetBuildFailures
|
||||
|
||||
|
||||
def bf_to_str(bf):
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
from SCons.Errors import StopError
|
||||
from SCons.Warnings import warn, WarningOnByDefault
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import pathlib
|
||||
import sys
|
||||
from functools import reduce
|
||||
|
||||
from SCons.Errors import StopError
|
||||
|
||||
|
||||
def _load_sdk_data(sdk_root):
|
||||
split_vars = {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
from SCons.Errors import StopError
|
||||
|
||||
Import("core_env")
|
||||
|
||||
update_env = core_env.Clone(
|
||||
toolpath=[core_env["FBT_SCRIPT_DIR"].Dir("fbt_tools")],
|
||||
tools=["python3"],
|
||||
)
|
||||
print("Updating SDK...")
|
||||
ufbt_state = update_env["UFBT_STATE"]
|
||||
|
||||
update_args = [
|
||||
"--ufbt-dir",
|
||||
f'"{update_env["UFBT_STATE_DIR"]}"',
|
||||
]
|
||||
|
||||
if branch_name := GetOption("sdk_branch"):
|
||||
update_args.extend(["--branch", branch_name])
|
||||
elif channel_name := GetOption("sdk_channel"):
|
||||
update_args.extend(["--channel", channel_name])
|
||||
elif branch_name := ufbt_state.get("branch", None):
|
||||
update_args.extend(["--branch", branch_name])
|
||||
elif channel_name := ufbt_state.get("channel", None):
|
||||
update_args.extend(["--channel", channel_name])
|
||||
else:
|
||||
raise StopError("No branch or channel specified for SDK update")
|
||||
|
||||
if hw_target := GetOption("sdk_target"):
|
||||
update_args.extend(["--hw-target", hw_target])
|
||||
else:
|
||||
update_args.extend(["--hw-target", ufbt_state["hw_target"]])
|
||||
|
||||
update_env.Replace(UPDATE_ARGS=update_args)
|
||||
result = update_env.Execute(
|
||||
update_env.subst('$PYTHON3 "$UFBT_BOOTSTRAP_SCRIPT" $UPDATE_ARGS'),
|
||||
)
|
||||
Exit(result)
|
||||
Reference in New Issue
Block a user