Skip to content

Commit

Permalink
td: Add a check_knob util
Browse files Browse the repository at this point in the history
Summary: It's a little annoying to write all the `cfg` boilerplate again and again.

Reviewed By: Acesine

Differential Revision: D55648146

fbshipit-source-id: ab30c9714dfd8a40861ee7ec39ef15fa8de04e6d
  • Loading branch information
Aniket Mathur authored and facebook-github-bot committed Apr 3, 2024
1 parent 2a0a770 commit 50b5cf4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions td_util/src/knobs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/

#[cfg(any(not(fbcode_build), not(target_os = "linux")))]
pub fn check_boolean_knob(name: &str) -> bool {
false
}

#[cfg(all(fbcode_build, target_os = "linux"))]
pub fn check_boolean_knob(name: &str) -> bool {
justknobs::eval(name, None, None).unwrap_or(false)
}
1 change: 1 addition & 0 deletions td_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod cli;
pub mod command;
pub mod directives;
pub mod json;
pub mod knobs;
pub mod no_hash;
pub mod prelude;
pub mod project;
Expand Down

0 comments on commit 50b5cf4

Please sign in to comment.