Kernel CONFIG cfg
I tried to find out how to detect thinks like if CONFIG_DEBUG_KERNEL is set. As I did not see a way, I implemented this way, but not sure if its a good way to handle this things. There for I only create the diff here, and no pr yet. This just passes every CONFIG_* to rustc as a cfg.
diff --git a/rust/kernel/build.rs b/rust/kernel/build.rs index 0897186b3f92..2818bcb1b391 100644 --- a/rust/kernel/build.rs +++ b/rust/kernel/build.rs @@ -92,6 +92,26 @@ fn main() { println!("cargo:rerun-if-env-changed=RUST_BINDGEN_CFLAGS"); let kernel_dir = "../../"; + println!("cargo:rerun-if-changed={}/include/config/auto.conf", kernel_dir); + let file = std::fs::File::open(format!("{}/include/config/auto.conf", kernel_dir)).expect("could not open kernel config"); + let file = std::io::BufReader::new(file); + use std::io::BufRead; + for line in file.lines() { + let line = line.unwrap(); + if !line.contains("=") { + continue; + } + let line: Vec<&str> = line.split("=").collect(); + if line.len() != 2 { + panic!(); + }; + let key = line[0]; + let value = line[1].trim_matches('"'); + + println!("cargo:rustc-cfg={}=\"{}\"", key, value); + }; + + let cflags = env::var("RUST_BINDGEN_CFLAGS").expect("Must be invoked from kernel makefile"); let kernel_args = prepare_cflags(&cflags, &kernel_dir);