mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[build] Move to yaml-based build config and manifest
Overall, I believe TOML to be a superior configuration format than YAML in many situations, but it gets ugly quickly when nesting data structures. The build configs were fine in TOML, but the manifest (and my future plans for it) got unwieldy. I also did not want different formats for each kind of configuration on top of also having a custom DSL for interface definitions, so I've switched all the TOML to YAML. Also of note is that this change actually adds structure to the manifest file, which was little more than a CSV previously.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
class BonnibelError(Exception):
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
def load_config(filename):
|
||||
from yaml import safe_load
|
||||
with open(filename, 'r') as infile:
|
||||
return safe_load(infile.read())
|
||||
|
||||
@@ -10,11 +10,12 @@ class Project:
|
||||
def __str__(self):
|
||||
return f"{self.name} {self.version.major}.{self.version.minor}.{self.version.patch}-{self.version.sha}"
|
||||
|
||||
def generate(self, root, output, modules, config, manifest):
|
||||
def generate(self, root, output, modules, config, manifest_file):
|
||||
import sys
|
||||
import bonnibel
|
||||
from os.path import join
|
||||
from ninja.ninja_syntax import Writer
|
||||
from . import load_config
|
||||
from .target import Target
|
||||
|
||||
targets = set()
|
||||
@@ -47,11 +48,7 @@ class Project:
|
||||
fatroot.mkdir(exist_ok=True)
|
||||
|
||||
fatroot_content = []
|
||||
for line in open(manifest, 'r'):
|
||||
target, name = line.split(",", 1)
|
||||
target = target.strip()
|
||||
name = name.strip()
|
||||
|
||||
def add_fatroot(name, target):
|
||||
if not name in modules:
|
||||
raise BonnibelError(f"Manifest item '{name}' is not a known module")
|
||||
|
||||
@@ -66,9 +63,23 @@ class Project:
|
||||
"name": f"Installing {name}",
|
||||
"debug": f"${{build_root}}/{mod.output}.debug",
|
||||
})
|
||||
|
||||
fatroot_content.append(fatroot_output)
|
||||
build.newline()
|
||||
|
||||
manifest = load_config(manifest_file)
|
||||
programs = manifest.get("programs", tuple())
|
||||
|
||||
kernel = manifest.get("kernel", dict())
|
||||
add_fatroot(
|
||||
kernel.get("name", "kernel"),
|
||||
kernel.get("target", "kernel"))
|
||||
|
||||
for program in programs:
|
||||
name = program["name"]
|
||||
target = program.get("target", "user")
|
||||
add_fatroot(name, target)
|
||||
|
||||
symbol_table = "${build_root}/fatroot/symbol_table.dat"
|
||||
build.build(
|
||||
rule = "makest",
|
||||
@@ -123,7 +134,7 @@ class Project:
|
||||
build.newline()
|
||||
|
||||
regen_implicits = \
|
||||
[f"{self.root}/configure", str(manifest)] + \
|
||||
[f"{self.root}/configure", str(manifest_file)] + \
|
||||
[str(mod.modfile) for mod in modules.values()]
|
||||
|
||||
for target in targets:
|
||||
|
||||
@@ -3,7 +3,7 @@ class Target(dict):
|
||||
|
||||
@classmethod
|
||||
def load(cls, root, name, config=None):
|
||||
import toml
|
||||
from . import load_config
|
||||
|
||||
if (name, config) in cls.__targets:
|
||||
return cls.__targets[(name, config)]
|
||||
@@ -17,9 +17,9 @@ class Target(dict):
|
||||
basename += f"-{config}"
|
||||
|
||||
while basename is not None:
|
||||
filename = str(configs / (basename + ".toml"))
|
||||
filename = str(configs / (basename + ".yaml"))
|
||||
depfiles.append(filename)
|
||||
desc = toml.load(filename)
|
||||
desc = load_config(filename)
|
||||
basename = desc.get("extends")
|
||||
dicts.append(desc.get("variables", dict()))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user