I tried to use cargo
code generation as described cargo study code generation, it works in such case:
[package]
name = "hello_world"
build = "build.rs"
where build.rs contains:
let src = Path::new("src/main.rs.in");
let dst = Path::new(&env::var("OUT_DIR").unwrap()).join("main.rs");
registry.expand("hello_world", &src, &dst).unwrap();
all works fine, cargo found and compile generated main.rs
.
But when I try library instead of binary:
[package]
name = "hello_world"
build = "build.rs"
[lib]
name = "test"
crate-type = ["cdylib"]
and replace main.rs.in with lib.rs.in compilation failed,
the problem is that cargo not search lib.rs in "target" directory,
why so and how can I fix this?