Skip to main content

bitwarden_commercial_marker/
lib.rs

1//! Compile-time marker for Bitwarden commercial (licensed) crates.
2//!
3//! Every crate in `bitwarden_license/` (except this one) must invoke [`commercial_crate!`] once in
4//! its `lib.rs`.
5#![no_std]
6
7/// Marks the calling crate as commercial (Bitwarden-licensed).
8///
9/// Expands to a `compile_error!` when built with `--cfg bitwarden_ensure_non_commercial`, so
10/// commercial code cannot leak into a non-commercial build. Invoke once per commercial crate:
11///
12/// ```ignore
13/// bitwarden_commercial_marker::commercial_crate!();
14/// ```
15#[macro_export]
16macro_rules! commercial_crate {
17    () => {
18        #[cfg(bitwarden_ensure_non_commercial)]
19        ::core::compile_error!(
20            "A commercial (Bitwarden-licensed) crate was compiled with `--cfg bitwarden_ensure_non_commercial` \
21             set. Look for a non-weak `bitwarden-commercial-*/<feature>` reference that should be \
22             `bitwarden-commercial-*?/<feature>`, or a commercial dependency activated outside \
23             `bitwarden-license`."
24        );
25    };
26}
27
28commercial_crate!();