Cargo: Sharing `target` directories

Created on 29 Aug 2014  路  7Comments  路  Source: rust-lang/cargo

Projects like servo have many dependencies, all of which need to be tested. It's much easier to set up CI for all of the dependencies once than separately. Right now it's the case that cargo test must be run once in each dependency, causing many libraries to be built many times. It would be much nicer if the target output directories could be shared amongst dependencies (somehow).

A-configuration P-high

Most helpful comment

@metajack not currently, but I can try to flesh something out if needed.

All 7 comments

436 (or its work around) might help?

As I posted on #523, could we have something like cargo [build | test | bench | doc] [PATH...], where cargo would run the specified command using the Cargo.toml located under each PATH, but using a common target directory. This would have the benefit of supporting more complex project structures (although they would require something like a Makefile to compile easily).

Example of a Makefile using this feature:

all: build doc

travis: test doc
    mv target/doc doc

build:
    cargo build src/*/

update:
    cargo update src/*/

clean:
    cargo clean

test:
    cargo test src/*/     # unit tests
    cargo test tests/*/   # integration tests

test-update: update
    cargo update tests/*/

doc:
    cargo doc src/*/

bench:
    cargo bench benches/*/

bench-update: update
    cargo update benches/*/

examples:
    cargo build examples/*/

examples-update: update
    cargo update examples/*/

And the Cargo.toml:

[package]

name = "gfx"
version = "0.1.0"
authors = [
]

build = "make build"

Note the separate update-* targets. This is to ensure that dependencies are not updated for the main build when they are not needed (like [dev_dependencies.*] currently does).

Could cargo test run tests in "path" dependencies? There is precedent of treating those specially: #612

(Servo might still want to run other tests, but this would be a first step.)

Certainly! That's what I would like to implement.

Is this on the radar at all?

@metajack not currently, but I can try to flesh something out if needed.

Was this page helpful?
0 / 5 - 0 ratings