fbt: glob improvements (#3117)
* fbt: glob improvements, now treats entries with no special glob chars as files by default, not calling scons' globbing for them * fbt: further fixes for glob * fbt: less strict existence checks * fbt: fixed frame_rate collection; typo fixes & comments Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
699078d5a5
commit
d47e5ca520
@ -9,7 +9,7 @@ from SCons.Errors import StopError
|
|||||||
|
|
||||||
def icons_emitter(target, source, env):
|
def icons_emitter(target, source, env):
|
||||||
icons_src = env.GlobRecursive("*.png", env["ICON_SRC_DIR"])
|
icons_src = env.GlobRecursive("*.png", env["ICON_SRC_DIR"])
|
||||||
icons_src += env.GlobRecursive("frame_rate", env["ICON_SRC_DIR"])
|
icons_src += env.GlobRecursive("**/frame_rate", env["ICON_SRC_DIR"])
|
||||||
|
|
||||||
target = [
|
target = [
|
||||||
target[0].File(env.subst("${ICON_FILE_NAME}.c")),
|
target[0].File(env.subst("${ICON_FILE_NAME}.c")),
|
||||||
|
|||||||
@ -157,6 +157,11 @@ class AppBuilder:
|
|||||||
for source_type in self.app.sources
|
for source_type in self.app.sources
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if not app_sources:
|
||||||
|
raise UserError(f"No source files found for {self.app.appid}")
|
||||||
|
|
||||||
|
## Uncomment for debug
|
||||||
|
# print(f"App sources for {self.app.appid}: {list(f.path for f in app_sources)}")
|
||||||
|
|
||||||
app_artifacts = FlipperExternalAppInfo(self.app)
|
app_artifacts = FlipperExternalAppInfo(self.app)
|
||||||
app_artifacts.debug = self.app_env.Program(
|
app_artifacts.debug = self.app_env.Program(
|
||||||
@ -239,9 +244,10 @@ class AppBuilder:
|
|||||||
|
|
||||||
# Add dependencies on file assets
|
# Add dependencies on file assets
|
||||||
for assets_dir in self.app._assets_dirs:
|
for assets_dir in self.app._assets_dirs:
|
||||||
|
glob_res = self.app_env.GlobRecursive("*", assets_dir)
|
||||||
self.app_env.Depends(
|
self.app_env.Depends(
|
||||||
app_artifacts.compact,
|
app_artifacts.compact,
|
||||||
(assets_dir, self.app_env.GlobRecursive("*", assets_dir)),
|
(*glob_res, assets_dir),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Always run the validator for the app's binary when building the app
|
# Always run the validator for the app's binary when building the app
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import SCons
|
import SCons
|
||||||
from fbt.util import GLOB_FILE_EXCLUSION
|
from fbt.util import GLOB_FILE_EXCLUSION
|
||||||
from SCons.Script import Flatten
|
from SCons.Script import Flatten
|
||||||
|
from SCons.Node.FS import has_glob_magic
|
||||||
|
|
||||||
|
|
||||||
def GlobRecursive(env, pattern, node=".", exclude=[]):
|
def GlobRecursive(env, pattern, node=".", exclude=[]):
|
||||||
@ -9,6 +10,8 @@ def GlobRecursive(env, pattern, node=".", exclude=[]):
|
|||||||
results = []
|
results = []
|
||||||
if isinstance(node, str):
|
if isinstance(node, str):
|
||||||
node = env.Dir(node)
|
node = env.Dir(node)
|
||||||
|
# Only initiate actual recursion if special symbols can be found in 'pattern'
|
||||||
|
if has_glob_magic(pattern):
|
||||||
for f in node.glob("*", source=True, exclude=exclude):
|
for f in node.glob("*", source=True, exclude=exclude):
|
||||||
if isinstance(f, SCons.Node.FS.Dir):
|
if isinstance(f, SCons.Node.FS.Dir):
|
||||||
results += env.GlobRecursive(pattern, f, exclude)
|
results += env.GlobRecursive(pattern, f, exclude)
|
||||||
@ -17,6 +20,10 @@ def GlobRecursive(env, pattern, node=".", exclude=[]):
|
|||||||
source=True,
|
source=True,
|
||||||
exclude=exclude,
|
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)
|
||||||
# print(f"Glob result for {pattern} from {node}: {results}")
|
# print(f"Glob result for {pattern} from {node}: {results}")
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user