add allow package list
This change adds allow_package_list which could include package name of
the flag, so that the tool can allow all flags in the package to be
exported. This should be removed once the build system can figure out
the flags and the current build target.
Test: m all_aconfig_declarations
Bug: 336800305
Change-Id: Ib55f573c80eaff9648c36baedd515a3554d5bcf2
diff --git a/tools/aconfig/exported_flag_check/allow_list.txt b/tools/aconfig/exported_flag_check/allow_flag_list.txt
similarity index 100%
rename from tools/aconfig/exported_flag_check/allow_list.txt
rename to tools/aconfig/exported_flag_check/allow_flag_list.txt
diff --git a/tools/aconfig/exported_flag_check/allow_package_list.txt b/tools/aconfig/exported_flag_check/allow_package_list.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/aconfig/exported_flag_check/allow_package_list.txt
diff --git a/tools/aconfig/exported_flag_check/src/utils.rs b/tools/aconfig/exported_flag_check/src/utils.rs
index 2c30424..3686fec 100644
--- a/tools/aconfig/exported_flag_check/src/utils.rs
+++ b/tools/aconfig/exported_flag_check/src/utils.rs
@@ -60,9 +60,15 @@
Ok(HashSet::from_iter(iter))
}
-fn get_allow_list() -> Result<HashSet<FlagId>> {
+fn get_allow_flag_list() -> Result<HashSet<FlagId>> {
let allow_list: HashSet<FlagId> =
- include_str!("../allow_list.txt").lines().map(|x| x.into()).collect();
+ include_str!("../allow_flag_list.txt").lines().map(|x| x.into()).collect();
+ Ok(allow_list)
+}
+
+fn get_allow_package_list() -> Result<HashSet<FlagId>> {
+ let allow_list: HashSet<FlagId> =
+ include_str!("../allow_package_list.txt").lines().map(|x| x.into()).collect();
Ok(allow_list)
}
@@ -73,7 +79,9 @@
all_flags: &HashSet<FlagId>,
already_finalized_flags: &HashSet<FlagId>,
) -> Result<Vec<FlagId>> {
- let allow_list = get_allow_list()?;
+ let allow_flag_list = get_allow_flag_list()?;
+ let allow_package_list = get_allow_package_list()?;
+
let new_flags: Vec<FlagId> = all_flags
.difference(flags_used_with_flaggedapi_annotation)
.cloned()
@@ -81,11 +89,19 @@
.difference(already_finalized_flags)
.cloned()
.collect::<HashSet<_>>()
- .difference(&allow_list)
+ .difference(&allow_flag_list)
+ .filter(|flag| {
+ if let Some(last_dot_index) = flag.rfind('.') {
+ let package_name = &flag[..last_dot_index];
+ !allow_package_list.contains(package_name)
+ } else {
+ true
+ }
+ })
.cloned()
.collect();
- Ok(new_flags.into_iter().collect())
+ Ok(new_flags)
}
#[cfg(test)]