mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
[FL-3627, FL-3628, FL-3631] fbt: glob & git improvements (#3151)
* fbt: optional shallow submodule checkout * fbt: more git threads by default * fbt: git condition fix * fbt: renamed FBT_SHALLOW to FBT_GIT_SUBMODULE_SHALLOW * github: enabled FBT_GIT_SUBMODULE_SHALLOW in flows * fbt: always compile icons' .c, even if user does not specify a proper source glob; changed glob to require files at user-specified paths to exist * fbt: fail build for missing imports in .faps * fbt: moved STRICT_FAP_IMPORT_CHECK to commandline options; enabled by default * ufbt: enabled STRICT_FAP_IMPORT_CHECK Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -100,6 +100,10 @@ class FlipperApplication:
|
||||
def is_default_deployable(self):
|
||||
return self.apptype != FlipperAppType.DEBUG and self.fap_category != "Examples"
|
||||
|
||||
@property
|
||||
def do_strict_import_checks(self):
|
||||
return self.apptype != FlipperAppType.PLUGIN
|
||||
|
||||
def __post_init__(self):
|
||||
if self.apptype == FlipperAppType.PLUGIN:
|
||||
self.stack_size = 0
|
||||
|
||||
@@ -42,6 +42,7 @@ class AppBuilder:
|
||||
self.ext_apps_work_dir = env["EXT_APPS_WORK_DIR"]
|
||||
self.app_work_dir = self.get_app_work_dir(env, app)
|
||||
self.app_alias = f"fap_{self.app.appid}"
|
||||
self.icons_src = None
|
||||
self.externally_built_files = []
|
||||
self.private_libs = []
|
||||
|
||||
@@ -93,6 +94,7 @@ class AppBuilder:
|
||||
)
|
||||
self.app_env.Alias("_fap_icons", fap_icons)
|
||||
self.fw_env.Append(_APP_ICONS=[fap_icons])
|
||||
self.icons_src = next(filter(lambda n: n.path.endswith(".c"), fap_icons))
|
||||
|
||||
def _build_private_libs(self):
|
||||
for lib_def in self.app.fap_private_libs:
|
||||
@@ -160,6 +162,10 @@ class AppBuilder:
|
||||
if not app_sources:
|
||||
raise UserError(f"No source files found for {self.app.appid}")
|
||||
|
||||
# Ensure that icons are included in the build, regardless of user-configured sources
|
||||
if self.icons_src and not self.icons_src in app_sources:
|
||||
app_sources.append(self.icons_src)
|
||||
|
||||
## Uncomment for debug
|
||||
# print(f"App sources for {self.app.appid}: {list(f.path for f in app_sources)}")
|
||||
|
||||
@@ -180,7 +186,9 @@ class AppBuilder:
|
||||
self.app._assets_dirs.append(self.app_work_dir.Dir("assets"))
|
||||
|
||||
app_artifacts.validator = self.app_env.ValidateAppImports(
|
||||
app_artifacts.compact
|
||||
app_artifacts.compact,
|
||||
_CHECK_APP=self.app.do_strict_import_checks
|
||||
and self.app_env.get("STRICT_FAP_IMPORT_CHECK"),
|
||||
)[0]
|
||||
|
||||
if self.app.apptype == FlipperAppType.PLUGIN:
|
||||
@@ -300,7 +308,10 @@ def validate_app_imports(target, source, env):
|
||||
+ fg.brightmagenta(f"{disabled_api_syms}")
|
||||
+ fg.brightyellow(")")
|
||||
)
|
||||
SCons.Warnings.warn(SCons.Warnings.LinkWarning, warning_msg),
|
||||
if env.get("_CHECK_APP"):
|
||||
raise UserError(warning_msg)
|
||||
else:
|
||||
SCons.Warnings.warn(SCons.Warnings.LinkWarning, warning_msg),
|
||||
|
||||
|
||||
def GetExtAppByIdOrPath(env, app_dir):
|
||||
|
||||
@@ -20,10 +20,9 @@ def GlobRecursive(env, pattern, node=".", exclude=[]):
|
||||
source=True,
|
||||
exclude=exclude,
|
||||
)
|
||||
# Otherwise, just check if that's an existing file path
|
||||
# NB: still creates "virtual" nodes as part of existence check
|
||||
elif (file_node := node.File(pattern)).exists() or file_node.rexists():
|
||||
results.append(file_node)
|
||||
# Otherwise, just assume that file at path exists
|
||||
else:
|
||||
results.append(node.File(pattern))
|
||||
# print(f"Glob result for {pattern} from {node}: {results}")
|
||||
return results
|
||||
|
||||
|
||||
@@ -88,6 +88,11 @@ vars.AddVariables(
|
||||
"CDC Port of Flipper to use, if multiple are connected",
|
||||
"auto",
|
||||
),
|
||||
BoolVariable(
|
||||
"STRICT_FAP_IMPORT_CHECK",
|
||||
help="Enable strict import check for .faps",
|
||||
default=True,
|
||||
),
|
||||
)
|
||||
|
||||
Return("vars")
|
||||
|
||||
Reference in New Issue
Block a user