-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add --dep-info flag to write Makefile compatible dependency files #10698
Conversation
Out of curiosity, why are we reviving this issue? Or more specifically, why is the rustpkg solution not being used? |
It doesn't look like rustpkg will be ready to handle all of Servo's needs in the near future and I want more reliable builds. With a few small changes (this + #10593) external build tooling becomes much easier to use. |
It sounds like this should maybe be a |
Why wouldn't we support it? There will always be reasons to use external build tooling, such as when non-Rust projects take Rust libraries as dependencies. |
I agree with @metajack. This is a useful flag that we should support. |
This should also have a test, just to make sure that nothing dies along this path. |
Rebased. Need to add a test still. |
@alexcrichton r? test added. The rest was previously reviewed by @pcwalton although it had a minor interaction with your patches during rebase, so you might take a glace at that. |
@alexcrichton I addressed your comments in two new commits. I'll squash it down after you review. |
When --dep-info is given, rustc will write out a `$input_base.d` file in the output directory that contains Makefile compatible dependency information for use with tools like make and ninja.
Fixed rustpkg's call to phase_6. Otherwise nothing changed. |
Added some minor test fixes to account for TMPDIR. |
This is cool. Makefiles are much easier now. Great work! However, I found a slight problem. When calling rustc twice with the same crate source file, the second compile overwrites the dependency file generated by the first compile. This happens to me when compiling tests from the same source file as the library. |
gcc does indeed have options for specifying the filename, but I didn't use that part, instead implementing the A workaround (and the recommended way I think) is to have tests start from test.rs. You might file a bug to add the ability for |
What do you think about using the target filename with extension replaced by ".d" for the deps file? That sounds more practical to me since you could build more than one target from a source (e.g. with different --cfg settings, or library and test like I tried. I know the recommended way is to build tests from test.rs, but especially for small projects, using the same source file for tests can make things easier). |
That sounds fine to me. Want to submit a PR? :) |
Sure, I'll look into it. May take me a little time since I'm mostly familiar with libstd/libextra and not librustc yet, but changing the name shouldn't be too hard :) |
Using --dep-info writes Makefile-compatible dependency info to a file that is by default named based on the crate source filename. This adds an optional string argument to the --dep-info option which allows to write dependency info to an arbitrary filename. cc #10698
This isn't super useful for libraries yet without #10593.
Fixes #7633.