Michael-F-Bryan / include_dir

The logical evolution of the include_str macro for embedding a directory tree into your binary.
https://michael-f-bryan.github.io/include_dir
MIT License
319 stars 36 forks source link

Doesn't work with `cargo:rustc-env=VAR=VALUE` #92

Closed eminfedar closed 9 months ago

eminfedar commented 1 year ago

I need to pass an environment variable which I generate on build.rs in my project.

build.rs:

fn main() {
        println!("cargo:rustc-env=MY_PATH=/path/here");
}

main.rs:

fn main() {
        include_dir!("$MY_PATH"); // doesn't work
        include_dir!(env!("MY_PATH")); // doesn't work either
}

If only I run my cargo build command like this, it works:

MY_PATH=/path/here cargo build

I think it should work with others too. Because users should be able to embed a directory which generated by build.rs dynamically.