Closed nsreeen closed 6 years ago
Hmm.
This assumes that everything in the src/
directory should cause a rebuild. And that is not true; e.g., if there are non-.md
/.rs
files stored under src/
(e.g. a notes.txt
file), then this will emit rerun-if-changed
for those files as well.
Now, you could fix that by revising the directory walk to only process file ended with .rs
/.md
. But I have a different suggestion.
Instead, I would add a flag to the Context
struct that tracks whether we need to emit the rerun-if-changed
directive, and then change Context::gather_inputs
to emit the rerun-if-changed
for each input it detects. (Either right before the calls to Context::check_transform
, or within the body of Context::check_transform
.)
thanks @pnkfelix! I started implementing this - rerun-if is now written from gather_inputs, at the point where .rs files are gathered.
I'm still working on emitting rerun-if for build.rs and tango.stamp, and the config struct
@Nasreen123 hmm.
Interesting questions arise about whether it should be tango's job to emit rerun-if
for the build.rs
and for the tango.stamp
...
build.rs
, I'd say that since tango
is not managing that file (instead, it is what drives tango
to run), I'd say you should not have tango
itself emit the rerun-if
directive for it.
rerun-if-changed=build.rs
in order to get sane behavior from cargo
, then I would argue that such a directive is the responsibility of the build.rs
script itself (or maybe some other library it is using), but is not the responsibility of tango.tango.stamp
file ... I cannot imagine a use-case where the user would be updating that file or touching it, but if they do, then I guess the right thing would nonetheless be to rerun tango
, I think... so including that in your output seems okay me, at least at first.
Hi @pnkfelix Now rerun-if is being written only for md and rs files in the src folder. You're right that build.rs doesn't need one - changing it always triggers a rebuild. Manually testing things things are working as expected, I'm still working on tests
Thanks Nasreen!
This introduces a second entry point as described in issue #12.
The new function (
process_root_and_emit_rerun
) writes acargo:rerun-if-changed=PATH
directive for each file tango manages or interacts with in a calling crate. These lines are written to the build script output file of the calling crate, where cargo will read them.This makes sure that if any of the files tango is interested in change, the calling crate will be rebuilt.