Commit Graph

101 Commits

Author SHA1 Message Date
Eric Huss 888100352a Move ProcessBuilder to cargo-util. 2021-03-20 15:19:03 -07:00
Arpad Borsos b4c4028f76
Run rustdoc doctests relative to the workspace
By doing so, rustdoc will also emit workspace-relative filenames for the doctests.

This was first landed in #8954 but later backed out in #8996 because it changed the CWD of rustdoc test invocations.

The second try relies on the new `--test-run-directory` rustdoc option which was added in https://github.com/rust-lang/rust/pull/81264 to explicitly control the rustdoc test cwd.

fixes #8993
2021-02-22 20:33:31 +01:00
Alex Crichton cc5e9df64a Cache failures in the rustc info cache
This commit updates the rustc info cache to cache failures to execute
rustc as well as successes. This fixes a weird issue where if you're
probing for flags the `rustc_info_cache` test fails on channels which
don't have the flag since previously a failure to execute rustc resulted
in never caching the result.
2021-02-01 11:29:25 -08:00
Eric Huss 00615fc51a Add more helpful message with stabilized -Z flags.
Previously, when something was stabilized, Cargo would spit out a very
unhelpful error message about an unknown -Z flag. This changes it so
that it displays a helpful warning (or error).
2021-01-20 19:46:50 -08:00
Alex Crichton 6f49ce636f Revert "Run rustdoc doctests relative to the workspace"
This reverts commit 2cc2ae8c96.
2020-12-18 08:06:43 -08:00
Arpad Borsos 2cc2ae8c96 Run rustdoc doctests relative to the workspace
By doing so, rustdoc will also emit workspace-relative filenames for
the doctests.

fixes #8097
2020-12-06 23:21:06 +01:00
Weihang Lo da1749db0a
feat(util): print_available_packages 2020-10-26 02:40:28 +08:00
est31 7f73a6c782 Move string interning to util
Code that handles string interning is rather an util functionality than
a core functionality.
2020-06-26 19:55:29 +02:00
Eric Huss 67b10f745d Move SipHasher to an isolated module. 2020-05-11 13:45:18 -07:00
Alex Crichton 458138bf02 Replace `std::sync::mpsc` with a much simpler queue
We don't need the complexity of most channels since this is not a
performance sensitive part of Cargo, nor is it likely to be so any time
soon. Coupled with recent bugs (#7840) we believe in `std::sync::mpsc`,
let's just not use that and use a custom queue type locally which should
be amenable to a blocking push soon too.
2020-03-07 14:01:36 -08:00
Eric Huss 95008f91e5 Try to better handle restricted crate names. 2020-03-02 16:04:24 -08:00
Alex Crichton 3a18c89a55 Migrate from the `failure` crate to `anyhow`
The `anyhow` crate interoperates with the `std::error::Error` trait
rather than a custom `Fail` trait, and this is the general trend of
error handling in Rust as well.

Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.
2020-01-07 16:50:09 -08:00
bors 7ab477866e Auto merge of #7375 - ehuss:extract-platform, r=alexcrichton
Extract Platform to a separate crate.

This moves the `Platform`, `Cfg`, `CfgExpr` types to a new crate named "cargo-platform".  The intent here is to give users of `cargo_metadata` a way of parsing and inspecting cargo's platform values.

Along the way, I rewrote the error handling to remove `failure`, and to slightly improve the output.

I'm having doubts whether or not this is a good idea.  As you can see from the `examples/matches.rs` example, it is nontrivial to use this (which also misses cargo's config values and environment variables).  I don't know if anyone will actually use this.  If this doesn't seem to have value, I would suggest closing it.

I've also included a sample script, `publish.py`, for publishing cargo itself.  I suspect it will need tweaking, but I figure it would be a start and open for feedback.
2019-09-20 18:05:09 +00:00
Alex Crichton 1d5d19e0e7 Update `-Ztimings` with CPU usage information
This commit updates the graph generated by `-Ztimings` to include CPU
usage information, ideally showing how Cargo/rustc used the CPU
throughout the build, ideally seeing nice periods of parallelism and
also periods of missed parallelism.
2019-09-18 13:44:08 -07:00
Eric Huss 57c96c194a Extract Platform to a separate crate. 2019-09-17 14:55:22 -07:00
Alex Crichton e545412251 Work with canonical URLs in `[patch]`
This commit addresses an issue with how the resolver processes `[patch]`
annotations in manifests and lock files. Previously the resolver would
use the raw `Url` coming out of a manifest, but the rest of resolution,
when comparing `SourceId`, uses a canonical form of a `Url` rather than
the actual raw `Url`. This ended up causing discrepancies like those
found in #7282.

To fix the issue all `patch` intermediate storage in the resolver uses a
newly-added `CanonicalUrl` type instead of a `Url`. This
`CanonicalUrl` is then also used throughout the codebase, and all
lookups in the resolver as switched to using `CanonicalUrl` instead of
`Url`, which...

Closes #7282
2019-09-17 09:07:12 -07:00
Eric Huss 51a8206c38 Be more consistent about detecting CI. 2019-07-25 12:10:55 -07:00
Eric Huss 7d7fe6797a Stabilize default-run 2019-06-21 11:36:53 -07:00
Jeremy Stucki 2415a2980f
Make rustfmt happy 2019-06-20 18:23:55 +02:00
Jeremy Stucki 930134c75b
Rename to_url -> into_url 2019-06-20 16:53:24 +02:00
Alex Helfet 491f8d6188 Added helper ToUrlWithBase/to_url_with_base() 2019-04-24 21:28:52 +01:00
Alex Crichton e9428cbadd Remove `Freshness` from `DependencyQueue`
Ever since the inception of Cargo and the advent of incremental
compilation at the crate level via Cargo, Cargo has tracked whether it
needs to recompile something at a unit level in its "dependency queue"
which manages when items are ready for execution. Over time we've fixed
lots and lots of bugs related to incremental compilation, and perhaps
one of the most impactful realizations was that the model Cargo started
with fundamentally doesn't handle interrupting Cargo halfway through and
resuming the build later.

The previous model relied upon implicitly propagating "dirtiness" based
on whether the one of the dependencies of a build was rebuilt or not.
This information is not available, however, if Cargo is interrupted and
resumed (or performs a subset of steps and then later performs more).
We've fixed this in a number of places historically but the purpose of
this commit is to put a nail in this coffin once and for all.

Implicit propagation of whether a unit is fresh or dirty is no longer
present at all. Instead Cargo should always know, irrespective of it's
in-memory state, whether a unit needs to be recompiled or not. This
commit actually turns up a few bugs in the test suite, so later commits
will be targeted at fixing this.

Note that this required a good deal of work on the `fingerprint` module
to fix some longstanding bugs (like #6780) and some serious hoops had to
be jumped through for others (like #6779). While these were fallout from
this change they weren't necessarily the primary motivation, but rather
to help make `fingerprints` a bit more straightforward in what's an
already confusing system!

Closes #6780
2019-04-10 10:42:08 -07:00
Jane Lusby 0389edc69b impl centralized RustcWrapper logic 2019-03-29 17:40:34 -07:00
Dale Wijnand 092c88c4a9
Replace util::without_prefix with Path::strip_prefix 2019-02-03 14:31:19 +01:00
Damian 56b6a80f57 --example with no argument now lists all available examples 2019-01-01 11:03:55 +01:00
Eric Huss 080f0b34c4 Restrict registry names to same style as package names. 2018-12-19 20:36:13 -08:00
Dale Wijnand 920d552750
Replace CargoError with failure::Error 2018-12-12 23:25:08 +00:00
Alex Crichton fecb724643 Format with `cargo fmt` 2018-12-08 03:19:47 -08:00
Andy Caldwell 077a31adb3
Move command prelude into main library 2018-11-19 21:41:09 +00:00
Alex Crichton a46df8fe7d Update the progress bar for parallel downloads
This is actually a super tricky problem. We don't really have the capacity for
more than one line of update-able information in Cargo right now, so we need to
squeeze a lot of information into one line of output for Cargo. The main
constraints this tries to satisfy are:

* At all times it should be clear what's happening. Cargo shouldn't just hang
  with no output when downloading a crate for a long time, a counter ideally
  needs to be decreasing while the download progresses.

* If a progress bar is shown, it shouldn't jump around. This ends up just being
  a surprising user experience for most. Progress bars should only ever
  increase, but they may increase at different speeds.

* Cargo has, currently, at most one line of output (as mentioned above) to pack
  information into. We haven't delved into fancier terminal features that
  involve multiple lines of update-able output.

* When downloading crates as part of `cargo build` (the norm) we don't actually
  know ahead of time how many crates are being downloaded. We rely on the
  calculation of unit dependencies to naturally feed into downloading more
  crates.

* Furthermore, once we decide to download a crate, we don't actually know how
  big it is! We have to wait for the server to tell us how big it is.

There doesn't really seem to be a great solution that satisfies all of these
constraints unfortunately. As a result this commit implements a relatively
conservative solution which should hopefully get us most of the way there. There
isn't actually a progress bar but rather Cargo prints that it's got N crates
left to download, and if it takes awhile it prints out that there are M bytes
remaining.

Unfortunately the progress is pretty choppy and jerky, not providing a smooth
UI. This appears to largely be because Cargo will synchronously extract
tarballs, which for large crates can cause a noticeable pause. Cargo's not
really prepared internally to perform this work on helper threads, but ideally
if it could do so it would improve the output quite a bit! (making it much
smoother and also able to account for the time tarball extraction takes).
2018-09-18 11:33:18 -07:00
Dale Wijnand eea58f205f
Move existing_vcs_repo to the util::vcs module
Rather than being in cargo_new publically exposed and used by cargo fix.
2018-07-26 22:09:45 +01:00
Alex Crichton b02ba3771e Import `cargo fix` directly in to Cargo
This commit imports the `cargo fix` subcommand in rust-lang-nursery/rustfix
directly into Cargo as a subcommand. This should allow us to ease our
distribution story of `cargo fix` as we prepare for the upcoming 2018 edition
release.

It's been attempted here to make the code as idiomatic as possible for Cargo's
own codebase. Additionally all tests from cargo-fix were imported into Cargo's
test suite as well. After this lands and is published in nightly the `cargo-fix`
command in rust-lang-nursery/rustfix will likely be removed.

cc rust-lang/rust#52272
2018-07-16 21:58:58 -07:00
kennytm a753b50087
Addressed comments. 2018-06-29 05:15:59 +08:00
Alex Crichton 1e6828485e cargo fmt 2018-03-14 17:48:23 -07:00
Aleksey Kladov 7f3e86e069 Switch to lazycell from crate.io 2018-02-12 21:33:31 +03:00
Alex Crichton 37cffbe0a3 Start migration to the `failure` crate
This commit is the initial steps to migrate Cargo's error handling from the
`error-chain` crate to the `failure` crate. This is intended to be a low-cost
(in terms of diff) transition where possible so it's note "purely idiomatic
`failure` crate" just yet.

The `error-chain` dependency is dropped in this commit and Cargo now canonically
uses the `Error` type from the `failure` crate. The main last remnant of
`error-chain` is a custom local extension trait to use `chain_err` instead of
`with_context`. I'll try to follow up with a commit that renames this later but
I wanted to make sure everything worked first! (and `chain_err` is used
practically everywhere).

Some minor tweaks happened in the tests as I touched up a few error messages
here and there but overall the UI of Cargo should be exactly the same before and
after this commit.
2017-12-18 17:48:36 -08:00
Alex Crichton 143b060025 Add a number of progress indicators to Cargo
This commit is an attempt to stem the tide of "cargo is stuck updating the
registry" issues by giving a better indication as to what's happening in
long-running steps. The primary addition here is a `Progress` helper module
which prints and manages a progress bar for long-running operations like git
fetches, git checkouts, HTTP downloads, etc.

The second addition here is to print out when we've been stuck in resolve for
some time. We never really have a progress indicator for crate graph resolution
nor do we know when we're done updating sources. Instead we make a naive
assumption that when you've spent 0.5s in the resolution loop itself (not
updating deps) you're probably done updating dependencies and on to acutal
resolution. This will print out `Resolving crate graph...` and help inform that
Cargo is indeed not stuck looking at the registry, but rather it's churning away
in resolution.
2017-11-06 10:35:00 -08:00
David King 7eca7f271d Add fossil VCS support to `cargo new`
Fossil is a simple, high-reliability, distributed software configuration
management system <https://www.fossil-scm.org/>
2017-06-09 18:03:28 -07:00
jluner c7de485927 Addresses review comments
* rebased
* removed `human` (deferring removing `internal` to a later PR)
* cargo_test.rs - fails on other error kinds
* unnecessary `map_err(CargoError::from)` removed
* fold NetworkError entirely into CargoError
* added justification comment for `extend_lifetime`
* various formatting goofs

The following tests are currently failing:
* `http_auth_offered`
* `custom_build_script_failed`
* `build_deps_for_the_right_arch`
* `dep_with_bad_submodule`
* `update_with_shared_deps`
* `finds_author_email`
* `finds_author_user`
* `finds_author_user_escaped`
* `finds_author_username`
* `finds_git_author`
* `exit_code`
2017-05-24 23:45:14 -05:00
jluner e95044e313 Add error-chain errors
Convert CargoResult, CargoError into an implementation provided by error-chain. The previous is_human machinery is mostly removed; now errors are displayed unless of the Internal kind, verbose mode will print all errors.
2017-05-24 21:14:04 -05:00
Nick Cameron 78e3414414 Allow a client to override values in a config 2017-04-03 14:08:15 +12:00
Paul Woolcock 2b31978cc7 Add Pijul support to cargo
[Pijul](https://pijul.org) is a version control system written in Rust. This commit adds the ability to create a cargo project using pijul as the vcs for the project.

To use it, run `cargo new my-awesome-project --vcs=pijul`
2017-03-31 14:22:04 -04:00
Ewan Higgs 7e66058af4 Revert "Cargo templating for `new` and `init`"
This reverts commit 875a8aba79.
2017-03-29 21:57:33 +02:00
tee-too c1c8e361ce Report the name of the test that failed (fix #2529) 2017-03-20 11:53:37 +01:00
Ewan Higgs 875a8aba79 Cargo templating for `new` and `init`
PR #3004 This is a resubmission of the PR #1747 (from scratch) which adds
support for templating in Cargo. The templates are implemented using the
handlebars crate (where the original PR used mustache).

Examples:
cargo new --template https://url/to/template somedir foo
cargo new --template https://url/to/templates --template-subdir somedir foo
cargo new --template ../path/to/template somedir foo
2017-01-31 10:23:42 +01:00
Nick Cameron 8c3b360528 Make some aspects of check/build available as an API.
There are two key parts to this commit:
* let API clients run `cargo check` with minimal fuss (ops/cargo_check.rs),
* let API clients intercept and customise Cargo's calls to rustc (all the Executor stuff).
2017-01-05 15:58:58 +13:00
Steven Fackler d105e75271 Use externally sourced shell-escape
Closes #3374
2016-12-30 10:21:10 -08:00
Aleksey Kladov ef94f46796 Create a centralized machine_message module 2016-10-02 17:28:26 +03:00
Alex Crichton 26690d33e4 Stream build script output to the console
This commit alters Cargo's behavior when the `-vv` option is passed (two verbose
flags) to stream output of all build scripts to the console. Cargo makes not
attempt to prevent interleaving or indicate *which* build script is producing
output, rather it simply forwards all output to one to the console.

Cargo still acts as a middle-man, capturing the output, to parse build script
output and interpret the results. The parsing is still deferred to completion
but the stream output happens while the build script is running.

On Unix this is implemented via `select` and on Windows this is implemented via
IOCP.

Closes #1106
2016-06-14 07:35:51 -07:00
Stephen Becker IV 7b03532b4f Network retry issue 1602
Dearest Reviewer,

This branch resolves #1602 which relates to retrying network
issues automatically. There is a new utility helper for retrying
any network call.

There is a new config called net.retry value in the .cargo.config
file. The default value is 2. The documentation has also been
updated to reflect the new value.

Thanks
Becker
2016-05-12 11:26:58 -07:00