bors [Sat, 26 Aug 2017 17:57:40 +0000 (17:57 +0000)]
Auto merge of #4358 - Mark-Simulacrum:fix-cfg-cargo, r=alexcrichton
Discover crate type information late if necessary.
Some crates aren't found during eager crate-type searching due to being behind `cfg(...)` flags. We still want to be able to handle these, though, so when necessary we now call rustc again to get crate-type information for these cfg-ed crates.
This is necessary for https://github.com/rust-lang/rust/pull/41991.
Mark Simulacrum [Mon, 21 Aug 2017 11:46:31 +0000 (05:46 -0600)]
Discover crate type information late if necessary.
Some crates aren't found during eager crate-type searching due to being
behind `cfg(...)` flags. We still want to be able to handle these,
though, so when necessary we now call rustc again to get crate-type
information for these cfg-ed crates.
bors [Fri, 25 Aug 2017 16:02:02 +0000 (16:02 +0000)]
Auto merge of #4433 - alexcrichton:unstable-features, r=matklad
Add infrastructure for nightly features and flags
This PR starts adding infrastructure in Cargo for nightly features and nightly flags. The current design looks like:
* There's a new `package.cargo-features` manifest key which accepts an array of strings. This array of strings is the list of enabled Cargo features for that crate.
* A new suite of flags behind `-Z`, like the compiler, are accepted on the command line for all commands.
* Features and unstable flags in Cargo are required to be used on Cargo's nightly channel, which is the same as Rust's nightly channel.
* Features and unstable flags cannot be used on the stable/beta channels of Rust/Cargo.
* Crates which enable features in their manifest are disallowed from being published to crates.io
The motivation behind this support is unblock a number of efforts in Cargo by allowing them to safely get implemented behind a nightly feature gate. Once behind a feature gate they can iterate in-tree without having to worry about "insta stability" and we can also get valuable usage feedback about upstream users.
bors [Thu, 24 Aug 2017 13:56:50 +0000 (13:56 +0000)]
Auto merge of #4431 - vignesh-sankaran:maintenance-badge-docs, r=alexcrichton
Add maintenance badge docs
Pending merging of [this PR for crates.io](https://github.com/rust-lang/crates.io/pull/952). This should close off [#704 on crates.io](https://github.com/rust-lang/crates.io/issues/704). I've also updated the badge metadata docs and reordered the fields into groups by build, code coverage, and maintenance.
So I've decided to put the list of possible badge options in the documentation, we'll have to find another place to put more detailed descriptions of the available maintenance badges.
bors [Tue, 22 Aug 2017 15:26:56 +0000 (15:26 +0000)]
Auto merge of #4424 - Xanewok:process-builder-api, r=alexcrichton
Add `fn args_replace` and `fn get_program` to `ProcessBuilder`
`Executor::exec()` provides a `ProcessBuilder` argument representing compiler call and if someone wants to use it or modify it for their own purposes, they have to (partially) recreate it themselves.
This:
* makes the argument modification possible (via `args_replace`, analogous to `env_remove`)
* exposes the program that will be run (via `get_program`, in case `rustc` is overriden via wrapper etc.).
bors [Sun, 20 Aug 2017 18:35:22 +0000 (18:35 +0000)]
Auto merge of #4416 - Xanewok:more-executor-params, r=alexcrichton
Expose `Target` and `Unit` params to appropriate `Executor` callbacks
This effectively does only two things:
* Pass existing `&Unit` to `init()`
* Pass existing `&Target` to `exec()`s
Also updated doc comments slightly.
The `init()` is called for every `Work` preparation by `rustc()` and since it's not called once (not sure if intended?), it'd be good to include more information for which `Unit` the `rustc` process invocation has been initially prepared (I think more importantly it shows that `init()` is called many times for many targets).
Additionally, it'd be good to know about `Unit` compiled in the `exec()` callbacks in more structured manner (so the user doesn't have to parse the `ProcessBuilder` arguments and/or make certain assumptions) and since `target` was already cloned and moved into the closure, it was only a matter of exposing it.
I think it'd be ideal to provide all the necessary information to recreate a `Unit` but with a static lifetime needed for the closure, however this would mean cloning more data per-target ([`Kind`](https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_rustc/mod.rs#L41) should be basically free, however not sure if cloning [`Profile`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/manifest.rs#L151) is acceptable). With this, `Executor` users could query `Context` more easily (e.g. to get a unit dep graph! :smile:), as the API accepts `Unit`s in many places.
r? @alexcrichton
cc @nrc
EDIT:
This changes the public API, not sure if there's something else I should do about it, only ran `cargo test` locally.
bors [Sun, 20 Aug 2017 12:57:50 +0000 (12:57 +0000)]
Auto merge of #4364 - RalfJung:feat, r=alexcrichton
Required dependencies are not features
Also, while I was at it, I fixed an error message which complained about something not being an optional dependency, when really what mattered was that it was not a dependency at all.
I made a bunch of guesses about how things work. These guesses ended up as comments in the commit (so hopefully, the next reader of these files has to guess less). I am not totally certain these comments are all correct, so please yell if not. :)
In particular, for resolve_features, I observed that dependencies get compiled even when they are not returned from that function. But judging from how the function used to behave, it actually returns all dependencies, even those that have nothing to do with any features. (Making the name rather misleading, TBH...)
bors [Mon, 14 Aug 2017 23:23:05 +0000 (23:23 +0000)]
Auto merge of #4404 - parkovski:master, r=alexcrichton
Fix #4370 - init panic in C:\ or /
This fixes the crash in this issue, but the error message is strange - unable to create directory 'C:\\.'. I don't have write permissions there without becoming admin, so I suspect it's just a permission issue, but the weird error can be fixed by calling Path::canonicalize on line 300.
bors [Sat, 12 Aug 2017 14:46:51 +0000 (14:46 +0000)]
Auto merge of #4393 - burtonageo:update-cargo-new-template, r=matklad
Update lib template for `cargo new` so that the placeholder test contains an assertion
When you run `rustfmt` on the default generated lib template, it modifies it as shown [here](https://play.rust-lang.org/?gist=bd44610731e26e76719e75d47e598990&version=undefined)
bors [Thu, 10 Aug 2017 09:04:21 +0000 (09:04 +0000)]
Auto merge of #4390 - alexcrichton:read-hard-links, r=matklad
Use `same-file` to avoid unnecessary hard links
This is targeted at removing the need for a workaround in rust-lang/rust#39518,
allowing the main rust build system to move back to hard links which should be
much more efficient.
Alex Crichton [Thu, 10 Aug 2017 00:22:34 +0000 (17:22 -0700)]
Use `same-file` to avoid unnecessary hard links
This is targeted at removing the need for a workaround in rust-lang/rust#39518,
allowing the main rust build system to move back to hard links which should be
much more efficient.
bors [Wed, 9 Aug 2017 16:30:21 +0000 (16:30 +0000)]
Auto merge of #4382 - Xanewok:expose-filter-rule, r=alexcrichton
Expose ops::cargo_compile::FilterRule
I've been mindlessly copying and consuming the Cargo API to work on the build plan prototype for RLS and I noticed that, it seems, pub `ops::cargo_compile::CompileFilter` is exported, but not the `ops::cargo_compile::FilterRule`, which `CompileFilter` uses, as a part of a public API.
If I'm wrong and missing something, feel free to ignore/close it. It was possible to match/destructure `CompileFilter` before, but with this change it's possible to use the underlying type.
This diff takes us to **Stage 1.1** of the migration plan by allowing
glob patterns to include a leading slash, so that glob patterns can be
updated, if needed, to start with a slash, closer to the future behavior
with gitignore-like matching.
Why is this stage needed?
It's common to have `package.include` set like this:
```
include = ["src/**"]
```
In old interpretation, this would only include all files under the `src`
directory under the package root. With the new interpretation, this
would match any path with some directory called `src`, even if it's not
directly under the package root.
After this patch, package owners can start marking glob patters with a
leading slash to fix the warning thrown, if any.
One thing to notice here is that there are no extra matchings, but, if
a manifest has already a pattern with a leading slash, this would
silently start matching it with the paths. I believe this is fine, since
the old behavior would have been for the pattern to not match anything,
therefore the item was useless.
See also <https://github.com/rust-lang/cargo/issues/4377> for suggestion
to throw warning on useless/invalid patterns in these fields.
bors [Wed, 9 Aug 2017 14:10:12 +0000 (14:10 +0000)]
Auto merge of #3611 - tylerwhall:stable-metadata, r=alexcrichton
Stable metadata hashes across workspaces
Currently a crate from a path source will have its metadata hash incorporate its absolute path on the system where it is built. This always impacts top-level crates, which means that compiling the same source with the same dependencies and compiler version will generate libraries with symbol names that vary depending on where the workspace resides on the machine.
This is hopefully a general solution to the hack we've used in meta-rust to make dynamic linking reliable.
meta-rust/meta-rust@0e6cf94
For paths inside the Cargo workspace, hash their SourceId relative to the root of the workspace. Paths outside of a workspace are still hashed as absolute.
This stability is important for reproducible builds as part of a larger build system that employs caching of artifacts, such as OpenEmbedded.
OpenEmbedded tightly controls all inputs to a build and its caching assumes that an equivalent artifact will always result from the same set of inputs. The workspace path is not considered to be an influential input, however.
For example, if Cargo is used to compile libstd shared objects which downstream crates link to dynamically, it must be possible to rebuild libstd given the same inputs and produce a library that is at least link-compatible with the original. If the build system happens to cache the downstream crates but needs to rebuild libstd and the user happens to be building in a different workspace path, currently Cargo will generate a library incompatible with the original and the downstream executables will fail at runtime on the target.
bors [Tue, 8 Aug 2017 00:58:29 +0000 (00:58 +0000)]
Auto merge of #4376 - behnam:virtual, r=alexcrichton
[docs/manifest] Add Virtual Manifest section
Current documentation does not mention Virtual Manifests at all, which
can be confusing because they appear in error messages.
Here we add the definition, and provide a hint about `--all` option for
most cargo commands, which allow the command to work in the way most
probably expected.
bors [Tue, 8 Aug 2017 00:05:36 +0000 (00:05 +0000)]
Auto merge of #4374 - behnam:new-init, r=alexcrichton
[cargo_new] Hint to use `cargo init` on existing dir
The `new` command always expects a non-existing path. The `init` command
always expects an existing path. Therefore, it makes sense to hint to
use `init` if the pre-condition to `new` is not satisfied.
bors [Mon, 7 Aug 2017 23:40:25 +0000 (23:40 +0000)]
Auto merge of #4375 - behnam:root-vs-repo, r=alexcrichton
[docs] Update language regarding repository vs package root
In the current documentation, there are many places with language that
assumes a *repository* (as in VCS) is the same as *package root* (the
directory where `Cargo.toml` sits).
With the new workspace features, this is far from true now, and the
inaccurate language makes it difficault for newbies or developers
without much familiarity with the cargo internals with authoring their
manifest files.
This diff tries to use the right terms for places any of these concepts
is referred to:
* Package root,
* Workspace root,
* VCS repository, and
* Package repository/index, like crates.io.
This diff takes us to **Stage 1.1** of the migration plan by allowing
glob patterns to include a leading slash, so that glob patterns can be
updated, if needed, to start with a slash, closer to the future behavior
with gitignore-like matching.
Why is this stage needed?
It's common to have `package.include` set like this:
```
include = ["src/**"]
```
In old interpretation, this would only include all files under the `src`
directory under the package root. With the new interpretation, this
would match any path with some directory called `src`, even if it's not
directly under the package root.
After this patch, package owners can start marking glob patters with a
leading slash to fix the warning thrown, if any.
One thing to notice here is that there are no extra matchings, but, if
a manifest has already a pattern with a leading slash, this would
silently start matching it with the paths. I believe this is fine, since
the old behavior would have been for the pattern to not match anything,
therefore the item was useless.
See also <https://github.com/rust-lang/cargo/issues/4377> for suggestion
to throw warning on useless/invalid patterns in these fields.
Behnam Esfahbod [Mon, 7 Aug 2017 18:44:34 +0000 (11:44 -0700)]
[docs/manifest] Add Virtual Manifest section
Current documentation does not mention Virtual Manifests at all, which
can be confusing because they appear in error messages.
Here we add the definition, and provide a hint about `--all` option for
most cargo commands, which allow the command to work in the way most
probably expected.
Behnam Esfahbod [Mon, 7 Aug 2017 18:11:36 +0000 (11:11 -0700)]
[docs] Update language regarding repository vs package root
In the current documentation, there are many places with language that
assumes a *repository* (as in VCS) is the same as *package root* (the
directory where `Cargo.toml` sits).
With the new workspace features, this is far from true now, and the
inaccurate language makes it difficault for newbies or developers
without much familiarity with the cargo internals with authoring their
manifest files.
This diff tries to use the right terms for places any of these concepts
is referred to:
* Package root,
* Workspace root,
* VCS repository, and
* Package repository/index, like crates.io.
Behnam Esfahbod [Mon, 7 Aug 2017 16:31:32 +0000 (09:31 -0700)]
[cargo_new] Hint to use `cargo init` on existing dir
The `new` command always expects a non-existing path. The `init` command
always expects an existing path. Therefore, it makes sense to hint to
use `init` if the pre-condition to `new` is not satisfied.
bors [Mon, 7 Aug 2017 04:12:18 +0000 (04:12 +0000)]
Auto merge of #4372 - frankmcsherry:patch-1, r=alexcrichton
Modernize explanation of `build.rs`
After some recent head-banging, it was explained to me that `"build.rs"` is a special file name, and that Cargo will build such a file even if you do not expect it to, for example if `Cargo.toml` contains the commented out line
```
#build = "build.rs"
```
Some experimentation lead me to the described behavior, but if it misses any subtle details please feel free to correct. The old text is incorrect, though.
Frank McSherry [Sun, 6 Aug 2017 20:57:13 +0000 (16:57 -0400)]
Modernize explanation of `build.rs`
After some recent head-banging, it was explained to me that `"build.rs"` is a special file name, and that Cargo will build such a file even if you do not expect it to, for example if `Cargo.toml` contains the commented out line
```
#build = "build.rs"
```
Some experimentation lead me to the described behavior, but if it misses any subtle details please feel free to correct. The old text is incorrect, though.
bors [Fri, 4 Aug 2017 09:28:33 +0000 (09:28 +0000)]
Auto merge of #4355 - pornel:docs, r=alexcrichton
Expand profile settings descriptions
Flags were described in the format `foobar = true # controls foobar, passes '--foobar' flag`, but this doesn't actually say what `foobar` does. I've expanded the descriptions a little to provide more context.
Auto merge of #4342 - sid0:hgignore, r=alexcrichton
new: fix hgignore for real
There was an attempt to fix hgignore in #4158, but unfortunately the fix
was incorrect -- hgignore glob syntax is not in fact identical to
gitignore syntax.
To get rooted ignores in Mercurial we must use the regex-based syntax,
so we have no choice but to define a separate set of ignores.
There was an attempt to fix hgignore in #4158, but unfortunately the fix
was incorrect -- hgignore glob syntax is not in fact identical to
gitignore syntax.
To get rooted ignores in Mercurial we must use the regex-based syntax,
so we have no choice but to define a separate set of ignores.
Avoids the sticking point of the previous two PRs (multiple registry updates) by threading through a first-run boolean flag to decide whether `select_pkg` needs to call `source.update()`.
There is still the issue that flags such as `--git` and `--vers` are "global" to the multiple packages you may be installing. The workaround is just to run `cargo install` separately. In the future we could add syntax like `cargo install foo=1.0 bar=2.5 quux=git://github.com/durka/quux#dev-branch` or something.
Auto merge of #4335 - debris:rebased_4021, r=matklad
Rebased and fixed 4025: Apply --all if workspace is virtual
- fixes #4021
- rebased #4025
- fixed issue issue described by @matklad in https://github.com/rust-lang/cargo/pull/4025#pullrequestreview-40660570
- added test `build_virtual_manifest_one_project` which covers the fix