mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-30 00:32:06 +03:00
917410a0a8
* fbt: reworking targets & assets handling WIP * fbt: dist fixes * fbt: moved SD card resources to owning apps * unit_tests: moved resources to app folder * github: updated unit_tests paths * github: packaging fixes * unit_tests: fixes * fbt: assets: internal cleanup * fbt: reworked assets handling * github: unit_tests: reintroducing fixes * minor cleanup * fbt: naming changes to reflect private nature of scons tools * fbt: resources: fixed dist archive paths * docs: updated paths * docs: updated more paths * docs: included "resources" parameter in app manifest docs; updated assets readme * updated gitignore for assets * github: updated action versions * unit_tests: restored timeout; scripts: assets: logging changes * gh: don't upload desktop animations for unit test run Co-authored-by: あく <alleteam@gmail.com>
194 lines
5.2 KiB
Python
194 lines
5.2 KiB
Python
from SCons.Action import Action
|
|
from SCons.Builder import Builder
|
|
from SCons.Defaults import Touch
|
|
|
|
|
|
def GetProjetDirName(env, project=None):
|
|
parts = [f"f{env['TARGET_HW']}"]
|
|
if project:
|
|
parts.append(project)
|
|
|
|
suffix = ""
|
|
if env["DEBUG"]:
|
|
suffix += "D"
|
|
if env["COMPACT"]:
|
|
suffix += "C"
|
|
if suffix:
|
|
parts.append(suffix)
|
|
|
|
return "-".join(parts)
|
|
|
|
|
|
def create_fw_build_targets(env, configuration_name):
|
|
flavor = GetProjetDirName(env, configuration_name)
|
|
build_dir = env.Dir("build").Dir(flavor)
|
|
return env.SConscript(
|
|
"firmware.scons",
|
|
variant_dir=build_dir,
|
|
duplicate=0,
|
|
exports={
|
|
"ENV": env,
|
|
"fw_build_meta": {
|
|
"type": configuration_name,
|
|
"flavor": flavor,
|
|
"build_dir": build_dir,
|
|
},
|
|
},
|
|
)
|
|
|
|
|
|
def AddFwProject(env, base_env, fw_type, fw_env_key):
|
|
project_env = env[fw_env_key] = create_fw_build_targets(base_env, fw_type)
|
|
env.Append(
|
|
DIST_PROJECTS=[
|
|
project_env["FW_FLAVOR"],
|
|
],
|
|
DIST_DEPENDS=[
|
|
project_env["FW_ARTIFACTS"],
|
|
],
|
|
)
|
|
|
|
env.Replace(DIST_DIR=env.GetProjetDirName())
|
|
return project_env
|
|
|
|
|
|
def AddFwFlashTarget(env, targetenv, **kw):
|
|
fwflash_target = env.FwFlash(
|
|
"#build/flash.flag",
|
|
targetenv["FW_ELF"],
|
|
**kw,
|
|
)
|
|
env.Alias(targetenv.subst("${FIRMWARE_BUILD_CFG}_flash"), fwflash_target)
|
|
if env["FORCE"]:
|
|
env.AlwaysBuild(fwflash_target)
|
|
return fwflash_target
|
|
|
|
|
|
def AddJFlashTarget(env, targetenv, **kw):
|
|
jflash_target = env.JFlash(
|
|
"#build/jflash-${BUILD_CFG}-flash.flag",
|
|
targetenv["FW_BIN"],
|
|
JFLASHADDR=targetenv.subst("$IMAGE_BASE_ADDRESS"),
|
|
BUILD_CFG=targetenv.subst("${FIRMWARE_BUILD_CFG}"),
|
|
**kw,
|
|
)
|
|
env.Alias(targetenv.subst("${FIRMWARE_BUILD_CFG}_jflash"), jflash_target)
|
|
if env["FORCE"]:
|
|
env.AlwaysBuild(jflash_target)
|
|
return jflash_target
|
|
|
|
|
|
def AddUsbFlashTarget(env, file_flag, extra_deps, **kw):
|
|
usb_update = env.UsbInstall(
|
|
file_flag,
|
|
(
|
|
env["DIST_DEPENDS"],
|
|
*extra_deps,
|
|
),
|
|
)
|
|
if env["FORCE"]:
|
|
env.AlwaysBuild(usb_update)
|
|
return usb_update
|
|
|
|
|
|
def DistCommand(env, name, source, **kw):
|
|
target = f"dist_{name}"
|
|
command = env.Command(
|
|
target,
|
|
source,
|
|
action=Action(
|
|
[
|
|
[
|
|
"${PYTHON3}",
|
|
"${DIST_SCRIPT}",
|
|
"copy",
|
|
"-p",
|
|
"${DIST_PROJECTS}",
|
|
"-s",
|
|
"${DIST_SUFFIX}",
|
|
"${DIST_EXTRA}",
|
|
]
|
|
],
|
|
"${DISTCOMSTR}",
|
|
),
|
|
**kw,
|
|
)
|
|
env.Pseudo(target)
|
|
env.Alias(name, command)
|
|
return command
|
|
|
|
|
|
def generate(env):
|
|
if not env["VERBOSE"]:
|
|
env.SetDefault(
|
|
COPROCOMSTR="\tCOPRO\t${TARGET}",
|
|
DISTCOMSTR="\tDIST\t${TARGET}",
|
|
)
|
|
env.AddMethod(AddFwProject)
|
|
env.AddMethod(DistCommand)
|
|
env.AddMethod(AddFwFlashTarget)
|
|
env.AddMethod(GetProjetDirName)
|
|
env.AddMethod(AddJFlashTarget)
|
|
env.AddMethod(AddUsbFlashTarget)
|
|
|
|
env.SetDefault(
|
|
COPRO_MCU_FAMILY="STM32WB5x",
|
|
SELFUPDATE_SCRIPT="${FBT_SCRIPT_DIR}/selfupdate.py",
|
|
DIST_SCRIPT="${FBT_SCRIPT_DIR}/sconsdist.py",
|
|
COPRO_ASSETS_SCRIPT="${FBT_SCRIPT_DIR}/assets.py",
|
|
FW_FLASH_SCRIPT="${FBT_SCRIPT_DIR}/fwflash.py",
|
|
)
|
|
|
|
env.Append(
|
|
BUILDERS={
|
|
"FwFlash": Builder(
|
|
action=[
|
|
[
|
|
"${PYTHON3}",
|
|
"${FW_FLASH_SCRIPT}",
|
|
"-d" if env["VERBOSE"] else "",
|
|
"--interface=${SWD_TRANSPORT}",
|
|
"--serial=${SWD_TRANSPORT_SERIAL}",
|
|
"${SOURCE}",
|
|
],
|
|
Touch("${TARGET}"),
|
|
]
|
|
),
|
|
"UsbInstall": Builder(
|
|
action=[
|
|
[
|
|
"${PYTHON3}",
|
|
"${SELFUPDATE_SCRIPT}",
|
|
"-p",
|
|
"${FLIP_PORT}",
|
|
"${UPDATE_BUNDLE_DIR}/update.fuf",
|
|
],
|
|
Touch("${TARGET}"),
|
|
]
|
|
),
|
|
"CoproBuilder": Builder(
|
|
action=Action(
|
|
[
|
|
[
|
|
"${PYTHON3}",
|
|
"${COPRO_ASSETS_SCRIPT}",
|
|
"copro",
|
|
"${COPRO_CUBE_DIR}",
|
|
"${TARGET}",
|
|
"${COPRO_MCU_FAMILY}",
|
|
"--cube_ver=${COPRO_CUBE_VERSION}",
|
|
"--stack_type=${COPRO_STACK_TYPE}",
|
|
"--stack_file=${COPRO_STACK_BIN}",
|
|
"--stack_addr=${COPRO_STACK_ADDR}",
|
|
]
|
|
],
|
|
"${COPROCOMSTR}",
|
|
)
|
|
),
|
|
}
|
|
)
|
|
|
|
|
|
def exists(env):
|
|
return True
|