aconfig: add support for changing flag value based on build
Teach aconfig about build IDs (continuously increasing integers). Extend
the aconfig file format to allow flags to say "by default, my value is
X, but starting from build ID A, it's Y, and from build ID B, it's Z".
Bug: 279485059
Test: atest aconfig.test
Change-Id: Idde03dee06f6cb9041c0dd4ca917c8b2f2faafdd
diff --git a/tools/aconfig/src/main.rs b/tools/aconfig/src/main.rs
index 79ac920..3ce9747 100644
--- a/tools/aconfig/src/main.rs
+++ b/tools/aconfig/src/main.rs
@@ -33,6 +33,12 @@
.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("aconfig").long("aconfig").action(ArgAction::Append))
.arg(Arg::new("override").long("override").action(ArgAction::Append))
.arg(Arg::new("cache").long("cache").required(true)),
@@ -52,6 +58,7 @@
match matches.subcommand() {
Some(("create-cache", sub_matches)) => {
let mut aconfigs = vec![];
+ let build_id = *sub_matches.get_one::<u32>("build-id").unwrap();
for path in
sub_matches.get_many::<String>("aconfig").unwrap_or_default().collect::<Vec<_>>()
{
@@ -65,7 +72,7 @@
let file = Box::new(fs::File::open(path)?);
overrides.push(Input { source: Source::File(path.to_string()), reader: file });
}
- let cache = commands::create_cache(aconfigs, overrides)?;
+ let cache = commands::create_cache(build_id, aconfigs, overrides)?;
let path = sub_matches.get_one::<String>("cache").unwrap();
let file = fs::File::create(path)?;
cache.write_to_writer(file)?;