fix: remove hardcoded wildcard and use the ones from the rules

This commit is contained in:
Jordan ⌨️ 2023-02-19 19:35:03 +01:00 committed by Sleepy Monax
parent 9b1e01bd66
commit 2781990ff5
2 changed files with 9 additions and 8 deletions

View file

@ -1,4 +1,5 @@
from typing import cast, Protocol, Iterable from typing import cast, Protocol, Iterable
from itertools import chain
from pathlib import Path from pathlib import Path
import os import os
@ -192,8 +193,9 @@ def resolveDeps(componentSpec: str, components: list[ComponentManifest], target:
def instanciate(componentSpec: str, components: list[ComponentManifest], target: TargetManifest) -> ComponentInstance | None: def instanciate(componentSpec: str, components: list[ComponentManifest], target: TargetManifest) -> ComponentInstance | None:
manifest = next(filter(lambda c: c.id == componentSpec, components)) manifest = next(filter(lambda c: c.id == componentSpec, components))
wildcards = set(chain(*map(lambda rule: rule.fileIn, rules.rules.values())))
sources = shell.find( sources = shell.find(
manifest.dirname(), ["*.c", "*.cpp", "*.s", "*.asm"], recusive=False) manifest.dirname(), list(wildcards), recusive=False)
enabled, unresolvedReason, resolved = resolveDeps( enabled, unresolvedReason, resolved = resolveDeps(
componentSpec, components, target) componentSpec, components, target)

View file

@ -14,21 +14,20 @@ class Rule:
self.args = args self.args = args
self.deps = deps self.deps = deps
rules: dict[str, Rule] = { rules: dict[str, Rule] = {
"cc": Rule("cc", ["c"], ["o"], "-c -o $out $in -MD -MF $out.d $flags $cincs $cdefs", ["-std=gnu2x", "cc": Rule("cc", ["*.c"], ["*.o"], "-c -o $out $in -MD -MF $out.d $flags $cincs $cdefs", ["-std=gnu2x",
"-Wall", "-Wall",
"-Wextra", "-Wextra",
"-Werror"], "$out.d"), "-Werror"], "$out.d"),
"cxx": Rule("cxx", ["cpp", "cc", "cxx"], ["o"], "-c -o $out $in -MD -MF $out.d $flags $cincs $cdefs", ["-std=gnu++2b", "cxx": Rule("cxx", ["*.cpp", "*.cc", "*.cxx"], ["*.o"], "-c -o $out $in -MD -MF $out.d $flags $cincs $cdefs", ["-std=gnu++2b",
"-Wall", "-Wall",
"-Wextra", "-Wextra",
"-Werror", "-Werror",
"-fno-exceptions", "-fno-exceptions",
"-fno-rtti"], "$out.d"), "-fno-rtti"], "$out.d"),
"as": Rule("as", ["s", "asm", "S"], ["o"], "-o $out $in $flags"), "as": Rule("as", ["*.s", "*.asm", "*.S"], ["*.o"], "-o $out $in $flags"),
"ar": Rule("ar", ["o"], ["a"], "$flags $out $in"), "ar": Rule("ar", ["*.o"], ["*.a"], "$flags $out $in"),
"ld": Rule("ld", ["o", "a"], ["out"], "-o $out $in $flags"), "ld": Rule("ld", ["*.o", "*.a"], ["*.out"], "-o $out $in $flags"),
} }
@ -40,7 +39,7 @@ def byFileIn(fileIn: str) -> Rule | None:
for key in rules: for key in rules:
rule = rules[key] rule = rules[key]
for ext in rule.fileIn: for ext in rule.fileIn:
if fileIn.endswith("." + ext): if fileIn.endswith(ext[1:]):
return rule return rule
return None return None