Loading Cargo.toml +6 −0 Original line number Diff line number Diff line Loading @@ -35,3 +35,9 @@ members = [ "system/gd/rust/linux/utils", "floss/hcidoc", ] [patch.crates-io] # When building out of ChromiumOS, we do not actually use featured. # Stub it to avoid downloading the platform2 repository. # See also: https://github.com/rust-lang/cargo/issues/4544 featured = { path = "system/gd/rust/linux/repositories/featured_stub" } # ignored by ebuild system/gd/rust/linux/repositories/featured_stub/Cargo.toml 0 → 100644 +5 −0 Original line number Diff line number Diff line [package] name = "featured" version = "0.1.0" authors = ["The ChromiumOS Authors"] edition = "2021" system/gd/rust/linux/repositories/featured_stub/src/lib.rs 0 → 100644 +1 −0 Original line number Diff line number Diff line // Copyright 2024 The ChromiumOS Authors system/gd/rust/linux/utils/Cargo.toml +5 −0 Original line number Diff line number Diff line Loading @@ -17,9 +17,14 @@ name = "bt_utils" version = "0.0.1" edition = "2021" [features] chromeos = ["featured"] [dependencies] bt_topshim = { path = "../../topshim" } cfg-if = "1.0.0" featured = { version = "0.1.0", optional = true } libc = "0.2" log = "0.4.14" nix = "0.23" Loading system/gd/rust/linux/utils/src/features.rs 0 → 100644 +21 −0 Original line number Diff line number Diff line //! This library provides Chrome feature query service. #[cfg(feature = "chromeos")] use featured::CheckFeature; /// Queries whether the specified Chrome feature is enabled. /// Returns false when the build is not for ChromeOS. pub fn is_feature_enabled(name: &str) -> Result<bool, Box<dyn std::error::Error>> { cfg_if::cfg_if! { if #[cfg(feature = "chromeos")] { let feature = featured::Feature::new(&name, false)?; let resp = featured::PlatformFeatures::get()? .is_feature_enabled_blocking(&feature); Ok(resp) } else { Ok(false) } } } Loading
Cargo.toml +6 −0 Original line number Diff line number Diff line Loading @@ -35,3 +35,9 @@ members = [ "system/gd/rust/linux/utils", "floss/hcidoc", ] [patch.crates-io] # When building out of ChromiumOS, we do not actually use featured. # Stub it to avoid downloading the platform2 repository. # See also: https://github.com/rust-lang/cargo/issues/4544 featured = { path = "system/gd/rust/linux/repositories/featured_stub" } # ignored by ebuild
system/gd/rust/linux/repositories/featured_stub/Cargo.toml 0 → 100644 +5 −0 Original line number Diff line number Diff line [package] name = "featured" version = "0.1.0" authors = ["The ChromiumOS Authors"] edition = "2021"
system/gd/rust/linux/repositories/featured_stub/src/lib.rs 0 → 100644 +1 −0 Original line number Diff line number Diff line // Copyright 2024 The ChromiumOS Authors
system/gd/rust/linux/utils/Cargo.toml +5 −0 Original line number Diff line number Diff line Loading @@ -17,9 +17,14 @@ name = "bt_utils" version = "0.0.1" edition = "2021" [features] chromeos = ["featured"] [dependencies] bt_topshim = { path = "../../topshim" } cfg-if = "1.0.0" featured = { version = "0.1.0", optional = true } libc = "0.2" log = "0.4.14" nix = "0.23" Loading
system/gd/rust/linux/utils/src/features.rs 0 → 100644 +21 −0 Original line number Diff line number Diff line //! This library provides Chrome feature query service. #[cfg(feature = "chromeos")] use featured::CheckFeature; /// Queries whether the specified Chrome feature is enabled. /// Returns false when the build is not for ChromeOS. pub fn is_feature_enabled(name: &str) -> Result<bool, Box<dyn std::error::Error>> { cfg_if::cfg_if! { if #[cfg(feature = "chromeos")] { let feature = featured::Feature::new(&name, false)?; let resp = featured::PlatformFeatures::get()? .is_feature_enabled_blocking(&feature); Ok(resp) } else { Ok(false) } } }