Expand values from top level config into variants when parsing.
Often it is desirable to share configuration options across variants.
This change allows that by taking all options at the higher level
(top-level or package) that aren't used there and adding them to all
variants where they are not already set. Doing so with the typed
configuration structs would be awkward as we'd have to have a bunch of
duplicate fields, and make all fields optional so we could tell when
they are not set. Instead, we first parse the JSON into a dynamically
typed representation, and then preprocess this to expand the variants
before getting serde to parse it into the typed configuration structs.
This also allows existing cargo_embargo.json configurations to work
again, as we default to a single variant with all relevant options from
the top level.
Bug: 293289578
Test: atest cargo_embargo.test
Change-Id: Ib546ffc7ee5df15c4be9eb1596184d1cd67884f7
5 files changed