2022-11-05 11:47:59 +00:00
|
|
|
from dataclasses import dataclass, field
|
2023-05-03 05:48:49 +00:00
|
|
|
from fbt.appmanifest import FlipperAppType
|
2023-03-14 14:29:28 +00:00
|
|
|
|
2022-11-05 11:47:59 +00:00
|
|
|
from SCons.Node import NodeList
|
2022-11-10 11:55:11 +00:00
|
|
|
from SCons.Warnings import warn, WarningOnByDefault
|
2023-05-03 05:48:49 +00:00
|
|
|
|
2022-10-06 13:55:57 +00:00
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
Import("ENV")
|
|
|
|
|
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
appenv = ENV["APPENV"] = ENV.Clone(
|
2022-10-06 13:55:57 +00:00
|
|
|
tools=[
|
2022-11-05 11:47:59 +00:00
|
|
|
"fbt_extapps",
|
2022-10-06 13:55:57 +00:00
|
|
|
"fbt_assets",
|
2022-11-02 15:15:40 +00:00
|
|
|
"fbt_sdk",
|
2023-03-14 14:29:28 +00:00
|
|
|
],
|
2022-09-14 16:11:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
appenv.Replace(
|
2023-02-07 16:33:05 +00:00
|
|
|
LINKER_SCRIPT_PATH=appenv["APP_LINKER_SCRIPT_PATH"],
|
2022-09-14 16:11:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
appenv.AppendUnique(
|
|
|
|
CCFLAGS=[
|
|
|
|
"-mword-relocations",
|
|
|
|
"-mlong-calls",
|
|
|
|
"-fno-common",
|
|
|
|
"-nostdlib",
|
|
|
|
],
|
|
|
|
LINKFLAGS=[
|
|
|
|
"-Ur",
|
|
|
|
"-Wl,-Ur",
|
|
|
|
"-nostartfiles",
|
|
|
|
"-mlong-calls",
|
|
|
|
"-fno-common",
|
|
|
|
"-nostdlib",
|
|
|
|
"-Wl,--gc-sections",
|
|
|
|
"-Wl,--no-export-dynamic",
|
|
|
|
"-fvisibility=hidden",
|
|
|
|
"-Wl,-e${APP_ENTRY}",
|
|
|
|
"-Xlinker",
|
|
|
|
"-Map=${TARGET}.map",
|
|
|
|
"-specs=nano.specs",
|
|
|
|
],
|
|
|
|
LIBS=[
|
|
|
|
"m",
|
|
|
|
"gcc",
|
|
|
|
"stdc++",
|
|
|
|
"supc++",
|
|
|
|
],
|
2024-04-01 17:02:45 +00:00
|
|
|
CFLAGS=[
|
|
|
|
"-Wno-strict-prototypes",
|
|
|
|
],
|
2022-09-14 16:11:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-11-05 11:47:59 +00:00
|
|
|
@dataclass
|
|
|
|
class FlipperExtAppBuildArtifacts:
|
2023-03-14 14:29:28 +00:00
|
|
|
application_map: dict = field(default_factory=dict)
|
2022-11-05 11:47:59 +00:00
|
|
|
sdk_tree: NodeList = field(default_factory=NodeList)
|
2022-09-14 16:11:38 +00:00
|
|
|
|
|
|
|
|
2023-09-05 11:49:39 +00:00
|
|
|
for app in appenv["APPBUILD"].get_ext_apps():
|
2022-11-05 11:47:59 +00:00
|
|
|
appenv.BuildAppElf(app)
|
2022-10-06 13:55:57 +00:00
|
|
|
|
2023-03-14 14:29:28 +00:00
|
|
|
extapps = FlipperExtAppBuildArtifacts()
|
|
|
|
extapps.application_map = appenv["EXT_APPS"]
|
|
|
|
|
2022-10-06 13:55:57 +00:00
|
|
|
|
2022-11-05 11:47:59 +00:00
|
|
|
if appenv["FORCE"]:
|
|
|
|
appenv.AlwaysBuild(
|
2023-03-14 14:29:28 +00:00
|
|
|
list(app_artifact.compact for app_artifact in extapps.application_map.values())
|
2022-11-05 11:47:59 +00:00
|
|
|
)
|
2022-10-06 13:55:57 +00:00
|
|
|
|
|
|
|
|
2022-11-05 11:47:59 +00:00
|
|
|
Alias(
|
2023-03-14 14:29:28 +00:00
|
|
|
"faps",
|
|
|
|
list(app_artifact.validator for app_artifact in extapps.application_map.values()),
|
2022-11-05 11:47:59 +00:00
|
|
|
)
|
2022-09-14 16:11:38 +00:00
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
if appsrc := appenv.subst("$APPSRC"):
|
2023-07-18 09:39:30 +00:00
|
|
|
launch_target = appenv.AddAppLaunchTarget(appsrc, "launch")
|
|
|
|
Alias("launch_app", launch_target)
|
|
|
|
appenv.PhonyTarget(
|
|
|
|
"launch_app",
|
|
|
|
Action(
|
|
|
|
lambda **kw: warn(
|
|
|
|
WarningOnByDefault,
|
|
|
|
"The 'launch_app' target is deprecated. Use 'launch' instead.",
|
|
|
|
),
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
)
|
2023-04-06 02:44:37 +00:00
|
|
|
|
2023-07-18 09:39:30 +00:00
|
|
|
appenv.AddAppBuildTarget(appsrc, "build")
|
2022-09-14 16:11:38 +00:00
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
# SDK management
|
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
amalgamated_api = "${BUILD_DIR}/sdk_origin"
|
|
|
|
sdk_source = appenv.ApiAmalgamator(
|
|
|
|
amalgamated_api,
|
2022-11-02 15:15:40 +00:00
|
|
|
# Deps on root SDK headers and generated files
|
|
|
|
(appenv["SDK_HEADERS"], appenv["FW_ASSETS_HEADERS"]),
|
|
|
|
)
|
|
|
|
# Extra deps on headers included in deeper levels
|
2022-11-05 11:47:59 +00:00
|
|
|
# Available on second and subsequent builds
|
2023-04-06 02:44:37 +00:00
|
|
|
Depends(sdk_source, appenv.ProcessSdkDepends(f"{amalgamated_api}.d"))
|
2022-11-02 15:15:40 +00:00
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
appenv["SDK_DIR"] = appenv.Dir("${BUILD_DIR}/sdk_headers")
|
|
|
|
sdk_header_tree = appenv.SDKHeaderTreeExtractor(appenv["SDK_DIR"], amalgamated_api)
|
2023-04-10 14:46:22 +00:00
|
|
|
Depends(sdk_header_tree, appenv["SDK_DEFINITION"])
|
2022-11-02 15:15:40 +00:00
|
|
|
# AlwaysBuild(sdk_tree)
|
2023-04-06 02:44:37 +00:00
|
|
|
Alias("sdk_tree", sdk_header_tree)
|
|
|
|
extapps.sdk_tree = sdk_header_tree
|
2022-11-02 15:15:40 +00:00
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
api_check = appenv.ApiTableValidator(appenv["SDK_DEFINITION"], amalgamated_api)
|
|
|
|
Precious(api_check)
|
|
|
|
NoClean(api_check)
|
|
|
|
AlwaysBuild(api_check)
|
|
|
|
Alias("api_check", api_check)
|
2022-11-02 15:15:40 +00:00
|
|
|
|
2023-04-06 02:44:37 +00:00
|
|
|
firmware_apitable = appenv.ApiSymbolTable(
|
|
|
|
"${BUILD_DIR}/assets/compiled/firmware_api_table.h", appenv["SDK_DEFINITION"]
|
2022-11-02 15:15:40 +00:00
|
|
|
)
|
2023-04-06 02:44:37 +00:00
|
|
|
Alias("api_table", firmware_apitable)
|
2023-01-17 12:55:49 +00:00
|
|
|
ENV.Replace(
|
2023-04-06 02:44:37 +00:00
|
|
|
FW_API_TABLE=firmware_apitable,
|
2023-01-17 12:55:49 +00:00
|
|
|
_APP_ICONS=appenv["_APP_ICONS"],
|
|
|
|
)
|
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
|
|
|
|
if appenv["FORCE"]:
|
2023-04-06 02:44:37 +00:00
|
|
|
appenv.AlwaysBuild(sdk_source, sdk_header_tree, api_check, firmware_apitable)
|
2022-11-02 15:15:40 +00:00
|
|
|
|
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
Return("extapps")
|