cutekit/osdk/builder.py

44 lines
1 KiB
Python
Raw Normal View History

from typing import Any, TextIO
from osdk.model import ComponentManifest, TargetManifest, Props
from osdk.ninja import Writer
from osdk.logger import Logger
from osdk.context import Context, contextFor
from osdk import shell
logger = Logger("builder")
def gen(out: TextIO, context: Context):
writer = Writer(out)
target = context.target
writer.comment("File generated by the build system, do not edit")
writer.newline()
writer.separator("Tools")
for key in target.tools:
tool = target.tools[key]
writer.variable(key, tool.cmd)
writer.variable(
key + "flags", " ".join(tool.args))
writer.newline()
writer.separator("Rules")
def build(componentSpec: str, targetSpec: str = "default", props: Props = {}) -> str:
context = contextFor(targetSpec, props)
target = context.target
shell.mkdir(target.builddir())
ninjaPath = f"{target.builddir()}/build.ninja"
with open(ninjaPath, "w") as f:
gen(f, context)
raise NotImplementedError()
return ""