Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
toml-patch
crate for improved inheritance (#1477)
Right now, Hubris has a hard-coded inheritance system that allows for one thing: adding new features to existing tasks. The current system is not flexible enough for our current set of boards, and we've ended up with a huge amount of duplication. For Gimlet alone, we have `rev-{b,c,d}{'',-dev,-lab,}`, i.e. 9 variations, of which 6 are mostly copy-pasta. This PR adds a more general form of TOML inheritance, implemented in a new `toml-patch` crate. For those familiar with the Yocto project, it's similar to [`.bbappend` files](https://docs.yoctoproject.org/1.6/dev-manual/dev-manual.html#using-bbappend-files): - TOML files can declare that they inherit from one or more other files, and also contain local data - Inheritance is processed in order (with local data being applied last) - Basic data types (e.g. integers, strings) are replaced with new values - Sequence data types (lists, tables, inline tables; including the root table) have new values appended to the end Before this PR, we shipped both `app.toml` and `patches.toml` in the Hubris archive, and Humility had special code to apply patches itself. After this PR, we flatten everything into a single canonical `app.toml` and only include that in the archive. This means that Humility doesn't have to know about the new patching system at all; it just sees an `app.toml`. The hard part about this was an unexpected issue with `toml_edit`: that crate has a _global order_ for TOML tables, which controls the order in which they're printed. This means that to insert new tables at the end position, we have to - Modify the original document to add gaps - Modify the incoming document, shifting tables into the correct position - _Then_, splice them together It gets even tricker when lists of tables (which may contain sub-tables of their own) are involved! Anyways, that's all implemented in the `toml-patch` crate, along with some unit tests. Note that this PR does not actually deduplicate all of our existing manifests! That's coming in a later PR, which will require careful testing to make sure it doesn't break anything. It does, however, update the style for `-lab` images.
- Loading branch information