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-06-26 12:00:03 +00:00
|
|
|
import SCons
|
2022-08-02 13:46:43 +00:00
|
|
|
import os.path
|
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
|
|
|
|
|
|
|
|
|
|
|
|
def LoadApplicationManifests(env):
|
|
|
|
appmgr = env["APPMGR"] = AppManager()
|
2022-08-02 13:46:43 +00:00
|
|
|
for entry in env.Glob("#/applications/*", ondisk=True, source=True):
|
2022-06-26 12:00:03 +00:00
|
|
|
if isinstance(entry, SCons.Node.FS.Dir) and not str(entry).startswith("."):
|
2022-07-14 16:24:26 +00:00
|
|
|
try:
|
2022-08-02 13:46:43 +00:00
|
|
|
appmgr.load_manifest(
|
|
|
|
os.path.join(entry.abspath, "application.fam"), entry.name
|
|
|
|
)
|
2022-07-14 16:24:26 +00:00
|
|
|
except FlipperManifestException as e:
|
2022-07-30 23:48:55 +00:00
|
|
|
warn(WarningOnByDefault, str(e))
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def PrepareApplicationsBuild(env):
|
|
|
|
env["APPBUILD"] = env["APPMGR"].filter_apps(env["APPS"])
|
|
|
|
env["APPBUILD_DUMP"] = env.Action(
|
|
|
|
DumpApplicationConfig,
|
|
|
|
"\tINFO\t",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def DumpApplicationConfig(target, source, env):
|
|
|
|
print(f"Loaded {len(env['APPMGR'].known_apps)} app definitions.")
|
|
|
|
print("Firmware modules configuration:")
|
|
|
|
for apptype in FlipperAppType:
|
|
|
|
app_sublist = env["APPBUILD"].get_apps_of_type(apptype)
|
|
|
|
if app_sublist:
|
|
|
|
print(
|
|
|
|
f"{apptype.value}:\n\t",
|
|
|
|
", ".join(app.appid for app in app_sublist),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def build_apps_c(target, source, env):
|
|
|
|
target_file_name = target[0].path
|
|
|
|
|
|
|
|
gen = ApplicationsCGenerator(env["APPBUILD"])
|
|
|
|
with open(target_file_name, "w") as file:
|
|
|
|
file.write(gen.generate())
|
|
|
|
|
|
|
|
|
|
|
|
def generate(env):
|
|
|
|
env.AddMethod(LoadApplicationManifests)
|
|
|
|
env.AddMethod(PrepareApplicationsBuild)
|
|
|
|
|
|
|
|
env.Append(
|
|
|
|
BUILDERS={
|
|
|
|
"ApplicationsC": Builder(
|
2022-06-30 16:06:12 +00:00
|
|
|
action=Action(
|
|
|
|
build_apps_c,
|
|
|
|
"${APPSCOMSTR}",
|
|
|
|
),
|
2022-06-26 12:00:03 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def exists(env):
|
|
|
|
return True
|