xref: /aosp_15_r20/build/make/tools/aconfig/aconfig_flags/src/lib.rs (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //! `aconfig_flags` is a crate for reading aconfig flags from Rust
18 // When building with the Android tool-chain
19 //
20 //   - the flag functions will read from aconfig_flags_inner
21 //   - the feature "cargo" will be disabled
22 //
23 // When building with cargo
24 //
25 //   - the flag functions will all return some trivial value, like true
26 //   - the feature "cargo" will be enabled
27 //
28 // This module hides these differences from the rest of aconfig.
29 
30 /// Module used when building with the Android tool-chain
31 #[cfg(not(feature = "cargo"))]
32 pub mod auto_generated {
33     /// Returns the value for the enable_only_new_storage flag.
enable_only_new_storage() -> bool34     pub fn enable_only_new_storage() -> bool {
35         aconfig_flags_rust::enable_only_new_storage()
36     }
37 
38     /// Returns the value for the enable_aconfigd_from_mainline flag.
enable_aconfigd_from_mainline() -> bool39     pub fn enable_aconfigd_from_mainline() -> bool {
40         aconfig_flags_rust::enable_only_new_storage()
41     }
42 }
43 
44 /// Module used when building with cargo
45 #[cfg(feature = "cargo")]
46 pub mod auto_generated {
47     /// Returns a placeholder value for the enable_only_new_storage flag.
enable_only_new_storage() -> bool48     pub fn enable_only_new_storage() -> bool {
49         // Used only to enable typechecking and testing with cargo
50         true
51     }
52 
53     /// Returns a placeholder value for the enable_aconfigd_from_mainline flag.
enable_aconfigd_from_mainline() -> bool54     pub fn enable_aconfigd_from_mainline() -> bool {
55         // Used only to enable typechecking and testing with cargo
56         true
57     }
58 }
59