Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fbt_apps.py « site_tools « site_scons - github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2ffdcae3a8bfb2431be78e1afa896de29edb7e8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from SCons.Builder import Builder
from SCons.Action import Action
from SCons.Errors import UserError

import SCons
from fbt.appmanifest import (
    FlipperAppType,
    AppManager,
    ApplicationsCGenerator,
    FlipperManifestException,
)

# 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()
    for entry in env.Glob("#/applications/*", source=True):
        if isinstance(entry, SCons.Node.FS.Dir) and not str(entry).startswith("."):
            try:
                appmgr.load_manifest(entry.File("application.fam").abspath, entry.name)
            except FlipperManifestException as e:
                raise UserError(e)


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(
                action=Action(
                    build_apps_c,
                    "${APPSCOMSTR}",
                ),
            ),
        }
    )


def exists(env):
    return True