2023-04-06 02:44:37 +00:00
|
|
|
import multiprocessing
|
2023-08-10 16:21:56 +00:00
|
|
|
import os
|
2023-04-06 02:44:37 +00:00
|
|
|
import pathlib
|
|
|
|
|
2023-08-10 16:21:56 +00:00
|
|
|
from SCons.Errors import UserError
|
|
|
|
from SCons.Node import FS
|
|
|
|
from SCons.Platform import TempFileMunge
|
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
SetOption("num_jobs", multiprocessing.cpu_count())
|
|
|
|
SetOption("max_drift", 1)
|
|
|
|
# SetOption("silent", False)
|
|
|
|
|
|
|
|
ufbt_state_dir = Dir(os.environ.get("UFBT_STATE_DIR", "#.ufbt"))
|
|
|
|
ufbt_script_dir = Dir(os.environ.get("UFBT_SCRIPT_DIR"))
|
2023-05-03 05:48:49 +00:00
|
|
|
ufbt_build_dir = ufbt_state_dir.Dir("build")
|
2023-04-06 02:44:37 +00:00
|
|
|
|
|
|
|
ufbt_current_sdk_dir = ufbt_state_dir.Dir("current")
|
|
|
|
|
|
|
|
SConsignFile(ufbt_state_dir.File(".sconsign.dblite").abspath)
|
|
|
|
|
|
|
|
ufbt_variables = SConscript("commandline.scons")
|
|
|
|
|
|
|
|
forward_os_env = {
|
|
|
|
# Import PATH from OS env - scons doesn't do that by default
|
|
|
|
"PATH": os.environ["PATH"],
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Core environment init - loads SDK state, sets up paths, etc.
|
|
|
|
core_env = Environment(
|
|
|
|
variables=ufbt_variables,
|
|
|
|
UFBT_STATE_DIR=ufbt_state_dir,
|
|
|
|
UFBT_CURRENT_SDK_DIR=ufbt_current_sdk_dir,
|
|
|
|
UFBT_SCRIPT_DIR=ufbt_script_dir,
|
|
|
|
toolpath=[ufbt_current_sdk_dir.Dir("scripts/ufbt/site_tools")],
|
|
|
|
tools=[
|
|
|
|
"ufbt_state",
|
|
|
|
("ufbt_help", {"vars": ufbt_variables}),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-05-03 05:48:49 +00:00
|
|
|
core_env.Append(CPPDEFINES=GetOption("extra_defines"))
|
2023-04-06 02:44:37 +00:00
|
|
|
|
|
|
|
# Now we can import stuff bundled with SDK - it was added to sys.path by ufbt_state
|
|
|
|
|
2023-08-10 16:21:56 +00:00
|
|
|
from fbt.appmanifest import FlipperApplication, FlipperAppType
|
|
|
|
from fbt.sdk.cache import SdkCache
|
2023-04-06 02:44:37 +00:00
|
|
|
from fbt.util import (
|
2023-12-19 12:43:06 +00:00
|
|
|
FORWARDED_ENV_VARIABLES,
|
2023-08-10 16:21:56 +00:00
|
|
|
path_as_posix,
|
|
|
|
resolve_real_dir_node,
|
2023-04-06 02:44:37 +00:00
|
|
|
single_quote,
|
2023-08-10 16:21:56 +00:00
|
|
|
tempfile_arg_esc_func,
|
2023-04-06 02:44:37 +00:00
|
|
|
wrap_tempfile,
|
|
|
|
)
|
|
|
|
|
2023-12-19 12:43:06 +00:00
|
|
|
variables_to_forward = list(FORWARDED_ENV_VARIABLES)
|
|
|
|
|
|
|
|
if proxy_env := GetOption("proxy_env"):
|
|
|
|
variables_to_forward.extend(proxy_env.split(","))
|
|
|
|
|
|
|
|
for env_value_name in variables_to_forward:
|
|
|
|
if environ_value := os.environ.get(env_value_name, None):
|
|
|
|
forward_os_env[env_value_name] = environ_value
|
|
|
|
|
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
# Base environment with all tools loaded from SDK
|
|
|
|
env = core_env.Clone(
|
2023-12-19 12:43:06 +00:00
|
|
|
ENV=forward_os_env,
|
2023-04-06 02:44:37 +00:00
|
|
|
toolpath=[core_env["FBT_SCRIPT_DIR"].Dir("fbt_tools")],
|
|
|
|
tools=[
|
|
|
|
"fbt_tweaks",
|
|
|
|
(
|
|
|
|
"crosscc",
|
|
|
|
{
|
|
|
|
"toolchain_prefix": "arm-none-eabi-",
|
|
|
|
"versions": (" 10.3",),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
"fwbin",
|
|
|
|
"python3",
|
|
|
|
"sconsrecursiveglob",
|
|
|
|
"sconsmodular",
|
|
|
|
"ccache",
|
|
|
|
"fbt_apps",
|
|
|
|
"fbt_extapps",
|
|
|
|
"fbt_assets",
|
2023-05-29 16:40:56 +00:00
|
|
|
"fbt_envhooks",
|
2023-04-06 02:44:37 +00:00
|
|
|
("compilation_db", {"COMPILATIONDB_COMSTR": "\tCDB\t${TARGET}"}),
|
|
|
|
],
|
2023-05-03 05:48:49 +00:00
|
|
|
FBT_FAP_DEBUG_ELF_ROOT=ufbt_build_dir,
|
2023-04-06 02:44:37 +00:00
|
|
|
TEMPFILE=TempFileMunge,
|
|
|
|
MAXLINELENGTH=2048,
|
|
|
|
PROGSUFFIX=".elf",
|
|
|
|
TEMPFILEARGESCFUNC=tempfile_arg_esc_func,
|
|
|
|
SINGLEQUOTEFUNC=single_quote,
|
2023-08-10 16:21:56 +00:00
|
|
|
ABSPATHGETTERFUNC=resolve_real_dir_node,
|
2023-04-06 02:44:37 +00:00
|
|
|
APPS=[],
|
2023-09-05 11:49:39 +00:00
|
|
|
EXTRA_EXT_APPS=[],
|
2023-04-06 02:44:37 +00:00
|
|
|
UFBT_API_VERSION=SdkCache(
|
|
|
|
core_env.subst("$SDK_DEFINITION"), load_version_only=True
|
|
|
|
).version,
|
|
|
|
APPCHECK_COMSTR="\tAPPCHK\t${SOURCE}\n\t\tTarget: ${TARGET_HW}, API: ${UFBT_API_VERSION}",
|
|
|
|
)
|
|
|
|
|
|
|
|
wrap_tempfile(env, "LINKCOM")
|
|
|
|
wrap_tempfile(env, "ARCOM")
|
|
|
|
|
2023-05-29 16:40:56 +00:00
|
|
|
env.PreConfigureUfbtEnvionment()
|
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
# print(env.Dump())
|
|
|
|
|
|
|
|
# Dist env
|
|
|
|
|
|
|
|
dist_env = env.Clone(
|
|
|
|
tools=[
|
|
|
|
"fbt_dist",
|
|
|
|
"fbt_debugopts",
|
|
|
|
"openocd",
|
|
|
|
"blackmagic",
|
|
|
|
"jflash",
|
|
|
|
"textfile",
|
|
|
|
],
|
|
|
|
ENV=os.environ,
|
|
|
|
OPENOCD_OPTS=[
|
|
|
|
"-f",
|
|
|
|
"interface/stlink.cfg",
|
|
|
|
"-c",
|
|
|
|
"transport select hla_swd",
|
|
|
|
"-f",
|
|
|
|
"${FBT_DEBUG_DIR}/stm32wbx.cfg",
|
|
|
|
"-c",
|
|
|
|
"stm32wbx.cpu configure -rtos auto",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-08-22 18:33:10 +00:00
|
|
|
flash_target = dist_env.FwFlash(
|
2023-04-06 02:44:37 +00:00
|
|
|
dist_env["UFBT_STATE_DIR"].File("flash"),
|
2023-08-22 18:33:10 +00:00
|
|
|
dist_env["FW_ELF"],
|
2023-04-06 02:44:37 +00:00
|
|
|
)
|
2023-08-22 18:33:10 +00:00
|
|
|
dist_env.Alias("firmware_flash", flash_target)
|
|
|
|
dist_env.Alias("flash", flash_target)
|
2023-04-06 02:44:37 +00:00
|
|
|
if env["FORCE"]:
|
2023-08-22 18:33:10 +00:00
|
|
|
env.AlwaysBuild(flash_target)
|
2023-04-06 02:44:37 +00:00
|
|
|
|
2023-04-10 14:46:22 +00:00
|
|
|
|
|
|
|
firmware_jflash = dist_env.JFlash(
|
|
|
|
dist_env["UFBT_STATE_DIR"].File("jflash"),
|
|
|
|
dist_env["FW_BIN"],
|
2023-08-22 18:33:10 +00:00
|
|
|
JFLASHADDR="0x08000000",
|
2023-04-10 14:46:22 +00:00
|
|
|
)
|
|
|
|
dist_env.Alias("firmware_jflash", firmware_jflash)
|
|
|
|
dist_env.Alias("jflash", firmware_jflash)
|
|
|
|
if env["FORCE"]:
|
|
|
|
env.AlwaysBuild(firmware_jflash)
|
|
|
|
|
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
firmware_debug = dist_env.PhonyTarget(
|
|
|
|
"debug",
|
|
|
|
"${GDBPYCOM}",
|
|
|
|
source=dist_env["FW_ELF"],
|
|
|
|
GDBOPTS="${GDBOPTS_BASE}",
|
|
|
|
GDBREMOTE="${OPENOCD_GDB_PIPE}",
|
|
|
|
FBT_FAP_DEBUG_ELF_ROOT=path_as_posix(dist_env.subst("$FBT_FAP_DEBUG_ELF_ROOT")),
|
|
|
|
)
|
|
|
|
|
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"blackmagic",
|
|
|
|
"${GDBPYCOM}",
|
|
|
|
source=dist_env["FW_ELF"],
|
|
|
|
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
|
|
|
|
GDBREMOTE="${BLACKMAGIC_ADDR}",
|
|
|
|
FBT_FAP_DEBUG_ELF_ROOT=path_as_posix(dist_env.subst("$FBT_FAP_DEBUG_ELF_ROOT")),
|
|
|
|
)
|
|
|
|
|
2023-05-08 23:31:44 +00:00
|
|
|
# Debug alien elf
|
|
|
|
debug_other_opts = [
|
|
|
|
"-ex",
|
|
|
|
"source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py",
|
|
|
|
"-ex",
|
|
|
|
"source ${FBT_DEBUG_DIR}/flipperversion.py",
|
|
|
|
"-ex",
|
|
|
|
"fw-version",
|
|
|
|
]
|
|
|
|
|
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"debug_other",
|
|
|
|
"${GDBPYCOM}",
|
|
|
|
GDBOPTS="${GDBOPTS_BASE}",
|
|
|
|
GDBREMOTE="${OPENOCD_GDB_PIPE}",
|
|
|
|
GDBPYOPTS=debug_other_opts,
|
|
|
|
)
|
|
|
|
|
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"debug_other_blackmagic",
|
|
|
|
"${GDBPYCOM}",
|
|
|
|
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
|
|
|
|
GDBREMOTE="${BLACKMAGIC_ADDR}",
|
|
|
|
GDBPYOPTS=debug_other_opts,
|
|
|
|
)
|
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
flash_usb_full = dist_env.UsbInstall(
|
|
|
|
dist_env["UFBT_STATE_DIR"].File("usbinstall"),
|
|
|
|
[],
|
|
|
|
)
|
|
|
|
dist_env.AlwaysBuild(flash_usb_full)
|
|
|
|
dist_env.Alias("flash_usb", flash_usb_full)
|
|
|
|
dist_env.Alias("flash_usb_full", flash_usb_full)
|
|
|
|
|
|
|
|
# App build environment
|
|
|
|
|
|
|
|
appenv = env.Clone(
|
|
|
|
CCCOM=env["CCCOM"].replace("$CFLAGS", "$CFLAGS_APP $CFLAGS"),
|
|
|
|
CXXCOM=env["CXXCOM"].replace("$CXXFLAGS", "$CXXFLAGS_APP $CXXFLAGS"),
|
|
|
|
LINKCOM=env["LINKCOM"].replace("$LINKFLAGS", "$LINKFLAGS_APP $LINKFLAGS"),
|
|
|
|
COMPILATIONDB_USE_ABSPATH=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
original_app_dir = Dir(appenv.subst("$UFBT_APP_DIR"))
|
|
|
|
app_mount_point = Dir("#/app/")
|
|
|
|
app_mount_point.addRepository(original_app_dir)
|
|
|
|
|
|
|
|
appenv.LoadAppManifest(app_mount_point)
|
|
|
|
appenv.PrepareApplicationsBuild()
|
|
|
|
|
|
|
|
#######################
|
|
|
|
|
|
|
|
apps_artifacts = appenv["EXT_APPS"]
|
|
|
|
|
|
|
|
apps_to_build_as_faps = [
|
|
|
|
FlipperAppType.PLUGIN,
|
|
|
|
FlipperAppType.EXTERNAL,
|
2023-07-10 08:03:41 +00:00
|
|
|
FlipperAppType.MENUEXTERNAL,
|
2023-04-06 02:44:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
known_extapps = [
|
|
|
|
app
|
|
|
|
for apptype in apps_to_build_as_faps
|
|
|
|
for app in appenv["APPBUILD"].get_apps_of_type(apptype, True)
|
|
|
|
]
|
2023-04-19 11:08:13 +00:00
|
|
|
incompatible_apps = []
|
2023-04-06 02:44:37 +00:00
|
|
|
for app in known_extapps:
|
2023-04-19 11:08:13 +00:00
|
|
|
if not app.supports_hardware_target(appenv.subst("f${TARGET_HW}")):
|
|
|
|
incompatible_apps.append(app)
|
|
|
|
continue
|
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
app_artifacts = appenv.BuildAppElf(app)
|
2023-08-10 16:21:56 +00:00
|
|
|
app_src_dir = resolve_real_dir_node(app_artifacts.app._appdir)
|
2023-04-06 02:44:37 +00:00
|
|
|
app_artifacts.installer = [
|
|
|
|
appenv.Install(app_src_dir.Dir("dist"), app_artifacts.compact),
|
|
|
|
appenv.Install(app_src_dir.Dir("dist").Dir("debug"), app_artifacts.debug),
|
|
|
|
]
|
|
|
|
|
2023-04-19 11:08:13 +00:00
|
|
|
if len(incompatible_apps):
|
|
|
|
print(
|
|
|
|
"WARNING: The following apps are not compatible with the current target hardware and will not be built: {}".format(
|
|
|
|
", ".join([app.name for app in incompatible_apps])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
if appenv["FORCE"]:
|
|
|
|
appenv.AlwaysBuild([extapp.compact for extapp in apps_artifacts.values()])
|
|
|
|
|
|
|
|
# Final steps - target aliases
|
|
|
|
|
|
|
|
install_and_check = [
|
|
|
|
(extapp.installer, extapp.validator) for extapp in apps_artifacts.values()
|
|
|
|
]
|
|
|
|
Alias(
|
|
|
|
"faps",
|
|
|
|
install_and_check,
|
|
|
|
)
|
|
|
|
Default(install_and_check)
|
|
|
|
|
|
|
|
# Compilation database
|
|
|
|
|
|
|
|
fwcdb = appenv.CompilationDatabase(
|
|
|
|
original_app_dir.Dir(".vscode").File("compile_commands.json")
|
|
|
|
)
|
|
|
|
|
|
|
|
AlwaysBuild(fwcdb)
|
|
|
|
Precious(fwcdb)
|
|
|
|
NoClean(fwcdb)
|
|
|
|
if len(apps_artifacts):
|
|
|
|
Default(fwcdb)
|
|
|
|
|
|
|
|
|
|
|
|
# launch handler
|
|
|
|
runnable_apps = appenv["APPBUILD"].get_apps_of_type(FlipperAppType.EXTERNAL, True)
|
|
|
|
|
|
|
|
app_to_launch = None
|
|
|
|
if len(runnable_apps) == 1:
|
|
|
|
app_to_launch = runnable_apps[0].appid
|
|
|
|
elif len(runnable_apps) > 1:
|
|
|
|
# more than 1 app - try to find one with matching id
|
|
|
|
app_to_launch = appenv.subst("$APPID")
|
|
|
|
|
|
|
|
|
|
|
|
def ambiguous_app_call(**kw):
|
|
|
|
raise UserError(
|
|
|
|
f"More than one app is runnable: {', '.join(app.appid for app in runnable_apps)}. Please specify an app with APPID=..."
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if app_to_launch:
|
|
|
|
appenv.AddAppLaunchTarget(app_to_launch, "launch")
|
2023-07-18 09:39:30 +00:00
|
|
|
appenv.AddAppBuildTarget(app_to_launch, "build")
|
2023-04-06 02:44:37 +00:00
|
|
|
else:
|
|
|
|
dist_env.PhonyTarget("launch", Action(ambiguous_app_call, None))
|
2023-07-18 09:39:30 +00:00
|
|
|
dist_env.PhonyTarget("build", Action(ambiguous_app_call, None))
|
2023-04-06 02:44:37 +00:00
|
|
|
|
|
|
|
# cli handler
|
|
|
|
|
|
|
|
appenv.PhonyTarget(
|
|
|
|
"cli",
|
2023-11-15 16:27:35 +00:00
|
|
|
[["${PYTHON3}", "${FBT_SCRIPT_DIR}/serial_cli.py", "-p", "${FLIP_PORT}"]],
|
2023-04-06 02:44:37 +00:00
|
|
|
)
|
|
|
|
|
2023-08-10 12:29:44 +00:00
|
|
|
# Update WiFi devboard firmware
|
2023-11-15 16:27:35 +00:00
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"devboard_flash", [["${PYTHON3}", "${FBT_SCRIPT_DIR}/wifi_board.py"]]
|
|
|
|
)
|
2023-08-10 12:29:44 +00:00
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
# Linter
|
|
|
|
|
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"lint",
|
2023-11-15 16:27:35 +00:00
|
|
|
[["${PYTHON3}", "${FBT_SCRIPT_DIR}/lint.py", "check", "${LINT_SOURCES}"]],
|
2023-04-06 02:44:37 +00:00
|
|
|
source=original_app_dir.File(".clang-format"),
|
|
|
|
LINT_SOURCES=[original_app_dir],
|
|
|
|
)
|
|
|
|
|
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"format",
|
2023-11-15 16:27:35 +00:00
|
|
|
[["${PYTHON3}", "${FBT_SCRIPT_DIR}/lint.py", "format", "${LINT_SOURCES}"]],
|
2023-04-06 02:44:37 +00:00
|
|
|
source=original_app_dir.File(".clang-format"),
|
|
|
|
LINT_SOURCES=[original_app_dir],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Prepare vscode environment
|
|
|
|
def _path_as_posix(path):
|
|
|
|
return pathlib.Path(path).as_posix()
|
|
|
|
|
|
|
|
|
|
|
|
vscode_dist = []
|
|
|
|
project_template_dir = dist_env["UFBT_SCRIPT_ROOT"].Dir("project_template")
|
|
|
|
for template_file in project_template_dir.Dir(".vscode").glob("*"):
|
|
|
|
vscode_dist.append(
|
|
|
|
dist_env.Substfile(
|
|
|
|
original_app_dir.Dir(".vscode").File(template_file.name),
|
|
|
|
template_file,
|
|
|
|
SUBST_DICT={
|
|
|
|
"@UFBT_VSCODE_PATH_SEP@": os.path.pathsep,
|
|
|
|
"@UFBT_TOOLCHAIN_ARM_TOOLCHAIN_DIR@": pathlib.Path(
|
|
|
|
dist_env.WhereIs("arm-none-eabi-gcc")
|
|
|
|
).parent.as_posix(),
|
|
|
|
"@UFBT_TOOLCHAIN_GCC@": _path_as_posix(
|
|
|
|
dist_env.WhereIs("arm-none-eabi-gcc")
|
|
|
|
),
|
|
|
|
"@UFBT_TOOLCHAIN_GDB_PY@": _path_as_posix(
|
|
|
|
dist_env.WhereIs("arm-none-eabi-gdb-py")
|
|
|
|
),
|
|
|
|
"@UFBT_TOOLCHAIN_OPENOCD@": _path_as_posix(dist_env.WhereIs("openocd")),
|
|
|
|
"@UFBT_APP_DIR@": _path_as_posix(original_app_dir.abspath),
|
|
|
|
"@UFBT_ROOT_DIR@": _path_as_posix(Dir("#").abspath),
|
2024-01-10 11:37:28 +00:00
|
|
|
"@UFBT_DEBUG_DIR@": _path_as_posix(dist_env["FBT_DEBUG_DIR"].abspath),
|
2023-04-06 02:44:37 +00:00
|
|
|
"@UFBT_DEBUG_ELF_DIR@": _path_as_posix(
|
|
|
|
dist_env["FBT_FAP_DEBUG_ELF_ROOT"].abspath
|
|
|
|
),
|
|
|
|
"@UFBT_FIRMWARE_ELF@": _path_as_posix(dist_env["FW_ELF"].abspath),
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
for config_file in project_template_dir.glob(".*"):
|
|
|
|
if isinstance(config_file, FS.Dir):
|
|
|
|
continue
|
|
|
|
vscode_dist.append(dist_env.Install(original_app_dir, config_file))
|
|
|
|
|
|
|
|
dist_env.Precious(vscode_dist)
|
|
|
|
dist_env.NoClean(vscode_dist)
|
|
|
|
dist_env.Alias("vscode_dist", vscode_dist)
|
|
|
|
|
|
|
|
|
|
|
|
# Creating app from base template
|
|
|
|
|
|
|
|
dist_env.SetDefault(FBT_APPID=appenv.subst("$APPID") or "template")
|
2023-06-07 02:14:33 +00:00
|
|
|
if fbt_appid := dist_env.subst("$FBT_APPID"):
|
|
|
|
if not FlipperApplication.APP_ID_REGEX.match(fbt_appid):
|
|
|
|
raise UserError(
|
|
|
|
f"Invalid app id '{fbt_appid}'. App id must match {FlipperApplication.APP_ID_REGEX.pattern}"
|
|
|
|
)
|
|
|
|
|
2023-05-08 11:01:52 +00:00
|
|
|
app_template_dir = project_template_dir.Dir("app_template")
|
2023-04-06 02:44:37 +00:00
|
|
|
app_template_dist = []
|
2023-05-08 11:01:52 +00:00
|
|
|
for template_file in app_template_dir.glob("*"):
|
2023-04-06 02:44:37 +00:00
|
|
|
dist_file_name = dist_env.subst(template_file.name)
|
|
|
|
if template_file.name.endswith(".png"):
|
|
|
|
app_template_dist.append(
|
|
|
|
dist_env.InstallAs(original_app_dir.File(dist_file_name), template_file)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
app_template_dist.append(
|
|
|
|
dist_env.Substfile(
|
|
|
|
original_app_dir.File(dist_file_name),
|
|
|
|
template_file,
|
|
|
|
SUBST_DICT={
|
|
|
|
"@FBT_APPID@": dist_env.subst("$FBT_APPID"),
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
AddPostAction(
|
|
|
|
app_template_dist[-1],
|
|
|
|
[
|
|
|
|
Mkdir(original_app_dir.Dir("images")),
|
|
|
|
Touch(original_app_dir.Dir("images").File(".gitkeep")),
|
2023-05-08 11:01:52 +00:00
|
|
|
# scons' glob ignores .dot directories, so we need to copy .github manually
|
|
|
|
Copy(original_app_dir.Dir(".github"), app_template_dir.Dir(".github")),
|
2023-04-06 02:44:37 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
dist_env.Precious(app_template_dist)
|
|
|
|
dist_env.NoClean(app_template_dist)
|
|
|
|
dist_env.Alias("create", app_template_dist)
|
2023-04-10 14:46:22 +00:00
|
|
|
|
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"get_blackmagic",
|
|
|
|
"@echo $( ${BLACKMAGIC_ADDR} $)",
|
|
|
|
)
|
|
|
|
|
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"get_apiversion",
|
|
|
|
"@echo $( ${UFBT_API_VERSION} $)",
|
|
|
|
)
|
2023-05-03 05:48:49 +00:00
|
|
|
|
|
|
|
# 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",
|
2023-11-15 16:27:35 +00:00
|
|
|
[
|
|
|
|
[
|
|
|
|
"${PYTHON3}",
|
|
|
|
"${FBT_SCRIPT_DIR}/storage.py",
|
|
|
|
"-p",
|
|
|
|
"${FLIP_PORT}",
|
|
|
|
"send",
|
|
|
|
"${SOURCE}",
|
|
|
|
"/ext/dolphin",
|
|
|
|
]
|
|
|
|
],
|
2023-05-03 05:48:49 +00:00
|
|
|
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))
|
2023-05-08 11:01:52 +00:00
|
|
|
|
2023-12-19 12:43:06 +00:00
|
|
|
# print(env.Dump())
|
2023-05-08 11:01:52 +00:00
|
|
|
dist_env.PhonyTarget(
|
|
|
|
"env",
|
2023-12-19 12:43:06 +00:00
|
|
|
'@echo "FBT_TOOLCHAIN_PATH='
|
|
|
|
+ forward_os_env["FBT_TOOLCHAIN_PATH"]
|
|
|
|
+ '" source $( "${FBT_SCRIPT_DIR.abspath}/toolchain/fbtenv.sh" $)',
|
2023-05-08 11:01:52 +00:00
|
|
|
)
|
2023-05-29 16:40:56 +00:00
|
|
|
|
|
|
|
dist_env.PostConfigureUfbtEnvionment()
|