unleashed-firmware/assets/SConscript
hedger c3ececcf96
[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>
2023-05-03 14:48:49 +09:00

102 lines
2.8 KiB
Python

from fbt.version import get_git_commit_unix_timestamp
Import("env")
assetsenv = env.Clone(
tools=["fbt_assets"],
FW_LIB_NAME="assets",
GIT_UNIX_TIMESTAMP=get_git_commit_unix_timestamp(),
)
assetsenv.ApplyLibFlags()
icons = assetsenv.CompileIcons(
assetsenv.Dir("compiled"), assetsenv.Dir("#/assets/icons")
)
assetsenv.Alias("icons", icons)
# Protobuf .proto -> .c + .h
proto_src = assetsenv.Glob("protobuf/*.proto", source=True)
proto_options = assetsenv.Glob("protobuf/*.options", source=True)
proto = assetsenv.ProtoBuilder(assetsenv.Dir("compiled"), proto_src)
assetsenv.Depends(proto, proto_options)
# Precious(proto)
assetsenv.Alias("proto", proto)
# Internal animations
dolphin_internal = assetsenv.DolphinSymBuilder(
assetsenv.Dir("compiled"),
assetsenv.Dir("#/assets/dolphin"),
DOLPHIN_RES_TYPE="internal",
)
assetsenv.Alias("dolphin_internal", dolphin_internal)
# Blocking animations
dolphin_blocking = assetsenv.DolphinSymBuilder(
assetsenv.Dir("compiled"),
assetsenv.Dir("#/assets/dolphin"),
DOLPHIN_RES_TYPE="blocking",
)
assetsenv.Alias("dolphin_blocking", dolphin_blocking)
# Protobuf version meta
proto_ver = assetsenv.ProtoVerBuilder(
"compiled/protobuf_version.h",
"#/assets/protobuf/Changelog",
)
assetsenv.Depends(proto_ver, proto)
assetsenv.Alias("proto_ver", proto_ver)
# Gather everything into a static lib
assets_parts = (icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
env.Replace(FW_ASSETS_HEADERS=assets_parts)
assetslib = assetsenv.Library("${FW_LIB_NAME}", assets_parts)
assetsenv.Install("${LIB_DIST_DIR}", assetslib)
# Resources for SD card
env.SetDefault(FW_RESOURCES=None)
if assetsenv["IS_BASE_FIRMWARE"]:
# External dolphin animations
dolphin_external = assetsenv.DolphinExtBuilder(
assetsenv.Dir("#/assets/resources/dolphin"),
assetsenv.Dir("#/assets/dolphin"),
DOLPHIN_RES_TYPE="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(
"*",
assetsenv.Dir("resources").srcnode(),
exclude=["Manifest"],
),
action=Action(
'${PYTHON3} "${ASSETS_COMPILER}" manifest "${TARGET.dir.posix}" --timestamp=${GIT_UNIX_TIMESTAMP}',
"${RESMANIFESTCOMSTR}",
),
)
assetsenv.Precious(resources)
assetsenv.AlwaysBuild(resources)
assetsenv.Clean(
resources,
assetsenv.Dir("#/assets/resources/apps"),
)
# Exporting resources node to external environment
env.Replace(FW_RESOURCES=resources)
assetsenv.Alias("resources", resources)
Return("assetslib")