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

Support adding new file after compilation #22

Open
jc4x4 opened this issue Mar 27, 2024 · 2 comments
Open

Support adding new file after compilation #22

jc4x4 opened this issue Mar 27, 2024 · 2 comments

Comments

@jc4x4
Copy link

jc4x4 commented Mar 27, 2024

I noticed that if I add a new file after a build, the new file would not be included in the next run. I have to manually clean the build cache via cargo clean. Is there a better/automatic way of doing this?

@dtolnay
Copy link
Owner

dtolnay commented Mar 27, 2024

I think if you add a build.rs containing the following (where path/to/dir is the relative path from the directory containing Cargo.toml to the directory containing the automatically included files) then it'll rebuild when a file is added:

fn main() {
    println!("cargo:rerun-if-changed=path/to/dir");
}

@jc4x4
Copy link
Author

jc4x4 commented Mar 28, 2024

Right, this is also what I got after searching for a while. I can confirm it works well. It would be nice to call this out in the example in the README.md. Here is a PR: #23.

i.e.

fn main() {
    println!("cargo:rerun-if-changed=tests/regression");
}

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

No branches or pull requests

2 participants