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

Use `rerun-if` features to detect when code needs rebuilding #230

Open
Diggsey opened this issue Aug 9, 2017 · 5 comments
Open

Use `rerun-if` features to detect when code needs rebuilding #230

Diggsey opened this issue Aug 9, 2017 · 5 comments

Comments

@Diggsey
Copy link

@Diggsey Diggsey commented Aug 9, 2017

No description provided.

@alexcrichton

This comment has been minimized.

Copy link
Owner

@alexcrichton alexcrichton commented Aug 10, 2017

I've historically avoided this for a few reasons:

  • Right now header files aren't tracked
  • If gcc isn't the only thing in a build script the messages printed out would be wrong

The first point is a must-have for this feature and the latter is a "maybe this should be opt in" but probably not.

@Diggsey

This comment has been minimized.

Copy link
Author

@Diggsey Diggsey commented Aug 10, 2017

Header dependency tracking is something of a solved problem AIUI - you just need to invoke the compiler with certain flags, so the real challenge there will be getting a portable solution.

It looks easy enough with MSVC: https://docs.microsoft.com/en-gb/cpp/build/reference/showincludes-list-include-files

And GCC has the -H option: https://stackoverflow.com/a/20477307

WRT to the second item - aren't the lines output from the build script interpreted entirely independently by cargo?

@alexcrichton

This comment has been minimized.

Copy link
Owner

@alexcrichton alexcrichton commented Aug 10, 2017

Yes my point is that this is not implemented, nor was it mentioned in the issue description. I wanted to outline why this isn't trivial to implement today and what needs to be done to close this issue.

If you use gcc for some parts of a build script but also use other files (e.g. code generation) in other parts of a build script, then gcc printing out the files it uses requires the other parts of the build script to also do so to work correctly. That may or may not be the case today.

@marco-c

This comment has been minimized.

Copy link

@marco-c marco-c commented May 28, 2018

Even if I manually add println!("cargo:rerun-if-changed=PATH_TO_C_FILE");, my C files are still getting rebuilt. I wonder why. Is there a way to check what the output of build.rs is?

@Diggsey

This comment has been minimized.

Copy link
Author

@Diggsey Diggsey commented May 28, 2018

Yes, the output from the build file is saved to target/<target>/build/<crate_name>/output (note there will be multiple directories with your crate name and a different hash).

After a clean build there should be exactly two directories with your crate name: one of them will contain the binary of the compiled build script, and the other will contain the output file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.