Added subdirs to component manifest.

This commit is contained in:
Sleepy Monax 2023-02-20 22:28:45 +01:00
parent 132af8fb7e
commit 60eba26cd4
3 changed files with 14 additions and 5 deletions

View file

@ -193,9 +193,10 @@ def resolveDeps(componentSpec: str, components: list[ComponentManifest], target:
def instanciate(componentSpec: str, components: list[ComponentManifest], target: TargetManifest) -> ComponentInstance | None:
manifest = next(filter(lambda c: c.id == componentSpec, components))
wildcards = set(chain(*map(lambda rule: rule.fileIn, rules.rules.values())))
wildcards = set(
chain(*map(lambda rule: rule.fileIn, rules.rules.values())))
sources = shell.find(
manifest.dirname(), list(wildcards), recusive=False)
manifest.subdirs, list(wildcards), recusive=False)
enabled, unresolvedReason, resolved = resolveDeps(
componentSpec, components, target)

View file

@ -192,6 +192,7 @@ class ComponentManifest(Manifest):
enableIf: dict[str, list[Any]] = {}
requires: list[str] = []
provides: list[str] = []
subdirs: list[str] = []
def __init__(self, json: Json = None, path: str = "", strict=True, **kwargs):
if json is not None:
@ -202,6 +203,8 @@ class ComponentManifest(Manifest):
self.enableIf = json.get("enableIf", self.enableIf)
self.requires = json.get("requires", self.requires)
self.provides = json.get("provides", self.provides)
self.subdirs = list(map(lambda x: os.path.join(os.path.dirname(
path), x), json.get("subdirs", [""])))
super().__init__(json, path, strict, **kwargs)

View file

@ -42,14 +42,19 @@ def sha256sum(path: str) -> str:
return hashlib.sha256(f.read()).hexdigest()
def find(path: str, wildcards: list[str] = [], recusive: bool = True) -> list[str]:
def find(path: str | list[str], wildcards: list[str] = [], recusive: bool = True) -> list[str]:
logger.log(f"Looking for files in {path} matching {wildcards}")
result: list[str] = []
if isinstance(path, list):
for p in path:
result += find(p, wildcards, recusive)
return result
if not os.path.isdir(path):
return []
result: list[str] = []
if recusive:
for root, _, files in os.walk(path):
for f in files: