Auto merge of #4496 - rwakulszowa:infer_from_subdirectories, r=matklad
Infer targets from subdirectories
Fixes #4086
I still have a few questions:
- should I add some tests for the old behaviour? It isn't really tested at the moment (no tests failed when I broke the implementation); I could refactor the tests to check for both single file and subdirectory inference
- I moved things around, mostly reusing the code from `inferred_bins` - hopefully I didn't break anything, but it won't hurt to double check :)
- Do we have something like servo's `tidy` check for coding style? I'm open for suggestions if something isn't formatted correctly
- Just a general one - should I rebase + squash commits every time I make subsequent changes to cargo?
Auto merge of #4501 - matklad:top-level-features, r=alexcrichton
Move cargo features to top-level
This should allow to add Cargo-features to virtual manifest as well.
I've not actually added support for features in virtual manifests just yet, because that will probably require some refactoring to avoid duplicating feature-related code between virtual and usual manifests.
Auto merge of #4478 - alexcrichton:less-fds, r=matklad
Periodically gc repos in Cargo
This commit is targeted at improving the long-term management of git checkouts
and git repositories. Currently every time data is fetched from crates.io
libgit2 will create a new pack file in the repository. These pack files
accumulate over time and end up causing pathological behavior if there's lots of
them, causing libgit2 to open many file descriptors all at once, possibly
blowing the system's file descriptor limits.
To alleviate this problem you typically run `git gc`, but libgit2 doesn't have
this implemented. Instead what Cargo now does is detect this situation and run
literally the command line tool `git gc` in a best-effort attempt to compact the
repo. Failing that, for example when git isn't installed, Cargo will remove the
entire repo and do a full checkout again.
At the same time this commit also generalizes this logic, plus the existing fast
path github logic, to all git repositories and not just the index. That way all
git repositories can benefit from the "github fast path" as well as the
compaction steps.
Alex Crichton [Sat, 9 Sep 2017 01:30:37 +0000 (18:30 -0700)]
Periodically gc repos in Cargo
This commit is targeted at improving the long-term management of git checkouts
and git repositories. Currently every time data is fetched from crates.io
libgit2 will create a new pack file in the repository. These pack files
accumulate over time and end up causing pathological behavior if there's lots of
them, causing libgit2 to open many file descriptors all at once, possibly
blowing the system's file descriptor limits.
To alleviate this problem you typically run `git gc`, but libgit2 doesn't have
this implemented. Instead what Cargo now does is detect this situation and run
literally the command line tool `git gc` in a best-effort attempt to compact the
repo. Failing that, for example when git isn't installed, Cargo will remove the
entire repo and do a full checkout again.
At the same time this commit also generalizes this logic, plus the existing fast
path github logic, to all git repositories and not just the index. That way all
git repositories can benefit from the "github fast path" as well as the
compaction steps.
Auto merge of #4485 - integer32llc:clarify-config, r=alexcrichton
Clarify that .cargo/config files are unified
It wasn't immediately clear to me from the text on this page whether Cargo looks for these files and stops at the first one, or whether it looks for them all and puts them all together. I was pretty sure it was the latter, but I think these few more words would have made me feel more confident sooner :)
Alex Crichton [Sat, 9 Sep 2017 20:52:03 +0000 (13:52 -0700)]
Make `dep_targets` consistent throughout compilation
Previously it depended on dynamic state that was calculated throughout a
compilation which ended up causing different fingerprints showing up in a few
locations, so this makes the invocation deterministic throughout `cargo_rustc`.
Auto merge of #4477 - alexcrichton:fix-out-of-bounds, r=matklad
Use poll instead of select to handle large fds
It may be the case that Cargo's running around with a lot of file descriptors,
and in this case we wouldn't be able to call `select` due to the file
descriptors being too large and not fitting in the bit array. This switches to
what the standard library is currently doing, using `poll`, which doesn't have
this limitations.
Auto merge of #3992 - alexcrichton:replace-git, r=matklad
Support vendoring git repositories
Currently the vendoring support in Cargo primarily only allows replacing
registry sources, e.g. crates.io. Other networked sources of code, such as git
repositories, cannot currently be replaced. The purpose of this commit is to
support vendoring of git dependencies to eventually have support implemented in
the `cargo-vendor` subcommand.
Support for vendoring git repositories required a few subtle changes:
* First and foremost, configuration for source replacement of a git repository
was added. This looks similar to the `Cargo.toml` configuration of a git
source.
* The restriction around checksum providing sources was relaxed. If a
replacement source provides checksums but the replaced source doesn't then
that's now considered ok unlike it being an error before.
* Lock files can be generated for crates.io crates against vendored sources, but
lock files cannot be generated against git sources. A lock file must
previously exist to make use of a vendored git source.
* The `package` field of `.cargo-checksum.json` is now optional, and it is
intended to be omitted for git sources that are vendored.
Alex Crichton [Fri, 8 Sep 2017 05:14:55 +0000 (22:14 -0700)]
Use poll instead of select to handle large fds
It may be the case that Cargo's running around with a lot of file descriptors,
and in this case we wouldn't be able to call `select` due to the file
descriptors being too large and not fitting in the bit array. This switches to
what the standard library is currently doing, using `poll`, which doesn't have
this limitations.
Alex Crichton [Thu, 4 May 2017 03:33:28 +0000 (20:33 -0700)]
Support vendoring git repositories
Currently the vendoring support in Cargo primarily only allows replacing
registry sources, e.g. crates.io. Other networked sources of code, such as git
repositories, cannot currently be replaced. The purpose of this commit is to
support vendoring of git dependencies to eventually have support implemented in
the `cargo-vendor` subcommand.
Support for vendoring git repositories required a few subtle changes:
* First and foremost, configuration for source replacement of a git repository
was added. This looks similar to the `Cargo.toml` configuration of a git
source.
* The restriction around checksum providing sources was relaxed. If a
replacement source provides checksums but the replaced source doesn't then
that's now considered ok unlike it being an error before.
* Lock files can be generated for crates.io crates against vendored sources, but
lock files cannot be generated against git sources. A lock file must
previously exist to make use of a vendored git source.
* The `package` field of `.cargo-checksum.json` is now optional, and it is
intended to be omitted for git sources that are vendored.
Auto merge of #4457 - behnam:book-pub, r=alexcrichton
[doc] Publish book to gh-pages
Export mdBook into `target/doc/book/`, to make it accessible at <http://doc.crates.io/book/>
I have tested the changes on my repo (but when I had this commit on top of the other PR) locally. The result is at <http://code.behnam.es/rust-cargo/book/>.
Auto merge of #4455 - behnam:book-enh, r=alexcrichton
[doc/book] Add introduction page and other enhancements
Preview: http://code.behnam.es/rust-cargo/book/
* Reorganize files to use folders instead of numbered files. This will allow us to add new sections and pages without breaking a numbering system or the URLs.
* Rename "Cargo In Depth" to "Cargo Reference", as those pages are considered *the* reference for cargo behaviors.
* Add `introduction.md`, as the landing page with the book title and Cargo logo on top.
* Expand `installation.md`: Import install text and links from <https://crates.io/install>, as we
want to drop that page and redirect it to here. (See <https://github.com/rust-lang/crates.io/issues/1029>)
* Sync `SUMMARY.md` titles (and sub-pages lists in section pages) with page titles and fix some wordings and casings.
* Expand Introduction and section pages with some intro text.
* Set lang for some of the code blocks.
* Add `book.toml` to get the title in HTML head title, etc.
bors [Thu, 31 Aug 2017 21:08:09 +0000 (21:08 +0000)]
Auto merge of #4453 - behnam:book, r=alexcrichton
Import mdBook-based docs and sync
Since we decided to keep the mdBook-based docs in-repo, I have imported the existing converted docs from <https://github.com/istankovic/cargo-book> under `/src/doc/book/` here, and have synced the current docs and the mdBook-based ones manually, file-by-file.
I have created a `MIGRATION_MAP` file, which shows the relationship between old docs and new ones. The first column is the old file, the second column is the canonical location in mdBook, and the rest of columns are globs of other files in mdBook containing content from the old file.
The first and second column of `MIGRATION_MAP` shall later be used to create redirect rules from `doc.crates.io/` to `doc.rust-lang.org/cargo/`.
I will also add a README file to remind everyone to keep these files in sync during the migration.
There are also two or three small wording fixes here, which I'll note inline.
This is a retry of <https://github.com/rust-lang/cargo/pull/4220>.
First step for <https://github.com/rust-lang/cargo/issues/4040>.
bors [Thu, 31 Aug 2017 20:26:56 +0000 (20:26 +0000)]
Auto merge of #4447 - lucaskolstad:proc-macro-crates-host-deps-linkage, r=alexcrichton
Add host dependency path via -L for cargo_test.
Proc-macro crates' dependencies in the host dependency directory cannot
be found when running `cargo test` with the `--target {target}` flag
set as reported in #4224. This adds the host dependency directory to the
search path to find those missing dependencies with -L when building tests
and adds a test case that fails before and passes after this patch.
A new function `find_host_deps(..)` is added to accomplish this which can
determine the path of the host dependencies directory from within
`run_doc_tests(..)` where the missing library search path is needed.
The test case seems to require a non-local crate from crates.io to example the failure before this patch. Couldn't make it fail with simply another local subcrate, but if others think it's possible that'd be great. This means that during tests for the cargo project itself that this test case actually downloads and compiles a crate, which I don't think any other tests do and is obviously not ideal and is perhaps even unacceptable. I've used the base64 crate pretty arbitrarily, but which crate it is really doesn't matter to test the case's content. So if anyone knows a tiny or empty crate on crates.io to use instead that'd speed this up and if someone can figure out how to make it fail before this patch is applied without downloading an external crate that would help as well.
Also, I'm not 100% confident about the `find_host_deps(..)` style and whether it's the best way to find the host dependencies directory with just the `TestOptions` and `Compilation` structs available since I'm new to this project. Any comments are appreciated.
Lucas Kolstad [Thu, 31 Aug 2017 17:55:19 +0000 (10:55 -0700)]
Tweak proc_macro test to correctly test case.
Minor change causes the test to actually test the case instead of always
passing regardless of the fix that adds the host dependency directory to
the library search path.
Lucas Kolstad [Thu, 31 Aug 2017 00:59:23 +0000 (17:59 -0700)]
Replace plugins_dylib_path with host_deps_output.
The plugins_dylib_path field on Compilation is removed because it is
identical to host_deps_output, it is only used in one easily replaced
location, and because host_deps_output is a more general name that
includes its new usage location in cargo_test.rs as well while better
matching the corresponding deps_output field.
Also de-indents erroneously indented lines in a test case.
Lucas Kolstad [Wed, 30 Aug 2017 22:16:52 +0000 (15:16 -0700)]
Remove find_host_deps and use Compilation field.
This patch removes the addition of the find_host_deps() function by
adding a host_deps_output field to the Compilation struct instead. The
test case is altered to not use an external crate from crates.io but
instead use the Package.publish(..) method.