-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.rs
More file actions
42 lines (37 loc) · 1.14 KB
/
build.rs
File metadata and controls
42 lines (37 loc) · 1.14 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::{env, fs, path::PathBuf};
fn main() {
autocfg::rerun_path("build.rs");
let ac = autocfg::new();
autocfg::emit_possibility("borrowedbuf_init");
let code = r#"
#![no_std]
#![feature(core_io_borrowed_buf)]
pub fn probe() {
let _ = core::io::BorrowedBuf::init_len;
}
"#;
if ac.probe_raw(code).is_ok() {
autocfg::emit("borrowedbuf_init");
}
autocfg::emit_possibility("maybe_uninit_slice");
let code = r#"
#![no_std]
pub fn probe() {
let _ = <[core::mem::MaybeUninit<()>]>::assume_init_mut;
}
"#;
if ac.probe_raw(code).is_ok() {
autocfg::emit("maybe_uninit_slice");
}
let buf_size = env::var("AXIO_DEFAULT_BUF_SIZE")
.map(|v| v.parse::<usize>().expect("Invalid AXIO_DEFAULT_BUF_SIZE"))
.unwrap_or(1024 * 2);
fs::write(
PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("config.rs"),
format!(
"/// Default buffer size for I/O operations.\npub const DEFAULT_BUF_SIZE: usize = {};",
buf_size
),
)
.expect("Failed to write config file");
}