Closed ghost closed 6 years ago
I just tested on Mac with rustc 1.24.0-nightly (cargo 0.25.0-nightly) - if I change (or just touch) main.rs and make, then the env BUILD_DATE
changes on each make
.
I can confirm the same! And I've also tested it on a new project and even a project within a workspace, both seem to update as expected!
I must be hitting an edge case for my particular project and I wrongly assumed it happens for any project!
Apologies for wasting your time. I will edit this post if I figure out what was that edge case for my project.
Closing, as it's obviously not an issue for cicada!
Never mind @xftroxgpx, we all learners :)
Thanks @mitnk !
Figured it out.
It failed for me because I had this line in my build.rs
println!("cargo:rerun-if-env-changed=A"); //if the environment variable's value changes the build script should be rerun.
If I remove the line, it works as intended. Otherwise, sometimes, it just won't recompile build.rs
after src/main.rs
is touched.
Doc for that is here: http://doc.crates.io/build-script.html#outputs-of-the-build-script
Seems like a cargo bug, or I'm misunderstanding something here.
Simple test project here My convoluted test project is here
PS: was using cargo 0.26.0 (git master) and rustc 1.24.0-dev (687d3d15b 2018-01-02), in this whole thread.
How do you ensure that the
BUILD_DATE
env var from here: https://github.com/mitnk/cicada/blob/340e8136465863c07832c9a19261c0b75b4034a5/src/build.rs#L15 is being updated upon each successful compilation, without having to manuallymake clean
beforemake
?If my understanding is correct(and I tested this a lil bit on my test project),
cargo
caches the output ofbuild.rs
and if you justtouch src/main.rs
for example, but not alsotouch build.rs
, it will use the cached output and thusBUILD_DATE
(and GIT_HASH for that matter) will be the stale one.