mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
fbt: source collection improvements (#3181)
* fbt: reduced amount of redundant compilation units * fbt: added GatherSources() method which can reject source paths starting with "!" in sources list; optimized apps' source lists * docs: updated on path exclusion for `sources` * apps: examples: fixed example_advanced_plugins source list * docs: more details on `sources`; apps: narrower sources lists
This commit is contained in:
@@ -147,16 +147,10 @@ class AppBuilder:
|
||||
CPPPATH=[self.app_work_dir, self.app._appdir],
|
||||
)
|
||||
|
||||
app_sources = list(
|
||||
itertools.chain.from_iterable(
|
||||
self.app_env.GlobRecursive(
|
||||
source_type,
|
||||
self.app_work_dir,
|
||||
exclude="lib",
|
||||
)
|
||||
for source_type in self.app.sources
|
||||
)
|
||||
app_sources = self.app_env.GatherSources(
|
||||
[self.app.sources, "!lib"], self.app_work_dir
|
||||
)
|
||||
|
||||
if not app_sources:
|
||||
raise UserError(f"No source files found for {self.app.appid}")
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import itertools
|
||||
|
||||
import SCons
|
||||
from fbt.util import GLOB_FILE_EXCLUSION
|
||||
from SCons.Script import Flatten
|
||||
from SCons.Node.FS import has_glob_magic
|
||||
from SCons.Script import Flatten
|
||||
|
||||
|
||||
def GlobRecursive(env, pattern, node=".", exclude=[]):
|
||||
@@ -23,12 +25,35 @@ def GlobRecursive(env, pattern, node=".", exclude=[]):
|
||||
# Otherwise, just assume that file at path exists
|
||||
else:
|
||||
results.append(node.File(pattern))
|
||||
## Debug
|
||||
# print(f"Glob result for {pattern} from {node}: {results}")
|
||||
return results
|
||||
|
||||
|
||||
def GatherSources(env, sources_list, node="."):
|
||||
sources_list = list(set(Flatten(sources_list)))
|
||||
include_sources = list(filter(lambda x: not x.startswith("!"), sources_list))
|
||||
exclude_sources = list(x[1:] for x in sources_list if x.startswith("!"))
|
||||
gathered_sources = list(
|
||||
itertools.chain.from_iterable(
|
||||
env.GlobRecursive(
|
||||
source_type,
|
||||
node,
|
||||
exclude=exclude_sources,
|
||||
)
|
||||
for source_type in include_sources
|
||||
)
|
||||
)
|
||||
## Debug
|
||||
# print(
|
||||
# f"Gathered sources for {sources_list} from {node}: {list(f.path for f in gathered_sources)}"
|
||||
# )
|
||||
return gathered_sources
|
||||
|
||||
|
||||
def generate(env):
|
||||
env.AddMethod(GlobRecursive)
|
||||
env.AddMethod(GatherSources)
|
||||
|
||||
|
||||
def exists(env):
|
||||
|
||||
Reference in New Issue
Block a user