fbt: 'target' field for apps; lib debugging support (#1995)
* fbt: added 'target' field to application manifest * fbt: earlier pagination setup for gdb * fbt: added LIB_DEBUG flag * fbt: sdk: added SDK_MAP_FILE_SUBST
This commit is contained in:
@@ -52,6 +52,8 @@ class FlipperApplication:
|
||||
icon: Optional[str] = None
|
||||
order: int = 0
|
||||
sdk_headers: List[str] = field(default_factory=list)
|
||||
targets: List[str] = field(default_factory=lambda: ["all"])
|
||||
|
||||
# .fap-specific
|
||||
sources: List[str] = field(default_factory=lambda: ["*.c*"])
|
||||
fap_version: Tuple[int] = field(default_factory=lambda: (0, 1))
|
||||
@@ -135,8 +137,8 @@ class AppManager:
|
||||
raise FlipperManifestException(f"Duplicate app declaration: {app.appid}")
|
||||
self.known_apps[app.appid] = app
|
||||
|
||||
def filter_apps(self, applist: List[str]):
|
||||
return AppBuildset(self, applist)
|
||||
def filter_apps(self, applist: List[str], hw_target: str):
|
||||
return AppBuildset(self, applist, hw_target)
|
||||
|
||||
|
||||
class AppBuilderException(Exception):
|
||||
@@ -155,11 +157,13 @@ class AppBuildset:
|
||||
FlipperAppType.STARTUP,
|
||||
)
|
||||
|
||||
def __init__(self, appmgr: AppManager, appnames: List[str]):
|
||||
def __init__(self, appmgr: AppManager, appnames: List[str], hw_target: str):
|
||||
self.appmgr = appmgr
|
||||
self.appnames = set(appnames)
|
||||
self.hw_target = hw_target
|
||||
self._orig_appnames = appnames
|
||||
self._process_deps()
|
||||
self._filter_by_target()
|
||||
self._check_conflicts()
|
||||
self._check_unsatisfied() # unneeded?
|
||||
self.apps = sorted(
|
||||
@@ -170,6 +174,16 @@ class AppBuildset:
|
||||
def _is_missing_dep(self, dep_name: str):
|
||||
return dep_name not in self.appnames
|
||||
|
||||
def _filter_by_target(self):
|
||||
for appname in self.appnames.copy():
|
||||
app = self.appmgr.get(appname)
|
||||
# if app.apptype not in self.BUILTIN_APP_TYPES:
|
||||
if not any(map(lambda t: t in app.targets, ["all", self.hw_target])):
|
||||
print(
|
||||
f"Removing {appname} due to target mismatch (building for {self.hw_target}, app supports {app.targets}"
|
||||
)
|
||||
self.appnames.remove(appname)
|
||||
|
||||
def _process_deps(self):
|
||||
while True:
|
||||
provided = []
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import SCons
|
||||
from SCons.Subst import quote_spaces
|
||||
from SCons.Errors import StopError
|
||||
from SCons.Node.FS import _my_normcase
|
||||
|
||||
import re
|
||||
import os
|
||||
@@ -58,3 +57,9 @@ def extract_abs_dir_path(node):
|
||||
raise StopError(f"Can't find absolute path for {node.name}")
|
||||
|
||||
return abs_dir_node.abspath
|
||||
|
||||
|
||||
def path_as_posix(path):
|
||||
if SCons.Platform.platform_default() == "win32":
|
||||
return path.replace(os.path.sep, os.path.altsep)
|
||||
return path
|
||||
|
@@ -1,7 +1,6 @@
|
||||
from SCons.Builder import Builder
|
||||
from SCons.Action import Action
|
||||
from SCons.Warnings import warn, WarningOnByDefault
|
||||
import SCons
|
||||
from ansi.color import fg
|
||||
|
||||
from fbt.appmanifest import (
|
||||
@@ -33,14 +32,12 @@ def LoadAppManifest(env, entry):
|
||||
|
||||
|
||||
def PrepareApplicationsBuild(env):
|
||||
appbuild = env["APPBUILD"] = env["APPMGR"].filter_apps(env["APPS"])
|
||||
appbuild = env["APPBUILD"] = env["APPMGR"].filter_apps(
|
||||
env["APPS"], env.subst("f${TARGET_HW}")
|
||||
)
|
||||
env.Append(
|
||||
SDK_HEADERS=appbuild.get_sdk_headers(),
|
||||
)
|
||||
env["APPBUILD_DUMP"] = env.Action(
|
||||
DumpApplicationConfig,
|
||||
"\tINFO\t",
|
||||
)
|
||||
|
||||
|
||||
def DumpApplicationConfig(target, source, env):
|
||||
@@ -68,6 +65,10 @@ def generate(env):
|
||||
env.AddMethod(PrepareApplicationsBuild)
|
||||
env.SetDefault(
|
||||
APPMGR=AppManager(),
|
||||
APPBUILD_DUMP=env.Action(
|
||||
DumpApplicationConfig,
|
||||
"\tINFO\t",
|
||||
),
|
||||
)
|
||||
|
||||
env.Append(
|
||||
|
@@ -41,12 +41,12 @@ def generate(env, **kw):
|
||||
"|openocd -c 'gdb_port pipe; log_output ${FBT_DEBUG_DIR}/openocd.log' ${[SINGLEQUOTEFUNC(OPENOCD_OPTS)]}"
|
||||
],
|
||||
GDBOPTS_BASE=[
|
||||
"-ex",
|
||||
"set pagination off",
|
||||
"-ex",
|
||||
"target extended-remote ${GDBREMOTE}",
|
||||
"-ex",
|
||||
"set confirm off",
|
||||
"-ex",
|
||||
"set pagination off",
|
||||
],
|
||||
GDBOPTS_BLACKMAGIC=[
|
||||
"-ex",
|
||||
|
@@ -14,6 +14,7 @@ import json
|
||||
|
||||
from fbt.sdk.collector import SdkCollector
|
||||
from fbt.sdk.cache import SdkCache
|
||||
from fbt.util import path_as_posix
|
||||
|
||||
|
||||
def ProcessSdkDepends(env, filename):
|
||||
@@ -52,6 +53,8 @@ def prebuild_sdk_create_origin_file(target, source, env):
|
||||
|
||||
|
||||
class SdkMeta:
|
||||
MAP_FILE_SUBST = "SDK_MAP_FILE_SUBST"
|
||||
|
||||
def __init__(self, env, tree_builder: "SdkTreeBuilder"):
|
||||
self.env = env
|
||||
self.treebuilder = tree_builder
|
||||
@@ -67,6 +70,7 @@ class SdkMeta:
|
||||
"linker_libs": self.env.subst("${LIBS}"),
|
||||
"app_ep_subst": self.env.subst("${APP_ENTRY}"),
|
||||
"sdk_path_subst": self.env.subst("${SDK_DIR_SUBST}"),
|
||||
"map_file_subst": self.MAP_FILE_SUBST,
|
||||
"hardware": self.env.subst("${TARGET_HW}"),
|
||||
}
|
||||
with open(json_manifest_path, "wt") as f:
|
||||
@@ -75,9 +79,9 @@ class SdkMeta:
|
||||
def _wrap_scons_vars(self, vars: str):
|
||||
expanded_vars = self.env.subst(
|
||||
vars,
|
||||
target=Entry("dummy"),
|
||||
target=Entry(self.MAP_FILE_SUBST),
|
||||
)
|
||||
return expanded_vars.replace("\\", "/")
|
||||
return path_as_posix(expanded_vars)
|
||||
|
||||
|
||||
class SdkTreeBuilder:
|
||||
@@ -142,13 +146,15 @@ class SdkTreeBuilder:
|
||||
meta.save_to(self.target[0].path)
|
||||
|
||||
def build_sdk_file_path(self, orig_path: str) -> str:
|
||||
return posixpath.normpath(
|
||||
posixpath.join(
|
||||
self.SDK_DIR_SUBST,
|
||||
self.target_sdk_dir_name,
|
||||
orig_path,
|
||||
return path_as_posix(
|
||||
posixpath.normpath(
|
||||
posixpath.join(
|
||||
self.SDK_DIR_SUBST,
|
||||
self.target_sdk_dir_name,
|
||||
orig_path,
|
||||
)
|
||||
)
|
||||
).replace("\\", "/")
|
||||
)
|
||||
|
||||
def emitter(self, target, source, env):
|
||||
target_folder = target[0]
|
||||
|
Reference in New Issue
Block a user