blob: 1ebe2a49307115700194cc8dee30782a43f19f91 [file] [log] [blame]
Shikha Panwar6d306412024-02-17 21:37:49 +00001// Copyright 2024, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Provide functionality for handling AVF build-time feature flags.
16
17use android_system_virtualizationservice::aidl::android::system::virtualizationservice::{
18 IVirtualizationService::FEATURE_DICE_CHANGES, IVirtualizationService::FEATURE_LLPVM_CHANGES,
Seungjae Yooa6589bd2024-06-11 10:14:07 +090019 IVirtualizationService::FEATURE_MULTI_TENANT, IVirtualizationService::FEATURE_NETWORK,
Shikha Panwar6d306412024-02-17 21:37:49 +000020 IVirtualizationService::FEATURE_REMOTE_ATTESTATION,
21 IVirtualizationService::FEATURE_VENDOR_MODULES,
22};
23use log::warn;
24
25/// Check if an AVF feature is enabled.
26pub fn is_feature_enabled(feature: &str) -> bool {
27 match feature {
28 FEATURE_DICE_CHANGES => cfg!(dice_changes),
29 FEATURE_LLPVM_CHANGES => cfg!(llpvm_changes),
30 FEATURE_MULTI_TENANT => cfg!(multi_tenant),
Seungjae Yooa6589bd2024-06-11 10:14:07 +090031 FEATURE_NETWORK => cfg!(network),
Shikha Panwar6d306412024-02-17 21:37:49 +000032 FEATURE_REMOTE_ATTESTATION => cfg!(remote_attestation),
33 FEATURE_VENDOR_MODULES => cfg!(vendor_modules),
34 _ => {
35 warn!("unknown feature {feature}");
36 false
37 }
38 }
39}