Generated cflags.
This commit is contained in:
parent
51f4f2ebd0
commit
3706ecb183
|
@ -18,19 +18,19 @@ def gen(out: TextIO, context: Context):
|
|||
writer.newline()
|
||||
|
||||
writer.separator("Tools")
|
||||
|
||||
writer.variable("cincs", " ".join(
|
||||
map(lambda i: f"-I{i}", context.cincludes())))
|
||||
writer.newline()
|
||||
|
||||
for i in target.tools:
|
||||
tool = target.tools[i]
|
||||
rule = rules.rules[i]
|
||||
writer.variable(i, tool.cmd)
|
||||
writer.variable(
|
||||
i + "flags", " ".join(tool.args))
|
||||
writer.newline()
|
||||
|
||||
writer.separator("Rules")
|
||||
for i in rules.rules:
|
||||
tool = target.tools[i]
|
||||
rule = rules.rules[i]
|
||||
i + "flags", " ".join(rule.args + tool.args))
|
||||
writer.rule(
|
||||
i, f"{tool.cmd} {rule.rule.replace('$flags',f'${i}flags')}", deps=rule.deps)
|
||||
i, f"{tool.cmd} {rule.rule.replace('$flags',f'${i}flags')}", depfile=rule.deps)
|
||||
writer.newline()
|
||||
|
||||
writer.separator("Components")
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from typing import cast
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
from osdk.model import TargetManifest, ComponentManifest, Props, Type
|
||||
from osdk.logger import Logger
|
||||
from osdk import const, shell, jexpr
|
||||
from osdk import const, shell, jexpr, utils
|
||||
|
||||
logger = Logger("context")
|
||||
|
||||
|
@ -48,6 +50,12 @@ class ComponentInstance:
|
|||
return self.libfile()
|
||||
return self.binfile()
|
||||
|
||||
def cinclude(self) -> str:
|
||||
if "cpp-root-include" in self.manifest.props:
|
||||
return self.manifest.dirname()
|
||||
else:
|
||||
return str(Path(self.manifest.dirname()).parent)
|
||||
|
||||
|
||||
class Context:
|
||||
target: TargetManifest
|
||||
|
@ -63,6 +71,11 @@ class Context:
|
|||
return None
|
||||
return result[0]
|
||||
|
||||
def cincludes(self) -> list[str]:
|
||||
includes = list(
|
||||
map(lambda x: x.cinclude(), self.instances))
|
||||
return utils.uniq(includes)
|
||||
|
||||
|
||||
def loadAllTargets() -> list[TargetManifest]:
|
||||
files = shell.find(const.TARGETS_DIR, ["*.json"])
|
||||
|
|
|
@ -108,6 +108,9 @@ class TargetManifest(Manifest):
|
|||
def builddir(self) -> str:
|
||||
return f"{const.BUILD_DIR}/{self.id}-{self.hashid()[:8]}"
|
||||
|
||||
def patch(self, toolSpec: str, args: list[str]):
|
||||
self.tools[toolSpec].args += args
|
||||
|
||||
|
||||
class ComponentManifest(Manifest):
|
||||
decription: str
|
||||
|
|
|
@ -3,19 +3,29 @@ class Rule:
|
|||
fileIn: list[str]
|
||||
fileOut: list[str]
|
||||
rule: str
|
||||
args: list[str]
|
||||
deps: str | None = None
|
||||
|
||||
def __init__(self, id: str, fileIn: list[str], fileOut: list[str], rule: str, deps: str | None = None):
|
||||
def __init__(self, id: str, fileIn: list[str], fileOut: list[str], rule: str, args: list[str] = [], deps: str | None = None):
|
||||
self.id = id
|
||||
self.fileIn = fileIn
|
||||
self.fileOut = fileOut
|
||||
self.rule = rule
|
||||
self.args = args
|
||||
self.deps = deps
|
||||
|
||||
|
||||
rules: dict[str, Rule] = {
|
||||
"cc": Rule("cc", ["c"], ["o"], "-c -o $out $in -MD -MF $out.d $flags", "$out.d"),
|
||||
"cxx": Rule("cxx", ["cpp", "cc", "cxx"], ["o"], "-c -o $out $in -MD -MF $out.d $flags", "$out.d"),
|
||||
"cc": Rule("cc", ["c"], ["o"], "-c -o $out $in -MD -MF $out.d $flags $cincs", ["-std=gnu2x",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror"], "$out.d"),
|
||||
"cxx": Rule("cxx", ["cpp", "cc", "cxx"], ["o"], "-c -o $out $in -MD -MF $out.d $flags $cincs", ["-std=gnu++2b",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti"], "$out.d"),
|
||||
"as": Rule("as", ["s", "asm", "S"], ["o"], "-o $out $in $flags"),
|
||||
"ar": Rule("ar", ["o"], ["a"], "$flags $out $in"),
|
||||
"ld": Rule("ld", ["o", "a"], ["out"], "$flags $out $in"),
|
||||
|
|
Loading…
Reference in a new issue