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

Added '--deps-only' to {build, doc} subcommands #3567

Closed

Conversation

KalitaAlexey
Copy link
Contributor

@KalitaAlexey KalitaAlexey commented Jan 20, 2017

Please don't merge it.
I haven't added tests.

It works, I just want to hear opinions.
Which subcommands can support "--deps-only"?

How can I prevent the bot from building?

Soon I will describe my changes.

Unresolved questions

What to do if --deps-only is passed but there are no dependencies?

What to do if both --deps-only and --no-deps are passed to cargo doc?

@rust-highfive
Copy link

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@KalitaAlexey
Copy link
Contributor Author

@rust-highfive, stop build.

@KalitaAlexey
Copy link
Contributor Author

@brson,
Hi. I want to write a test checking that there is a library in deps folder. The library has metadata-suffix.
How to deal with it?

@alexcrichton
Copy link
Member

cc #2644

I'm not personally sold on the motivation for such a feature here to add it to Cargo yet. Perhaps we could continue to gather use cases on the issue itself?

@KalitaAlexey
Copy link
Contributor Author

@alexcrichton,
It is useful and easy to add. Why can't we?

@KalitaAlexey
Copy link
Contributor Author

cc #2801

@alexcrichton
Copy link
Member

The implementation is not as easy as you might think. For example the implementation here is incorrect. For example it looks like this will still compile the library of the current package if there's a binary.

I'd like to get more information about use cases before we add such a feature. "it is useful" to me isn't a concrete reason as to why this feature is motivated.

@KalitaAlexey
Copy link
Contributor Author

KalitaAlexey commented Jan 23, 2017

@alexcrichton,

For example it looks like this will still compile the library of the current package if there's a binary.

I can't understand that. Can you rephrase that please?

I will check whether it still compiles a library.

For me it is useful only for cargo doc because my library can be broken and I want to see a documentation to fix my problem, but some people also would like to have it for cargo build.

@alexcrichton
Copy link
Member

@KalitaAlexey I'd encourage you to add some tests to this PR to see the behavior. You can try adding a project with both a library and a binary and then assert that cargo build --no-deps doesn't compile the library.

@KalitaAlexey
Copy link
Contributor Author

@alexcrichton,
Did you mean cargo build --deps-only?

@alexcrichton
Copy link
Member

Ah yes, I do

@KalitaAlexey
Copy link
Contributor Author

Currently I little time.
When I have time I will improve this.

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to resubmit with comments addressed!

@atodorov
Copy link

atodorov commented Aug 2, 2017

@alexcrichton I'm a +1 for using this inside Docker but I'm not sure if we can do this. In my Dockerfile I have:

COPY src/ /bdcs-api-rs/
RUN cd /bdcs-api-rs/ && cargo build

What I want to do is:

COPY src/Cargo.toml /bdcs-api-rs/
RUN cd /bdcs-api-rs/ && cargo build --dependencies-only

COPY src/ /bdcs-api-rs/
RUN cd /bdcs-api-rs/ && cargo build

so that I rebuild the dependencies only if they changed and I can reuse the intermediate Docker container running the --dependencies-only step.

Is it possible to implement this option without having the source code available, only Cargo.toml and/or Cargo.lock ? If yes can you point to some places in the code I may be able to produce a PR ?

@alexcrichton
Copy link
Member

@atodorov right now Cargo's not really built to cater to that use case unfortunately. Getting that working in a reliable fashion would be pretty difficult.

@atodorov
Copy link

FYI I've managed to work around this by using cargo build -p and a small Python script to parse Cargo.toml. Works well for me. If you need to see examples checkout my blog.

@nacardin
Copy link

nacardin commented Mar 7, 2018

I just published a cargo extension crate to make this easier. I've been using it in one of my projects. https://crates.io/crates/cargo-build-deps
Feedback via issues/PRs would be appreciated. https://github.com/nacardin/cargo-build-deps

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.

6 participants