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
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants
@KalitaAlexey
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Jan 20, 2017

r? @brson

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

r? @brson

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

@KalitaAlexey

This comment has been minimized.

Show comment
Hide comment
@KalitaAlexey

KalitaAlexey Jan 20, 2017

Contributor

@rust-highfive, stop build.

Contributor

KalitaAlexey commented Jan 20, 2017

@rust-highfive, stop build.

@KalitaAlexey

This comment has been minimized.

Show comment
Hide comment
@KalitaAlexey

KalitaAlexey Jan 20, 2017

Contributor

@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?

Contributor

KalitaAlexey commented Jan 20, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jan 20, 2017

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?

Member

alexcrichton commented Jan 20, 2017

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

This comment has been minimized.

Show comment
Hide comment
@KalitaAlexey

KalitaAlexey Jan 21, 2017

Contributor

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

Contributor

KalitaAlexey commented Jan 21, 2017

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

@KalitaAlexey

This comment has been minimized.

Show comment
Hide comment
Contributor

KalitaAlexey commented Jan 21, 2017

cc #2801

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jan 23, 2017

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.

Member

alexcrichton commented Jan 23, 2017

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

This comment has been minimized.

Show comment
Hide comment
@KalitaAlexey

KalitaAlexey Jan 23, 2017

Contributor

@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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jan 24, 2017

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.

Member

alexcrichton commented Jan 24, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@KalitaAlexey

KalitaAlexey Jan 24, 2017

Contributor

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

Contributor

KalitaAlexey commented Jan 24, 2017

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

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jan 27, 2017

Member

Ah yes, I do

Member

alexcrichton commented Jan 27, 2017

Ah yes, I do

@KalitaAlexey

This comment has been minimized.

Show comment
Hide comment
@KalitaAlexey

KalitaAlexey Jan 27, 2017

Contributor

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

Contributor

KalitaAlexey commented Jan 27, 2017

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

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Apr 4, 2017

Member

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

Member

alexcrichton commented Apr 4, 2017

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

@atodorov

This comment has been minimized.

Show comment
Hide comment
@atodorov

atodorov 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 ?

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

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Aug 9, 2017

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.

Member

alexcrichton commented Aug 9, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@atodorov

atodorov Aug 30, 2017

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.

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

This comment has been minimized.

Show comment
Hide comment
@nacardin

nacardin 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

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