Skip to content
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

Option to use file polling with cargo watch #2

Merged
merged 3 commits into from
Aug 22, 2023
Merged

Option to use file polling with cargo watch #2

merged 3 commits into from
Aug 22, 2023

Conversation

paul-hansen
Copy link
Contributor

Cargo watch has a --poll flag that is useful in situations where you can't rely on filesystem events being consistent. This PR exposes that flag as a field on HotReloadPlugin.

This is especially useful when using WSL as you might be modifying the files in Windows and running in WSL or vice versa and WSL sadly doesn't send the file events between the two systems. I added some simple WSL detection to enable polling by default for those cases.

I also made a slight change to the feature cfg for build() to reduce some indentation that I added in my previous PR.

@DGriffin91
Copy link
Owner

@paul-hansen Thanks for the contribution! I'm assuming you tested this with WSL? I'm not currently setup to test it. The WSL check looks a bit janky, but if that's a somewhat accepted way of checking, I'm fine with it. Make sure to use cargo fmt if you're not already.

@paul-hansen
Copy link
Contributor Author

I've been mostly using WSL for making Windows builds and running them while in a WSL path. (Rust compiles faster in WSL.) So I've tested the non-linux detection, but I haven't gotten Bevy wsl linux builds to actually run so I haven't tested the linux check. I borrowed most of that from: https://docs.rs/wsl/0.1.0/src/wsl/lib.rs.html#1-27

This is the best source for confirmation for how to detect it I've found: microsoft/WSL#423 (comment) (comment from a wsl developer).

Here's the output of /proc/sys/kernel/osrelease from my WSL instance:
image

Make sure to use cargo fmt if you're not already.

I am, clippy too. Not sure why it wasn't formatting what I fixed with the "Fix indentation" commit, I thought that was kind of odd. Something tripping it up.

@paul-hansen
Copy link
Contributor Author

If you want I can remove the WSL check and just have this PR add the poll option and default to false. That way you don't have to worry about maintaining it.

@DGriffin91
Copy link
Owner

DGriffin91 commented Aug 22, 2023

Your sources seem like reason enough for me. If there's issues in the future we'll address them then.

@DGriffin91 DGriffin91 merged commit b88668f into DGriffin91:main Aug 22, 2023
@paul-hansen paul-hansen deleted the polling branch August 28, 2023 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants