-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Modifying the file included with flate!
doesn't automatically trigger rebuild
#12
Comments
Build scripts typically solve this problem by printing |
I did a little research and came across those two issues:
These seem to be the exact features fixing this bug would need, so I guess we're waiting on those. That being said, the author of the second issue did include his current workaround in his post. Maybe this is something we can do too in the meantime? I'll give it a try. |
The workaround is fine for relative paths. But it seems to break builds when using absolute paths. For example, given a path The root cause of this seems to be |
Interesting. I'll admit I did not consider absolute paths at all, although why would you want to do so? I'm curious. |
After thinking about this for a bit on what can be done, I don't think there exists a perfect fix for this problem right now. It's not possible, as far as I know, to conditionally include a file without procedural macros; and the only way to track a file in procedural macros is with the unstable
@evolutics @SOF3 what do you think? |
Is there an actual example scenario why you'd include an absolute path outside the workspace? |
I struggle to think of one, although to be fair, there are provisions for this case in the proc macro: include-flate/codegen/src/lib.rs Lines 74 to 78 in 363fd4f
|
Thanks for your ideas. Just to be clear about my motivation: I don't need to use absolute paths. My use case is only a demo example of how to use another library in combination with Up to you to decide. Yet another alternative might be to simply not support absolute paths if people only need relative paths anyway. |
@SOF3 what do you think I should do? Perhaps completely remove support for absolute paths and explicitly state so in docs? Or should I keep support and implement one of the above workarounds? |
Personally I don't see any good reason for including absolute paths (other than using devfs or procfs, which is probably dangerous either way). I would opt for explicitly dropping support for absolute paths. (Alright, maybe you want to use /etc/hostname, but you don't need to deflate that right?) |
To reproduce:
main.rs
:foo.bar
under crate root, and write some contentcargo run
, and observe that the content offoo.bar
is correctly printedfoo.bar
and savecargo run
again, and observe that a rebuild is not triggered, and the old contents offoo.bar
are printedflate!
withinclude_str!
, repeat steps 2-5, and observe that a rebuild is triggeredI am reporting this as a bug primarily because
include-flate
is advertised as a drop-in replacement forinclude_str
, so this difference in behaviour could be confusing.Also I agree with the standard library that automatically triggering a rebuild is the sensible default, so
include-flate
should try to replicate this behaviour. That being said, I'm not too familiar with the implementation details ofinclude_str!
, so perhaps it's driven by compiler magic and the automatic rebuild behaviour is not replicable in third-party crates, I'm not sure.The text was updated successfully, but these errors were encountered: