Commit graph

1048 commits

Author SHA1 Message Date
Eric Huss ec21e12d8a Some clippy fixes. 2019-05-20 12:40:14 -07:00
vlad20012 e1d433d30f Add doctest field into metadata
Some tools can support rust doctests (e.g. highlighting
or launching). So it should be possible to find out if
doctests are enabled for a target or not. This commit
adds `doctest` field to `cargo metadata` output.
2019-05-17 18:39:23 +03:00
Matthias Krüger 235fcbecc2 tests: registry: revert readonly permission after running tests.
Fixes #6943
2019-05-15 20:16:37 +02:00
bors 1b4fab3263 Auto merge of #6904 - fluffysquirrels:first-update-precise, r=alexcrichton
Fix for "Running cargo update without a Cargo.lock ignores arguments" #6872
2019-05-15 14:53:37 +00:00
Alex Crichton 5d9383ed76 Re-enable compatibility with readonly CARGO_HOME
Previously Cargo would attempt to work as much as possible with a
previously filled out CARGO_HOME, even if it was mounted as read-only.
In #6880 this was regressed as a few global locks and files were always
attempted to be opened in writable mode.

This commit fixes these issues by correcting two locations:

* First the global package cache lock has error handling to allow
  acquiring the lock in read-only mode inaddition to read/write mode. If
  the read/write mode failed due to an error that looks like a readonly
  filesystem then we assume everything in the package cache is readonly
  and we switch to just acquiring any lock, this time a shared readonly
  one. We in theory aren't actually doing any synchronization at that
  point since it's all readonly anyway.

* Next when unpacking package we're careful to issue a `stat` call
  before opening a file in writable mode. This way our preexisting guard
  to return early if a package is unpacked will succeed before we open
  anything in writable mode.

Closes #6928
2019-05-14 07:46:01 -07:00
Eric Huss 337fbaaa12 Fix version of ignore.
Some tests relied on new behavior, so bump the minimal version.

The change to `gitignore_negate` was just an innocuous typo.
2019-05-13 18:05:10 -07:00
Eric Huss 309eb874fd Stabilize offline mode. 2019-05-12 10:49:45 -07:00
Alex Helfet 36160ed444 Merge remote-tracking branch 'origin/master' into first-update-precise 2019-05-11 16:44:39 +01:00
bors ceb1389037 Auto merge of #6924 - ehuss:include-exclude-patterns, r=alexcrichton
Migrate package include/exclude to gitignore patterns.

This moves to the next phase of #4268.

This also includes a fdew more changes which can be removed if desired:
- Add support for `!` negate gitignore patterns.
- Add a warning if both package.include and package.exclude are specified.
2019-05-10 15:03:12 +00:00
Eric Huss db3328ecb1 Add a warning if both package.include and package.exclude are specified. 2019-05-10 07:46:50 -07:00
Eric Huss 3ca96e90eb Add support for ! negate gitignore patterns. 2019-05-10 07:46:50 -07:00
Eric Huss d4b6e90fc1 Migrate package include/exclude to gitignore patterns. 2019-05-10 07:46:50 -07:00
bors 2e09266f66 Auto merge of #6883 - alexcrichton:pipelining-v2, r=ehuss
Implement the Cargo half of pipelined compilation (take 2)

This commit starts to lay the groundwork for #6660 where Cargo will
invoke rustc in a "pipelined" fashion. The goal here is to execute one
command to produce both an `*.rmeta` file as well as an `*.rlib` file
for candidate compilations. In that case if another rlib depends on that
compilation, then it can start as soon as the `*.rmeta` is ready and not
have to wait for the `*.rlib` compilation.

Initially attempted in #6864 with a pretty invasive refactoring this
iteration is much more lightweight and fits much more cleanly into
Cargo's backend. The approach taken here is to update the
`DependencyQueue` structure to carry a piece of data on each dependency
edge. This edge information represents the artifact that one node
requires from another, and then we a node has no outgoing edges it's
ready to build.

A dependency on a metadata file is modeled as just that, a dependency on
just the metadata and not the full build itself. Most of cargo's backend
doesn't really need to know about this edge information so it's
basically just calculated as we insert nodes into the `DependencyQueue`.
Once that's all in place it's just a few pieces here and there to
identify compilations that *can* be pipelined and then they're wired up
to depend on the rmeta file instead of the rlib file.

Closes #6660
2019-05-10 14:36:30 +00:00
bors 29b000fcc2 Auto merge of #6925 - ehuss:package-include-manifest, r=alexcrichton
Always include `Cargo.toml` when packaging.

Since `Cargo.toml` is required, might as well include it automatically rather than force everyone to include it explicitly. If it is not listed in `include`, there was a somewhat confusing error message when packaging.

Closes #6830
Closes #4660
2019-05-10 13:44:03 +00:00
Eric Huss 49e37f80fa Always include Cargo.toml when packaging. 2019-05-09 13:34:08 -07:00
Eric Huss 87449f453b Remove unnecessary calls to masquerade_as_nightly_cargo.
These are not needed anymore.
2019-05-09 10:58:18 -07:00
Alex Crichton 6b28a0c050 Fix fingerprint handling in pipelining mode
This commit fixes an issue when pipelining mode is used in handling
recompilations. Previously a sequence of compilations could look like:

* Crate A starts to build
* Crate A produces metadata
* Crate B, which depends on A, starts
* Crate B finishes
* Crate A finishes

In this case the mtime for B is before that of A, which fooled Cargo
into thinking that B needed to be recompiled. In this case, however, B
doesn't actually need to be recompiled because it only depends on the
metadata of A, not the final artifacts.

This unfortunately resulted in some duplication in a few places, but not
really much moreso than already exists between fingerprinting and compilation.
2019-05-08 11:28:07 -07:00
Zach Lute 782266aaee Changed RUST_LOG usage to CARGO_LOG to avoid confusion. 2019-05-08 10:53:02 -07:00
Alex Crichton c2152f0805 Delete rmeta files for rlibs during cargo clean 2019-05-08 09:00:27 -07:00
Alex Crichton 8f032b3bd4 Handle "invalid JSON" from the compiler
Just opportunistically consider lines which start with `{` as valid
JSON, otherwise forward everything else to normal stdout/stderr.
2019-05-08 08:51:40 -07:00
Alex Crichton 95e240448d Switch to -Zemit-artifact-notifications
This is the renamed version of `-Zemit-directives`.
2019-05-08 08:43:09 -07:00
Alex Crichton 4617f78dbc Parse rmeta directives coming from rustc
This commit updates Cargo to process JSON directives emitted by rustc
when we're pipelining compilation. In this mode Cargo will attempt to
start subsequent compilations of crates as soon as possible, fully
completing the features of pipelined compilations in Cargo!
2019-05-08 08:10:26 -07:00
Alex Crichton 1a6e452407 Refactor routing output from rustc/rustdoc
This commit refactors slightly how we actually spawn rustc/rustdoc
processes and how their output is routed. Over time lots has changed
around this, but it turns out that we unconditionally capture all output
from the compiler/rustdoc today, no exceptions. As a result simplify the
various execution functions in the `Executor` trait as well as branches
for emitting json messages. Instead throw everything in the same bucket
and just always look for lines that start with `{` which indicate a
JSON message.

This also fixes a few issues where output printed in each thread is now
routed through the main coordinator thread to handle updating the
progress bar if necessary.
2019-05-08 08:10:26 -07:00
Alex Crichton 127fdfeb89 Implement the Cargo half of pipelined compilation
This commit starts to lay the groundwork for #6660 where Cargo will
invoke rustc in a "pipelined" fashion. The goal here is to execute one
command to produce both an `*.rmeta` file as well as an `*.rlib` file
for candidate compilations. In that case if another rlib depends on that
compilation, then it can start as soon as the `*.rmeta` is ready and not
have to wait for the `*.rlib` compilation.

Initially attempted in #6864 with a pretty invasive refactoring this
iteration is much more lightweight and fits much more cleanly into
Cargo's backend. The approach taken here is to update the
`DependencyQueue` structure to carry a piece of data on each dependency
edge. This edge information represents the artifact that one node
requires from another, and then we a node has no outgoing edges it's
ready to build.

A dependency on a metadata file is modeled as just that, a dependency on
just the metadata and not the full build itself. Most of cargo's backend
doesn't really need to know about this edge information so it's
basically just calculated as we insert nodes into the `DependencyQueue`.
Once that's all in place it's just a few pieces here and there to
identify compilations that *can* be pipelined and then they're wired up
to depend on the rmeta file instead of the rlib file.
2019-05-08 08:10:26 -07:00
Matthias Krüger b48ae60e67 run cargo fmt --all 2019-05-07 14:08:29 +02:00
bors 759b6161a3 Auto merge of #6910 - Eh2406:small-things, r=alexcrichton
Small things

This has two small changes that are worth saving from my most recent attempt to speedup https://github.com/rust-lang/cargo/issues/6258#issuecomment-479204465:

1. This removes the `ConflictCache::contains` added in #6776. Replacing it with a more general and easier to explain system based on the existing `ConflictCache::find_conflicting`.
2. This adds code to print the used part of the input for failing resolver tests. This is very helpful when
    1. The proptest shrinking algorithm is interrupted, at least you have the smallest one found so far.
    2. Hand minimizing, remove a dep and it will tell you all the packages that are no longer needed for the test to fail.
2019-05-06 20:47:49 +00:00
Alex Crichton 23ee20469a Fix skipping over invalid registry packages
This accidentally regressed in the previous caching PR for Cargo.
Invalid lines of JSON in the registry are intended to be skipped over,
but when skipping we forgot to update some indices which meant that all
future versions would fail to parse as well!
2019-05-06 13:01:19 -07:00
Eh2406 45411e2d99 if found a case that causes a panic and did not use all of the input. lets print the part of the input that was used. Helpful in minimization. 2019-05-06 12:37:05 -04:00
bors 0f77ed5f61 Auto merge of #6903 - matthiaskrgr:typos, r=ehuss
fix more typos (codespell)
2019-05-03 16:04:51 +00:00
Alex Helfet 1bcf7f113d Fix. 2019-05-03 16:13:10 +01:00
Alex Helfet f299d1c117 Failing test. 2019-05-03 16:13:10 +01:00
Alex Crichton 783f22bf8c Thread through last update time to index cache
Removed in the previous commit this now adds dedicated tracking for the
last update.
2019-05-03 07:23:00 -07:00
Alex Crichton 5217280ee3 Make registry locking more coarse
This commit updates the locking strategy in Cargo handle the recent
addition of creating a cache of the on-disk index also on disk. The goal
here is reduce the overhead of locking both cognitively when reading but
also performance wise by requiring fewer locks. Previously Cargo had a
bunch of fine-grained locks throughout the index and git repositories,
but after this commit there's just one global "package cache" lock.

This global lock now serves to basically synchronize the entire crate
graph resolution step. This shouldn't really take that long unless it's
downloading, in which case there's not a ton of benefit to running in
parallel anyway. The other intention of this single global lock is to
make it much easier on the sources to not worry so much about lock
ordering or when to acquire locks, but rather they just assert in their
various operations that they're locked.

Cargo now has a few coarse-grained locations where locks are held (for
example during resolution and during package downloading). These locks
are a bit sprinkled about but they have in-code asserts which assert
that they're held, so we'll find bugs quickly if any lock isn't held
(before a race condition is hit that is)
2019-05-03 07:23:00 -07:00
Matthias Krüger b4cd609579 fix more typos (codespell) 2019-05-03 14:22:11 +02:00
bors 7eb9e6ca52 Auto merge of #6881 - k-nasa:feature_cargo_toml_template, r=alexcrichton
Default Cargo.toml template provide help for completing the metadata

## Descriptio
This is new Cargo.toml example.
```toml
[package]
name = "foo"
version = "0.1.0"
authors = ["k-nasa"]
documentation = ""
homepage = ""
repository = ""
readme = ""
categories = []
keywords = []
license = ""
edition = "2018"

[dependencies]

# See more https://doc.rust-lang.org/cargo/reference/manifest.html

```
## Motivation
close: https://github.com/rust-lang/cargo/issues/6845
2019-05-02 14:01:13 +00:00
k-nasa 63a9c7aa6d $cargo fmt --all 2019-05-02 06:39:15 +09:00
k-nasa f781d2df86 test: Add reference link test 2019-05-02 06:29:56 +09:00
Eric Huss f95f55af39 Symlink dSYM on macOS example binaries. 2019-04-29 14:17:28 -07:00
Alex Helfet 987f19d2ea Forbid relative path in registry index (relative URL only), update tests. 2019-04-29 18:39:21 +01:00
Alex Helfet ef00aa9294 Merge remote-tracking branch 'origin/master' into rel-registry-url 2019-04-29 18:03:52 +01:00
bors 2de6c3ef2b Auto merge of #6871 - ehuss:offline-spurious-suggestion, r=alexcrichton
Add some help with updating the registry in offline mode.

This includes the following:

- Move offline tests to a dedicated file.

- If an index has never been downloaded, and `-Z offline` is used, provide a suggestion to run without `-Z offline`.

- ~~If an index needs to be updated, and the network appears to be down, suggest running with `-Z offline`.~~ (removed this)

- The `offline_resolve_optional_fail` test is added to show that resolver errors are still possible (though hopefully rare!).
2019-04-29 14:43:24 +00:00
Eric Huss c6fad3af85 Tweak the error message when updating an empty registry while offline. 2019-04-28 20:04:32 -07:00
Eric Huss c2d12c6ccc Add some help with updating the registry in offline mode.
This makes two changes:

- If an index has never been downloaded, and `-Z offline` is used, provide a
  suggestion to run without `-Z offline`.

- If an index needs to be updated, and the network appears to be down, suggest
  running with `-Z offline`.
2019-04-28 19:45:01 -07:00
Eric Huss 80b9d329ba Move offline tests to a dedicated file. 2019-04-28 19:45:01 -07:00
Eric Huss a9ae668c1b Attempt to debug a spurious test. 2019-04-28 19:25:24 -07:00
Alex Helfet 0dda8f5f72 Added a few tests for relative registry index URLs, fixed a bug. 2019-04-28 00:01:43 +01:00
Aaron Hill f4aac94f12
Properly fix assertion and tests 2019-04-26 00:07:04 -04:00
Aaron Hill df4d2095ac
Prevent 'public' specifier from being used on non-Normal dependencies 2019-04-25 22:42:19 -04:00
Aaron Hill 8a45e5c0b0
Format pub_priv test 2019-04-25 22:42:19 -04:00
Aaron Hill be9ae5e547
Fix error message on stable 2019-04-25 22:42:18 -04:00