Remove the hand-crafted wrappers around the structures auto-generated from protos/aconfig.proto, and use the auto-generated structs directly intead. This gets rid of a lot of manual repetition, and its inherent risk. Also unify how individual fields read from text proto are verified (e.g. is the flag.name field a valid identifier). Also change the intermediate cache format from JSON to binary protobuf. The concept of a 'cache' as an intermediate internal format to represent parsed input stays. The command line interface still refers to caches. At the moment a cache file is identical to a parsed_file protbuf, and the code exploits this internally. A couple of points regarding the auto-generated structs: - Vectors are named in the singular (e.g. parsed_flags.parsed_flag is a Vec<ProtoParsedFlag>) because this improves ergonomics for all devs working with aconfig input files - The auto-generated structs have fields that are of type Option<T> and convenience methods (named the same as the fields) to access T Test: atest aconfig.test aconfig.test.java Bug: 283910447 Change-Id: I512820cc4bc6c543dea9f6a4356f863120a10be3
30 lines
615 B
Plaintext
30 lines
615 B
Plaintext
{{- for mod in modules -}}
|
|
pub mod {mod} \{
|
|
{{ endfor -}}
|
|
{{- for flag in template_flags -}}
|
|
{{- if flag.is_read_only_disabled -}}
|
|
#[inline(always)]
|
|
pub const fn r#{flag.name}() -> bool \{
|
|
false
|
|
}
|
|
|
|
{{ endif -}}
|
|
{{- if flag.is_read_only_enabled -}}
|
|
#[inline(always)]
|
|
pub const fn r#{flag.name}() -> bool \{
|
|
true
|
|
}
|
|
|
|
{{ endif -}}
|
|
{{- if flag.is_read_write -}}
|
|
#[inline(always)]
|
|
pub fn r#{flag.name}() -> bool \{
|
|
flags_rust::GetServerConfigurableFlag("{flag.device_config_namespace}", "{flag.device_config_flag}", "false") == "true"
|
|
}
|
|
|
|
{{ endif -}}
|
|
{{- endfor -}}
|
|
{{- for mod in modules -}}
|
|
}
|
|
{{ endfor -}}
|