fn prepare_cflags(cflags: &str, kernel_dir: &str) -> Vec<String> {
    let cflag_parts = shlex::split(&cflags).unwrap();
    let mut cflag_iter = cflag_parts.iter();
    let mut kernel_args = vec![];
    while let Some(arg) = cflag_iter.next() {
        if arg.starts_with("-I") && !arg.starts_with("-I/") {
            kernel_args.push(format!("-I{}/{}", kernel_dir, &arg[2..]));
        } else if arg == "-include" {
            kernel_args.push(arg.to_string());
            let include_path = cflag_iter.next().unwrap();
            if include_path.starts_with('/') {
                kernel_args.push(include_path.to_string());
            } else {
                kernel_args.push(format!("{}/{}", kernel_dir, include_path));
            }
        } else {
            kernel_args.push(arg.to_string());
        }
    }
    //    println!("!!! {:?}", kernel_args);
    kernel_args
}
// Takes the CFLAGS from the kernel Makefile and changes all the include paths to be absolute
// instead of relative.
Takes the CFLAGS from the kernel Makefile and changes all the include paths to be absolute
instead of relative.
Takes the CFLAGS from the kernel Makefile and changes all the include paths to be absolute instead of relative .
fn prepare_cflags(cflags: &str, kernel_dir: &str) -> Vec<String> {
    let cflag_parts = shlex::split(&cflags).unwrap();
    let mut cflag_iter = cflag_parts.iter();
    let mut kernel_args = vec![];
    while let Some(arg) = cflag_iter.next() {
        if arg.starts_with("-I") && !arg.starts_with("-I/") {
            kernel_args.push(format!("-I{}/{}", kernel_dir, &arg[2..]));
        } else if arg == "-include" {
            kernel_args.push(arg.to_string());
            let include_path = cflag_iter.next().unwrap();
            if include_path.starts_with('/') {
                kernel_args.push(include_path.to_string());
            } else {
                kernel_args.push(format!("{}/{}", kernel_dir, include_path));
            }
        } else {
            kernel_args.push(arg.to_string());
        }
    }
    //    println!("!!! {:?}", kernel_args);
    kernel_args
}
fn prepare_cflags ( cflags : & str , kernel_dir : & str ) -> Vec < String > { let cflag_parts = shlex :: split ( & cflags ) . unwrap ( ) ; let mut cflag_iter = cflag_parts . iter ( ) ; let mut kernel_args = vec ! [ ] ; while let Some ( arg ) = cflag_iter . next ( ) { if arg . starts_with ( " " ) && ! arg . starts_with ( " " ) { kernel_args . push ( format ! ( " " kernel_dir arg [ 2 ] ) ) ; } else if arg == " " { kernel_args . push ( arg . to_string ( ) ) ; let include_path = cflag_iter . next ( ) . unwrap ( ) ; if include_path . starts_with ( '/' ) { kernel_args . push ( include_path . to_string ( ) ) ; } else { kernel_args . push ( format ! ( " " kernel_dir include_path ) ) ; } } else { kernel_args . push ( arg . to_string ( ) ) ; } } //    println!("!!! {:?}", kernel_args); kernel_args }
Takes the CFLAGS from the kernel Makefile and changes all the include paths to be absolute
instead of relative.
Takes the CFLAGS from the kernel Makefile and changes all the include paths to be absolute instead of relative .
cflags
&str
kernel_dir
&str