aconfig: separate flag declarations and flag values
Simplify how aconfig configurations work: remove the ability to set flag
values based on build-id.
The aconfig files now some in two flavours:
- flag declaration files: introduce new flags; aconfig will assign the
flags a hard-coded default value (disabled, read-write)
- flag value files: assign flags new values
`aconfig create-cache` expects flags to be declared exactly once, and
for their values to be reassigned zero or more times.
The flag value files are identical what used to be called override
files.
Also, remove the now obsolete build-id parameter: this was used to
calculate default values before applying overrides, and is no longer
needed.
Also rename a few more structs and functions to be closer to the .proto
names. This will make it easier to use the generated proto structs
directly, and get rid of the hand-crafter wrappers.
Bug: 279485059
Test: atest aconfig.test
Change-Id: I7bf881338b0567f932099ce419cac457abbe8df8
diff --git a/tools/aconfig/src/main.rs b/tools/aconfig/src/main.rs
index f29186a..4abcb90 100644
--- a/tools/aconfig/src/main.rs
+++ b/tools/aconfig/src/main.rs
@@ -36,15 +36,9 @@
.subcommand_required(true)
.subcommand(
Command::new("create-cache")
- .arg(
- Arg::new("build-id")
- .long("build-id")
- .value_parser(clap::value_parser!(u32))
- .required(true),
- )
.arg(Arg::new("namespace").long("namespace").required(true))
- .arg(Arg::new("aconfig").long("aconfig").action(ArgAction::Append))
- .arg(Arg::new("override").long("override").action(ArgAction::Append))
+ .arg(Arg::new("declarations").long("declarations").action(ArgAction::Append))
+ .arg(Arg::new("values").long("values").action(ArgAction::Append))
.arg(Arg::new("cache").long("cache").required(true)),
)
.subcommand(
@@ -78,11 +72,10 @@
let matches = cli().get_matches();
match matches.subcommand() {
Some(("create-cache", sub_matches)) => {
- let build_id = *sub_matches.get_one::<u32>("build-id").unwrap();
let namespace = sub_matches.get_one::<String>("namespace").unwrap();
- let aconfigs = open_zero_or_more_files(sub_matches, "aconfig")?;
- let overrides = open_zero_or_more_files(sub_matches, "override")?;
- let cache = commands::create_cache(build_id, namespace, aconfigs, overrides)?;
+ let declarations = open_zero_or_more_files(sub_matches, "declarations")?;
+ let values = open_zero_or_more_files(sub_matches, "values")?;
+ let cache = commands::create_cache(namespace, declarations, values)?;
let path = sub_matches.get_one::<String>("cache").unwrap();
let file = fs::File::create(path)?;
cache.write_to_writer(file)?;