-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
28 lines (24 loc) · 881 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::{env, path::PathBuf};
fn main() {
println!("cargo:rerun-if-env-changed=DEFMT_BRTT_BUFFER_SIZE");
let size = env::var("DEFMT_BRTT_BUFFER_SIZE")
.map(|s| {
s.parse()
.expect("could not parse DEFMT_BRTT_BUFFER_SIZE as usize")
})
.unwrap_or(1024_usize);
let out_dir_path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let out_file_path = out_dir_path.join("consts.rs");
std::fs::write(
out_file_path,
format!(
"/// BBQ & RTT buffer size (default: 1024. Consumed twice, once for RTT and once for BBQueue).
///
/// Can be customized by setting the `DEFMT_BRTT_BUFFER_SIZE` environment variable.
/// Use a power of 2 for best performance.
pub const BUF_SIZE: usize = {};",
size
),
)
.unwrap();
}