2022-06-26 12:00:03 +00:00
|
|
|
import SCons
|
2023-02-08 09:35:38 +00:00
|
|
|
from fbt.util import GLOB_FILE_EXCLUSION
|
2023-05-03 05:48:49 +00:00
|
|
|
from SCons.Script import Flatten
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
|
2023-02-08 09:35:38 +00:00
|
|
|
def GlobRecursive(env, pattern, node=".", exclude=[]):
|
|
|
|
exclude = list(set(Flatten(exclude) + GLOB_FILE_EXCLUSION))
|
|
|
|
# print(f"Starting glob for {pattern} from {node} (exclude: {exclude})")
|
2022-06-26 12:00:03 +00:00
|
|
|
results = []
|
|
|
|
if isinstance(node, str):
|
|
|
|
node = env.Dir(node)
|
|
|
|
for f in node.glob("*", source=True, exclude=exclude):
|
|
|
|
if isinstance(f, SCons.Node.FS.Dir):
|
|
|
|
results += env.GlobRecursive(pattern, f, exclude)
|
|
|
|
results += node.glob(
|
|
|
|
pattern,
|
|
|
|
source=True,
|
|
|
|
exclude=exclude,
|
|
|
|
)
|
2023-02-08 09:35:38 +00:00
|
|
|
# print(f"Glob result for {pattern} from {node}: {results}")
|
2022-06-26 12:00:03 +00:00
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
def generate(env):
|
|
|
|
env.AddMethod(GlobRecursive)
|
|
|
|
|
|
|
|
|
|
|
|
def exists(env):
|
|
|
|
return True
|