Skip to main content

camelot_kconfig/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2024 Ledger SAS
4// Copyright 2025 ANSSI
5
6#![no_std]
7
8#[macro_export]
9macro_rules! _get {
10    ($value:ident) => {$value};
11    ($value:ident, $value_type:ty) => {
12        match <$value_type>::from_str_radix($value, 10) {
13            Ok(v) => v,
14            Err(e) => panic!("kconfig conversion error"),
15        }
16    };
17}
18
19#[macro_export]
20macro_rules! get {
21    ($name:expr $(, $value_type:ty)?) => {{
22        const value: &str = match option_env!($name) {
23            Some(v) => v,
24            None => panic!("kconfig entry not found !"),
25        };
26
27        use $crate::_get;
28        _get!(value $(, $value_type)?)
29    }};
30}