-
Couldn't load subscription status.
- Fork 2.7k
Allow specifying a custom output directory #1657
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
Conversation
This commit adds support to allow specifying a custom output directory to Cargo. First, the `build.target-dir` configuration key is checked, and failing that the `CARGO_TARGET_DIR` environment variable is checked, and failing that the root package's directory joined with the directory name "target" is used. There are a few caveats to switching target directories, however: * If the target directory is in the current source tree, and the folder name is not called "target", then Cargo may walk the output directory when determining whether a tree is fresh. * If the target directory is not called "target", then Cargo may look inside it currently for `Cargo.toml` files to learn about local packages. * Concurrent usage of Cargo will still result in badness (rust-lang#354), and this is now exascerbated because many Cargo projects can share the same output directory. * The top-level crate is not cached for future compilations, so if a crate is built into directory `foo` and then that crate is later used as a dependency, it will be recompiled. The naming limitations can be overcome in time, but for now it greatly simplifies the crawling routines and shouldn't have much of a negative impact other than some Cargo runtimes (which can in turn be negated by following the "target" name convention). Closes rust-lang#482
|
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @wycats cc @larsbergstrom, @metajack, I believe you guys have wanted this in Servo for some time now |
|
Am I correct that this is a solution for target directory sharing? |
80a198f to
014765f
Compare
|
@metajack yeah, I would expect Servo to check in a top-level Alternatively Servo's build system would set the |
|
@alexcrichton thank you very much! |
Hm, doesn't checking in |
|
Right, but |
|
For servo it's probably OK, I'm more thinking about this as a general footgun. |
|
(I don't really have anything concrete to offer to fix/mitigate it, and have no idea if it'll be a problem in practice.) |
|
r? @brson |
|
@bors r+ |
|
📌 Commit 014765f has been approved by |
This commit adds support to allow specifying a custom output directory to Cargo. First, the `build.target-dir` configuration key is checked, and failing that the `CARGO_TARGET_DIR` environment variable is checked, and failing that the root package's directory joined with the directory name "target" is used. There are a few caveats to switching target directories, however: * If the target directory is in the current source tree, and the folder name is not called "target", then Cargo may walk the output directory when determining whether a tree is fresh. * If the target directory is not called "target", then Cargo may look inside it currently for `Cargo.toml` files to learn about local packages. * Concurrent usage of Cargo will still result in badness (#354), and this is now exascerbated because many Cargo projects can share the same output directory. * The top-level crate is not cached for future compilations, so if a crate is built into directory `foo` and then that crate is later used as a dependency, it will be recompiled. The naming limitations can be overcome in time, but for now it greatly simplifies the crawling routines and shouldn't have much of a negative impact other than some Cargo runtimes (which can in turn be negated by following the "target" name convention). Closes #482
|
☀️ Test successful - cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-gnu-32, cargo-win-gnu-64 |
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
(From OE-Core rev: ec7522deaa7d09dd4954320a24a6c0403e135400)
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
(From OE-Core rev: ec7522deaa7d09dd4954320a24a6c0403e135400)
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
(From OE-Core rev: 1452ac7a44196454a52f3f6d883290ddcccfd3f8)
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
(From OE-Core rev: 1452ac7a44196454a52f3f6d883290ddcccfd3f8)
(From OE-Core rev: 9d9ce457630ea7403ffe7028e3370647db0b83fa)
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
The cargo class defaults to out-of-tree builds in WORKDIR/build, but
at no point was that directory cleaned. This causes problems with the
rust standard library recipe (libstd-rs) which installs manually with cp,
so rebuilds can be contaminated with the contents of previous builds.
I believe that post-release we should switch cargo.bbclass to mandating
out-of-tree builds to reduce the complexity, but for now in out-of-tree
builds we can just delete the ${B}/target directory.
Note that we use ${B}/target because there at least were reasons to use
that name[1], it is unclear if these limitations still hold. We can't
simply clean ${B} because that will break recipes that use cargo and
something else to build, for example librsvg.
[1] rust-lang/cargo#1657
(From OE-Core rev: 1452ac7)
Signed-off-by: Ross Burton <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
This commit adds support to allow specifying a custom output directory to Cargo.
First, the
build.target-dirconfiguration key is checked, and failing that theCARGO_TARGET_DIRenvironment variable is checked, and failing that the rootpackage's directory joined with the directory name "target" is used.
There are a few caveats to switching target directories, however:
not called "target", then Cargo may walk the output directory when determining
whether a tree is fresh.
currently for
Cargo.tomlfiles to learn about local packages.exascerbated because many Cargo projects can share the same output directory.
built into directory
fooand then that crate is later used as a dependency,it will be recompiled.
The naming limitations can be overcome in time, but for now it greatly
simplifies the crawling routines and shouldn't have much of a negative impact
other than some Cargo runtimes (which can in turn be negated by following the
"target" name convention).
Closes #482