forked from FutureSDR/FutureSDR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
49 lines (42 loc) · 1.56 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use rustc_version::{version_meta, Channel};
#[cfg(feature = "lttng")]
fn gen_lttng_tracepoints() {
use lttng_ust_generate::{CIntegerType, CTFType, Generator, Provider};
use std::env;
use std::path::PathBuf;
let mut provider = Provider::new("futuresdr");
let c = provider
.create_class("samples")
.add_field("block", CTFType::Integer(CIntegerType::U64))
.add_field("samples", CTFType::Integer(CIntegerType::U64));
c.instantiate("rx");
c.instantiate("tx");
let output_file_name = PathBuf::from(env::var("OUT_DIR").unwrap()).join("tracepoints.rs");
Generator::default()
.generated_lib_name("futuresdr")
.register_provider(provider)
.output_file_name(&output_file_name)
.generate()
.expect("Unable to generate tracepoint bindings");
let bindings = std::fs::read_to_string(&output_file_name).expect("output file name not found");
let bindings = bindings.replace("pub(", "#[allow(dead_code)]\npub(");
std::fs::write(output_file_name, bindings).expect("writing back bindings failed");
}
fn main() {
match version_meta().unwrap().channel {
Channel::Stable => {
println!("cargo:rustc-cfg=RUSTC_IS_STABLE");
}
Channel::Beta => {
println!("cargo:rustc-cfg=RUSTC_IS_BETA");
}
Channel::Nightly => {
println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY");
}
Channel::Dev => {
println!("cargo:rustc-cfg=RUSTC_IS_DEV");
}
}
#[cfg(feature = "lttng")]
gen_lttng_tracepoints();
}