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

Code is recompiled each time #730

Closed
vertrex opened this issue Feb 24, 2021 · 4 comments
Closed

Code is recompiled each time #730

vertrex opened this issue Feb 24, 2021 · 4 comments

Comments

@vertrex
Copy link

vertrex commented Feb 24, 2021

Hi,

I use CXX in one of my crate and an other depends of it. Each time I run cargo build or cargo run, my c++ code is recompiled even if there is no change in any file. I tried to use println!("cargo:rerun-if-changed/") but I didn't change anything, must I print for each of the file (I have lot of c++ and header file in sub dir) ?

Tahnk you

@adetaylor
Copy link
Collaborator

Maybe you could use something like WalkDir to output the cargo:rerun-if-changed string for each C++/header file?

I think this is all largely beyond the control of the cxx crate, since we just use cc for our Cargo C++ build.

@dtolnay
Copy link
Owner

dtolnay commented Feb 24, 2021

@vertrex can you provide a minimal repro of this? Ideally the best would be a repo I can check out and run cargo build && cargo build and observe it build two times.

@vertrex
Copy link
Author

vertrex commented Feb 25, 2021

It worked after adding :


    let paths = fs::read_dir("./").unwrap();
    for path in paths { println!("cargo:rerun-if-change={}", path.unwrap().path().display()) }

Thank you

@dtolnay
Copy link
Owner

dtolnay commented Mar 17, 2021

Closing as very likely a consequence of this misbehavior/bug in Cargo: rust-lang/cargo#6003.

@dtolnay dtolnay closed this as completed Mar 17, 2021
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

3 participants