2022-06-26 12:00:03 +00:00
|
|
|
from SCons.Builder import Builder
|
|
|
|
from SCons.Action import Action
|
2022-07-30 23:48:55 +00:00
|
|
|
from SCons.Warnings import warn, WarningOnByDefault
|
2022-11-02 15:15:40 +00:00
|
|
|
from ansi.color import fg
|
2022-07-30 23:48:55 +00:00
|
|
|
|
2022-07-14 16:24:26 +00:00
|
|
|
from fbt.appmanifest import (
|
|
|
|
FlipperAppType,
|
|
|
|
AppManager,
|
|
|
|
ApplicationsCGenerator,
|
|
|
|
FlipperManifestException,
|
|
|
|
)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
# Adding objects for application management to env
|
|
|
|
# AppManager env["APPMGR"] - loads all manifests; manages list of known apps
|
|
|
|
# AppBuildset env["APPBUILD"] - contains subset of apps, filtered for current config
|
|
|
|
|
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
def LoadAppManifest(env, entry):
|
|
|
|
try:
|
|
|
|
APP_MANIFEST_NAME = "application.fam"
|
|
|
|
manifest_glob = entry.glob(APP_MANIFEST_NAME)
|
|
|
|
if len(manifest_glob) == 0:
|
|
|
|
raise FlipperManifestException(
|
|
|
|
f"Folder {entry}: manifest {APP_MANIFEST_NAME} is missing"
|
|
|
|
)
|
2022-09-14 16:11:38 +00:00
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
app_manifest_file_path = manifest_glob[0].rfile().abspath
|
|
|
|
env["APPMGR"].load_manifest(app_manifest_file_path, entry)
|
|
|
|
env.Append(PY_LINT_SOURCES=[app_manifest_file_path])
|
|
|
|
except FlipperManifestException as e:
|
|
|
|
warn(WarningOnByDefault, str(e))
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def PrepareApplicationsBuild(env):
|
2022-11-10 11:55:11 +00:00
|
|
|
appbuild = env["APPBUILD"] = env["APPMGR"].filter_apps(
|
|
|
|
env["APPS"], env.subst("f${TARGET_HW}")
|
|
|
|
)
|
2022-09-14 16:11:38 +00:00
|
|
|
env.Append(
|
|
|
|
SDK_HEADERS=appbuild.get_sdk_headers(),
|
|
|
|
)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def DumpApplicationConfig(target, source, env):
|
|
|
|
print(f"Loaded {len(env['APPMGR'].known_apps)} app definitions.")
|
2022-11-02 15:15:40 +00:00
|
|
|
print(fg.boldgreen("Firmware modules configuration:"))
|
2022-06-26 12:00:03 +00:00
|
|
|
for apptype in FlipperAppType:
|
|
|
|
app_sublist = env["APPBUILD"].get_apps_of_type(apptype)
|
|
|
|
if app_sublist:
|
|
|
|
print(
|
2022-11-02 15:15:40 +00:00
|
|
|
fg.green(f"{apptype.value}:\n\t"),
|
2022-06-26 12:00:03 +00:00
|
|
|
", ".join(app.appid for app in app_sublist),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def build_apps_c(target, source, env):
|
|
|
|
target_file_name = target[0].path
|
|
|
|
|
2022-08-12 22:17:11 +00:00
|
|
|
gen = ApplicationsCGenerator(env["APPBUILD"], env.subst("$LOADER_AUTOSTART"))
|
2022-06-26 12:00:03 +00:00
|
|
|
with open(target_file_name, "w") as file:
|
|
|
|
file.write(gen.generate())
|
|
|
|
|
|
|
|
|
|
|
|
def generate(env):
|
2022-11-02 15:15:40 +00:00
|
|
|
env.AddMethod(LoadAppManifest)
|
2022-06-26 12:00:03 +00:00
|
|
|
env.AddMethod(PrepareApplicationsBuild)
|
2022-11-02 15:15:40 +00:00
|
|
|
env.SetDefault(
|
|
|
|
APPMGR=AppManager(),
|
2022-11-10 11:55:11 +00:00
|
|
|
APPBUILD_DUMP=env.Action(
|
|
|
|
DumpApplicationConfig,
|
|
|
|
"\tINFO\t",
|
|
|
|
),
|
2022-11-02 15:15:40 +00:00
|
|
|
)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
env.Append(
|
|
|
|
BUILDERS={
|
|
|
|
"ApplicationsC": Builder(
|
2022-06-30 16:06:12 +00:00
|
|
|
action=Action(
|
|
|
|
build_apps_c,
|
|
|
|
"${APPSCOMSTR}",
|
|
|
|
),
|
2022-08-02 14:05:31 +00:00
|
|
|
suffix=".c",
|
2022-06-26 12:00:03 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def exists(env):
|
|
|
|
return True
|