cargo.git
7 years agoAuto merge of #5472 - alexcrichton:rename-rust, r=matklad
bors [Thu, 3 May 2018 19:39:24 +0000 (19:39 +0000)]
Auto merge of #5472 - alexcrichton:rename-rust, r=matklad

Rename the `rust` manifest key to `edition`

This'll hopefully jive better with the terminology of "edition" throughout the
rest of Rust!

7 years agoRename the `rust` manifest key to `edition`
Alex Crichton [Thu, 3 May 2018 16:14:25 +0000 (09:14 -0700)]
Rename the `rust` manifest key to `edition`

This'll hopefully jive better with the terminology of "edition" throughout the
rest of Rust!

7 years agoAuto merge of #5473 - ehuss:autobin-warning, r=alexcrichton
bors [Thu, 3 May 2018 18:19:51 +0000 (18:19 +0000)]
Auto merge of #5473 - ehuss:autobin-warning, r=alexcrichton

Address autobins warning.

Removes the large warning displayed if you build Cargo with itself (but adds a warning if you build with an older Cargo).  Not sure which approach you prefer to address it, or if you want to do this later.

7 years agoAddress autobins warning.
Eric Huss [Thu, 3 May 2018 16:13:36 +0000 (09:13 -0700)]
Address autobins warning.

7 years agoAuto merge of #5470 - alexcrichton:hopeful-fix, r=matklad
bors [Thu, 3 May 2018 17:03:06 +0000 (17:03 +0000)]
Auto merge of #5470 - alexcrichton:hopeful-fix, r=matklad

Attmept to fix a spurious failure on AppVeyor

I *think* the issue is that `link.exe` is generating debuginfo in the background
which keeps the file open and prevents us from deleting it, but hopefully by
disabling debug information we'll either be able to confirm or deny this
hypothesis.

7 years agoAttmept to fix a spurious failure on AppVeyor
Alex Crichton [Thu, 3 May 2018 15:01:25 +0000 (08:01 -0700)]
Attmept to fix a spurious failure on AppVeyor

I *think* the issue is that `link.exe` is generating debuginfo in the background
which keeps the file open and prevents us from deleting it, but hopefully by
disabling debug information we'll either be able to confirm or deny this
hypothesis.

7 years agoAuto merge of #5468 - matklad:aliases, r=alexcrichton
bors [Thu, 3 May 2018 15:31:44 +0000 (15:31 +0000)]
Auto merge of #5468 - matklad:aliases, r=alexcrichton

Tweak handling of aliases

Previously, `execute_subcommand` was called recursively, and each call
would `.configure` the `config` again. It worked, but seemed rather
fragile.

This commit handles aliases more explicitly, ensures that `.configure`
is called once and, as a bonus, adds a warning for when an alias is
shadowed by the built in.

7 years agoTweak error messages
Aleksey Kladov [Thu, 3 May 2018 11:05:21 +0000 (14:05 +0300)]
Tweak error messages

By convention, all errors should start with a lowercase letter

7 years agoMake alias handling more straightforward
Aleksey Kladov [Thu, 3 May 2018 10:50:05 +0000 (13:50 +0300)]
Make alias handling more straightforward

Previously, `execute_subcommand` was called recursively, and each call
would `.configure` the `config` again. It worked, but seemed rather
fragile.

This commit handles aliases more explicitly, ensures that `.configure`
is called once and, as a bonus, adds a warning for when an alias is
shadowed by the built in.

7 years agoAuto merge of #5464 - ehuss:restore-example-test, r=alexcrichton
bors [Thu, 3 May 2018 13:43:38 +0000 (13:43 +0000)]
Auto merge of #5464 - ehuss:restore-example-test, r=alexcrichton

Partially revert change to testing examples.

Fixes #5437

I don't think changing the behavior was quite the correct thing to do.  This new behavior is very similar to the old with a few small differences:

```
cargo test
    ORGINAL: Only builds examples.
    NEW: Builds all examples.  Any example with `test` set is tested.

cargo test --tests
    ORIGINAL: Runs all examples as tests.
    NEW: Only runs examples as tests if `test` is set.

cargo test --examples
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)

cargo test --example foo
    ORIGINAL: Runs the given example as a test.
    NEW: (SAME)

cargo test --all-targets
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)
```

7 years agoAuto merge of #5469 - matklad:fix-link, r=matklad
bors [Thu, 3 May 2018 13:06:37 +0000 (13:06 +0000)]
Auto merge of #5469 - matklad:fix-link, r=matklad

Fix link in docs

7 years agoFix link in docs
Aleksey Kladov [Thu, 3 May 2018 13:06:18 +0000 (16:06 +0300)]
Fix link in docs

7 years agoAuto merge of #5466 - matklad:pr-5465, r=matklad
bors [Thu, 3 May 2018 10:26:59 +0000 (10:26 +0000)]
Auto merge of #5466 - matklad:pr-5465, r=matklad

Fix target_dir handling for RLS

Supersedes  and closes #5465

7 years agoFix the test
Aleksey Kladov [Thu, 3 May 2018 10:22:03 +0000 (13:22 +0300)]
Fix the test

7 years agoRevert part to #5393
Nick Cameron [Thu, 3 May 2018 08:23:49 +0000 (20:23 +1200)]
Revert part to #5393

Commit 0b530c30867da26a4b59146f490c9f1d5377c20a (which this commit mostly reverts) did some refactoring around the `target_dir` function. However, it introduced a bug because it meant that where `CARGO_TARGET_DIR` was specified but `--target-dir` was not, the value from `CARGO_TARGET_DIR` was ignored.

7 years agoPartially revert change to testing examples.
Eric Huss [Thu, 3 May 2018 03:17:53 +0000 (20:17 -0700)]
Partially revert change to testing examples.

Fixes #5437

I don't think changing the behavior was quite the correct thing to do.  This new behavior is very similar to the old with a few small differences:

```
cargo test
    ORGINAL: Only builds examples.
    NEW: Builds all examples.  Any example with `test` set is tested.

cargo test --tests
    ORIGINAL: Runs all examples as tests.
    NEW: Only runs examples as tests if `test` is set.

cargo test --examples
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)

cargo test --example foo
    ORIGINAL: Runs the given example as a test.
    NEW: (SAME)

cargo test --all-targets
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)
```

7 years agoAuto merge of #5462 - matklad:install-releases, r=alexcrichton
bors [Wed, 2 May 2018 23:52:15 +0000 (23:52 +0000)]
Auto merge of #5462 - matklad:install-releases, r=alexcrichton

Don't install pre-releases by default

Currently, `cargo install` will try to install a pre-release version, if available (try `cargo install rand`). This happens because we use `VersionReq::any`, if no version is specified, and that matches pre-releases. The fix is to use `*`, which is different from `any`.

This needs to be done in `cargo install`, and not directly in `parse_no_deprecated`, the latter would be wrong, as demonstrated by a new test with patch.

7 years agoDon't install pre-releases by default
Aleksey Kladov [Wed, 2 May 2018 22:26:48 +0000 (01:26 +0300)]
Don't install pre-releases by default

7 years agoAuto merge of #5459 - matklad:more-comments, r=alexcrichton
bors [Wed, 2 May 2018 19:03:17 +0000 (19:03 +0000)]
Auto merge of #5459 - matklad:more-comments, r=alexcrichton

Explain why we need a `Vec<Dependency>` in `Resolve`.

Looks like everyone, who sees it, asks the same question, so let's add an explanation!

cc https://github.com/rust-lang/cargo/pull/5428#issuecomment-385459845

7 years agoAuto merge of #5456 - LukasKalbertodt:patch-1, r=matklad
bors [Wed, 2 May 2018 17:17:27 +0000 (17:17 +0000)]
Auto merge of #5456 - LukasKalbertodt:patch-1, r=matklad

Show elapsed time in minutes if >= 60 secs

In large projects with long compile times, seeing "428.65 secs" isn't as clear to humans as seeing the number of minutes (and seconds).

**Old**:
```
Finished dev [unoptimized + debuginfo] target(s) in 2.23 secs
Finished dev [unoptimized + debuginfo] target(s) in 63.94 secs
Finished dev [unoptimized + debuginfo] target(s) in 428.65 secs
```

**New**:
```
Finished dev [unoptimized + debuginfo] target(s) in 2.23s
Finished dev [unoptimized + debuginfo] target(s) in 1m 3.94s
Finished dev [unoptimized + debuginfo] target(s) in 7m 8.65s
```

Note that I also changed `secs` to `s`, because `7 mins 8.65 secs` and `7m 8.65 secs` both look strange IMO. But if you disagree and you'd prefer `secs`, just tell me and I'll change it.

I *didn't* add a check for `secs >= 3600` to print the time in hours. I *hope* this is not necessary...

7 years agoAuto merge of #5458 - alexcrichton:track-panic, r=matklad
bors [Wed, 2 May 2018 16:35:38 +0000 (16:35 +0000)]
Auto merge of #5458 - alexcrichton:track-panic, r=matklad

Track panic mode in fingerprint

Ensure that if we've previously compiled a crate with panic=abort and we later
need it for panic=unwind we correctly recompile it.

Closes #5445

7 years agoAdjust tests to new time output format
Lukas Kalbertodt [Wed, 2 May 2018 12:52:40 +0000 (14:52 +0200)]
Adjust tests to new time output format

7 years agoShow elapsed time in minutes if >= 60 secs
Lukas Kalbertodt [Wed, 2 May 2018 10:15:37 +0000 (12:15 +0200)]
Show elapsed time in minutes if >= 60 secs

In large projects with long compile times, seeing "400.65 secs" isn't as
clear as seeing the number of minutes (and seconds).

7 years agoAuto merge of #5454 - alexcrichton:fix, r=matklad
bors [Wed, 2 May 2018 15:35:33 +0000 (15:35 +0000)]
Auto merge of #5454 - alexcrichton:fix, r=matklad

Fix optional dependencies and required dev-deps

This fixes an accidental bug introduced in #5300 by ensuring a local map keeps
track of the fact that there can be multiple dependencies for one name

Closes #5453

7 years agoExplain why we need a `Vec<Dependency>` in `Resolve`.
Aleksey Kladov [Wed, 2 May 2018 15:13:03 +0000 (18:13 +0300)]
Explain why we need a `Vec<Dependency>` in `Resolve`.

7 years agoAuto merge of #5446 - csmoe:new_name, r=alexcrichton
bors [Wed, 2 May 2018 14:40:15 +0000 (14:40 +0000)]
Auto merge of #5446 - csmoe:new_name, r=alexcrichton

Emit correct project name with --name

Fixes #5440

7 years agoTrack panic mode in fingerprint
Alex Crichton [Wed, 2 May 2018 14:32:10 +0000 (07:32 -0700)]
Track panic mode in fingerprint

Ensure that if we've previously compiled a crate with panic=abort and we later
need it for panic=unwind we correctly recompile it.

Closes #5445

7 years agoAuto merge of #5432 - djc:split-context, r=alexcrichton
bors [Wed, 2 May 2018 14:15:23 +0000 (14:15 +0000)]
Auto merge of #5432 - djc:split-context, r=alexcrichton

Split Context into two types

@matklad here's the crazy attempt to make the `Context` situation slightly more sane. It basically splits all of the stuff that is immutable over the lifetime of the compilation from the stuff that's initialized empty. The latter is now stored in a type which I have provisionally called `BuildProgress` -- feel free to bikeshed about the name (I came up with `BuildData` as another alternative). It stores a reference to the `Context` to make things easier for now, we might want to change that down the line.

IMO this is a pretty good improvement, which clarifies the design quite a bit.

@alexcrichton you'll probably want to review this, too.

7 years agoStore unit dependencies directly into Context
Dirkjan Ochtman [Sun, 29 Apr 2018 19:55:57 +0000 (21:55 +0200)]
Store unit dependencies directly into Context

7 years agoMove Links into context module
Dirkjan Ochtman [Sun, 29 Apr 2018 19:45:35 +0000 (21:45 +0200)]
Move Links into context module

7 years agoExtract new build_context module out of context module
Dirkjan Ochtman [Sat, 28 Apr 2018 15:33:11 +0000 (17:33 +0200)]
Extract new build_context module out of context module

7 years agoSplit Context into two types
Dirkjan Ochtman [Sat, 28 Apr 2018 15:20:27 +0000 (17:20 +0200)]
Split Context into two types

7 years agoFix optional dependencies and required dev-deps
Alex Crichton [Wed, 2 May 2018 00:03:23 +0000 (17:03 -0700)]
Fix optional dependencies and required dev-deps

This fixes an accidental bug introduced in #5300 by ensuring a local map keeps
track of the fact that there can be multiple dependencies for one name

Closes #5453

7 years agoAuto merge of #5451 - DarkDrek:add_doc_clean, r=alexcrichton
bors [Tue, 1 May 2018 18:32:06 +0000 (18:32 +0000)]
Auto merge of #5451 - DarkDrek:add_doc_clean, r=alexcrichton

Add cargo clean --doc

Implements #5449.
It only removes the doc directory and therefore keeps all other build artifacts intact.
When `--doc` is used all other options are ignored.

My test case is mostly copy&paste from `clean_release` so maybe the `.toml`s can be simplified.

7 years agoAdd cargo clean --doc
DarkDrek [Tue, 1 May 2018 15:33:10 +0000 (17:33 +0200)]
Add cargo clean --doc

7 years agoLet Context store BuildConfig by reference
Dirkjan Ochtman [Sat, 14 Apr 2018 09:37:13 +0000 (11:37 +0200)]
Let Context store BuildConfig by reference

7 years agoAuto merge of #5447 - ehuss:ws-error-message, r=alexcrichton
bors [Tue, 1 May 2018 13:50:13 +0000 (13:50 +0000)]
Auto merge of #5447 - ehuss:ws-error-message, r=alexcrichton

Better error message for `cargo rustc` in a workspace.

Fixes #5371

7 years agoAuto merge of #5448 - ehuss:debug_env, r=alexcrichton
bors [Tue, 1 May 2018 03:49:32 +0000 (03:49 +0000)]
Auto merge of #5448 - ehuss:debug_env, r=alexcrichton

Fix "DEBUG" env var in build.rs for debug=0

Fixes #5370

7 years agoBetter error message for `cargo rustc` in a workspace.
Eric Huss [Tue, 1 May 2018 03:39:07 +0000 (20:39 -0700)]
Better error message for `cargo rustc` in a workspace.

Fixes #5371

7 years agoadd test for project name
csmoe [Tue, 1 May 2018 01:39:22 +0000 (09:39 +0800)]
add test for project name

7 years agofix project name
csmoe [Tue, 1 May 2018 01:38:13 +0000 (09:38 +0800)]
fix project name

7 years agoAuto merge of #5443 - rtsuk:update-doc-env-var, r=alexcrichton
bors [Mon, 30 Apr 2018 18:19:47 +0000 (18:19 +0000)]
Auto merge of #5443 - rtsuk:update-doc-env-var, r=alexcrichton

Update documentation on config via environment variables

Use source replacement as a specific example of the kind
of configuration feature that cannot currently be set by
environmental variables.

7 years agoAuto merge of #5300 - djc:namespaced-features, r=alexcrichton
bors [Mon, 30 Apr 2018 17:52:35 +0000 (17:52 +0000)]
Auto merge of #5300 - djc:namespaced-features, r=alexcrichton

Introduction of namespaced features (see #1286)

I think this basically covers all of the plans from #1286, although it still needs a bunch of tests and documentation updates. Submitting this PR to get some early feedback on the direction.

7 years agoFix "DEBUG" env var in build.rs for debug=0.
Eric Huss [Mon, 30 Apr 2018 17:17:43 +0000 (10:17 -0700)]
Fix "DEBUG" env var in build.rs for debug=0.

Fixes #5370

7 years agoUpdate documentation on config via environment variables
Rob Tsuk [Mon, 30 Apr 2018 15:49:27 +0000 (08:49 -0700)]
Update documentation on config via environment variables

Use source replacement as a specific example of the kind
of configuration feature that cannot currently be set by
environmental variables.

7 years agoPut namespaced features behind a feature gate
Dirkjan Ochtman [Mon, 30 Apr 2018 08:42:52 +0000 (10:42 +0200)]
Put namespaced features behind a feature gate

7 years agoAuto merge of #5430 - matklad:bring-old-features-back, r=alexcrichton
bors [Sat, 28 Apr 2018 18:02:36 +0000 (18:02 +0000)]
Auto merge of #5430 - matklad:bring-old-features-back, r=alexcrichton

Revert "Enable new behavior of `--feature`"

This reverts commit 038eec5cb3bd25a0855b0be6ad2aeba5391c6c6e.

As discussed at https://github.com/rust-lang/cargo/issues/5364, the new behavior unfortunately causes real-life breakage, so we have to revert it.

This is kinda sad, this is a part of the larger issue with feature selection, which, at the moment, has a behavior which I would classify (loosely speaking) as unsound:

* `cargo build -p foo` and `cargo build -p foo -p bar` might produce different artifacts for `foo` ([repro](https://github.com/matklad/workspace-vs-feaures))
* `cargo build -p foo` might produce different artifacts, depending on cwd ([repro](https://github.com/matklad/features-cwd))

The new feature behavior specifically addressed the second point.

It is unclear what we could do with this... One option, instead of flatly erroring out, as the revreted commit does, is to print a warning, but change the set of activated features. It will still be a breaking change, but it at least has  a chance of working by accident.

r? @alexcrichton

7 years agoAuto merge of #5425 - matklad:rename-fingerprint, r=alexcrichton
bors [Sat, 28 Apr 2018 16:44:31 +0000 (16:44 +0000)]
Auto merge of #5425 - matklad:rename-fingerprint, r=alexcrichton

Package renames should affect fingerprints

7 years agoAuto merge of #5428 - matklad:graph-with-edges, r=alexcrichton
bors [Sat, 28 Apr 2018 16:10:39 +0000 (16:10 +0000)]
Auto merge of #5428 - matklad:graph-with-edges, r=alexcrichton

Store dependencies as edges of the graph

r? @alexcrichton

7 years agoAuto merge of #5429 - matklad:dashes-test, r=matklad
bors [Sat, 28 Apr 2018 14:59:21 +0000 (14:59 +0000)]
Auto merge of #5429 - matklad:dashes-test, r=matklad

Extend dashes forwarding test

Closes https://github.com/rust-lang/cargo/issues/2213

Looks like this was fixed when we've transitioned to clap!

7 years agoExtend dashes forwarding test
Aleksey Kladov [Sat, 28 Apr 2018 14:57:03 +0000 (17:57 +0300)]
Extend dashes forwarding test

7 years agoRevert "Enable new behavior of `--feature`"
Aleksey Kladov [Sat, 28 Apr 2018 14:28:39 +0000 (17:28 +0300)]
Revert "Enable new behavior of `--feature`"

This reverts commit 038eec5cb3bd25a0855b0be6ad2aeba5391c6c6e.

7 years agoStore dependencies as edges of the graph
Aleksey Kladov [Sat, 28 Apr 2018 12:59:27 +0000 (15:59 +0300)]
Store dependencies as edges of the graph

7 years agoAdd some documentation about unstable namespaced-features feature
Dirkjan Ochtman [Mon, 23 Apr 2018 07:18:08 +0000 (09:18 +0200)]
Add some documentation about unstable namespaced-features feature

7 years agoAdd tests for namespaced features
Dirkjan Ochtman [Wed, 18 Apr 2018 10:12:43 +0000 (12:12 +0200)]
Add tests for namespaced features

7 years agoTake feature namespace into account while building summary (fixes #1286)
Dirkjan Ochtman [Thu, 5 Apr 2018 14:59:51 +0000 (16:59 +0200)]
Take feature namespace into account while building summary (fixes #1286)

Here's an attempt at a table to cover the different cases:

Feature
    Old (must be in features table)
        Continue
    Namespaced (might be stray value)
        In features table: Check that Crate dependency is in the list
        -> Non-optional dependency: Bail [PREVIOUSLY: bailed for non-optional dependency]
        -> Optional dependency: Insert feature of this name
        -> Else: Bail [PREVIOUSLY: bailed for unknown dependency or feature]

Crate
    Old (might be stray value)
        Non-optional dependency: Bail
        No dependency found: Bail
    Namespaced
        Non-optional dependency: Bail
        No dependency found: Bail

CrateFeature
    Old
        No dependency found: Bail
    Namespaced
        No dependency found: Bail

7 years agoKeep track of namespaced-features flag in Summary objects
Dirkjan Ochtman [Mon, 2 Oct 2017 09:00:18 +0000 (11:00 +0200)]
Keep track of namespaced-features flag in Summary objects

For now, all Summaries from a registry have it set to false.

7 years agoAdd namespaced-features option for manifest [project] section
Dirkjan Ochtman [Mon, 2 Oct 2017 07:30:22 +0000 (09:30 +0200)]
Add namespaced-features option for manifest [project] section

7 years agoMake a dependencies map while building feature map
Dirkjan Ochtman [Thu, 5 Apr 2018 14:23:11 +0000 (16:23 +0200)]
Make a dependencies map while building feature map

7 years agoSimplify retrieval of dependency data
Dirkjan Ochtman [Thu, 5 Apr 2018 13:22:37 +0000 (15:22 +0200)]
Simplify retrieval of dependency data

7 years agoMix package renames into fingerprints
Aleksey Kladov [Sat, 28 Apr 2018 10:35:49 +0000 (13:35 +0300)]
Mix package renames into fingerprints

7 years agoAuto merge of #5384 - ehuss:profile-override, r=matklad
bors [Fri, 27 Apr 2018 23:22:50 +0000 (23:22 +0000)]
Auto merge of #5384 - ehuss:profile-override, r=matklad

Profile Overrides (RFC #2282 Part 1)

Profile Overrides (RFC #2282 Part 1)

WIP: Putting this up before I dig into writing tests, but should be mostly complete.  I also have a variety of questions below.

This implements the ability to override profiles for dependencies and build scripts.  This includes a general rework of how profiles work internally. Closes #5298.

Profile overrides are available with `profile-overrides` set in `cargo-features` in the manifest.

Part 2 is to implement profiles in config files (to be in a separate PR).

General overview of changes:

- `Profiles` moved to `core/profiles.rs`. All profile selection is centralized there.
- Removed Profile flags `test`, `doc`, `run_custom_build`, and `check`.
- Removed `Profile` from `Unit` and replaced it with two enums: `CompileMode` and `ProfileFor`.  This is the minimum information needed to compute profiles at a later stage.
- Also removed `rustc_args`/`rustdoc_args` from `Profile` and place them in `Context`.  This is currently not very elegant because it is a special case, but it works. An alternate solution I considered was to leave them in the `Profile` and add a special uber-override layer.  Let me know if you think it should change.
- Did some general cleanup in `generate_targets`.

## Misc Fixes
- `cargo check` now honors the `--release` flag.  Fixes #5218.
- `cargo build --test` will set `panic` correctly for dependences. Fixes #5369.
- `cargo check --tests` will no longer include bins twice (once as a normal check, once as a `--test` check).  It only does `--test` check now.
    - Similarly, `cargo check --test name` no longer implicitly checks bins.
- Examples are no longer considered a "test".  (See #5397). Consequences:
    - `cargo test` will continue to build examples as a regular build (no change).
    - `cargo test --tests` will no longer build examples at all.
    - `cargo test --all-targets` will no longer build examples as tests, but instead build them as a regular build (now matches `cargo test` behavior).
    - `cargo check --all-targets` will no longer check examples twice (once as
      normal, once as `--test`).  It now only checks it once as a normal
      target.

## Questions
- Thumbs up/down on the general approach?
- The method to detect if a package is a member of a workspace should probably be redone.  I'm uncertain of the best approach.  Maybe `Workspace.members` could be a set?
- `Hash` and `PartialEq` are implemented manually for `Profile` only to avoid matching on the `name` field.  The `name` field is only there for debug purposes. Is it worth it to keep `name`?  Maybe useful for future use (like #4140)?
- I'm unhappy with the `Finished` line summary that displays `[unoptimized + debuginfo]`.  It doesn't actually show what was compiled.  Currently it just picks the base "dev" or "release" profile.  I'm not sure what a good solution is (to be accurate it would need to potentially display a list of different options).  Is it ok?  (See also #4140 for the wrong profile name being printed.)
- Build-dependencies use different profiles based on whether or not `--release` flag is given.  This means that if you want build-dependencies to always use a specific set of settings, you have to specify both `[profile.dev.build_override]` and `[profile.release.build_override]`.  Is that reasonable (for now)?  I've noticed some issues (like #1774, #2234, #2424) discussing having more control over how build-dependencies are handled.
- `build --bench xxx` or `--benches` builds dependencies with dev profile, which may be surprising.  `--release` does the correct thing.  Perhaps print a warning when using `cargo build` that builds benchmark deps in dev mode?
- Should it warn/error if you have an override for a package that does not exist?
- Should it warn/error if you attempt to set `panic` on the `test` or `bench` profile?

## TODO
- I have a long list of tests to add.
- Address a few "TODO" comments left behind.

7 years agoMinor style update.
Eric Huss [Fri, 27 Apr 2018 18:23:57 +0000 (11:23 -0700)]
Minor style update.

7 years agoComment why `deps_of` doesn't need to keep track of `profile_for` in map.
Eric Huss [Tue, 24 Apr 2018 17:35:20 +0000 (10:35 -0700)]
Comment why `deps_of` doesn't need to keep track of `profile_for` in map.

7 years agoFix Unit/Context parameter order.
Eric Huss [Tue, 24 Apr 2018 17:12:53 +0000 (10:12 -0700)]
Fix Unit/Context parameter order.

7 years agoAvoid building libs and bins twice in `cargo build --all-targets --release`.
Eric Huss [Sun, 22 Apr 2018 20:57:38 +0000 (13:57 -0700)]
Avoid building libs and bins twice in `cargo build --all-targets --release`.

This changes it so that `Build` mode is not set in the Unit, since there is
no difference between Bench and Test once the profile has been selected.

7 years agoUpdate tests now that `cargo check` does not re-check bins.
Eric Huss [Sun, 22 Apr 2018 16:05:18 +0000 (09:05 -0700)]
Update tests now that `cargo check` does not re-check bins.

7 years agoAdd some more tests.
Eric Huss [Sun, 22 Apr 2018 00:21:42 +0000 (17:21 -0700)]
Add some more tests.

7 years agoAdd thorough tests for target/profile selection.
Eric Huss [Sat, 21 Apr 2018 20:57:54 +0000 (13:57 -0700)]
Add thorough tests for target/profile selection.

7 years agoMove profile override tests to a dedicated file.
Eric Huss [Sat, 21 Apr 2018 20:47:01 +0000 (13:47 -0700)]
Move profile override tests to a dedicated file.

7 years agorustfmt
Eric Huss [Sat, 21 Apr 2018 19:16:03 +0000 (12:16 -0700)]
rustfmt

7 years agoRemove last TODO comments.
Eric Huss [Sat, 21 Apr 2018 18:18:05 +0000 (11:18 -0700)]
Remove last TODO comments.

7 years agoSome test cleanup for profiles.
Eric Huss [Sat, 21 Apr 2018 17:41:05 +0000 (10:41 -0700)]
Some test cleanup for profiles.

7 years agoAdd more profile override validation tests.
Eric Huss [Sat, 21 Apr 2018 17:03:23 +0000 (10:03 -0700)]
Add more profile override validation tests.

7 years agoAdd test for profile override on non-dev/release.
Eric Huss [Sat, 21 Apr 2018 16:50:55 +0000 (09:50 -0700)]
Add test for profile override on non-dev/release.

7 years agoAdd warning if `panic` is set in test or bench profile.
Eric Huss [Sat, 21 Apr 2018 16:40:00 +0000 (09:40 -0700)]
Add warning if `panic` is set in test or bench profile.

7 years agoAdd warnings for unknown profile overrides.
Eric Huss [Sat, 21 Apr 2018 05:19:16 +0000 (22:19 -0700)]
Add warnings for unknown profile overrides.

7 years agoMinor tweaks on how examples are handled with tests, and some panic propagation.
Eric Huss [Sat, 21 Apr 2018 02:43:57 +0000 (19:43 -0700)]
Minor tweaks on how examples are handled with tests, and some panic propagation.

7 years agoAvoid running `build.rs` too often.
Eric Huss [Fri, 20 Apr 2018 20:20:38 +0000 (13:20 -0700)]
Avoid running `build.rs` too often.

7 years agoAdd extra rustc/rustdoc args to the fingerprint and metadata.
Eric Huss [Thu, 19 Apr 2018 02:54:01 +0000 (19:54 -0700)]
Add extra rustc/rustdoc args to the fingerprint and metadata.

7 years agoUpdate for some review comments.
Eric Huss [Thu, 19 Apr 2018 02:17:38 +0000 (19:17 -0700)]
Update for some review comments.

7 years agoFix a variety of profile bugs.
Eric Huss [Thu, 19 Apr 2018 00:21:03 +0000 (17:21 -0700)]
Fix a variety of profile bugs.

7 years agoMove `Profile` back into `Unit` as a copy.
Eric Huss [Wed, 18 Apr 2018 18:41:58 +0000 (11:41 -0700)]
Move `Profile` back into `Unit` as a copy.

The de-duplication of Units just doesn't work without it.

7 years agoMinor cleanup.
Eric Huss [Wed, 18 Apr 2018 14:03:17 +0000 (07:03 -0700)]
Minor cleanup.

7 years agoProfile Overrides (RFC #2282 Part 1)
Eric Huss [Wed, 18 Apr 2018 01:46:44 +0000 (18:46 -0700)]
Profile Overrides (RFC #2282 Part 1)

7 years agoAuto merge of #5415 - alexcrichton:rename-same-dep, r=matklad
bors [Fri, 27 Apr 2018 17:48:52 +0000 (17:48 +0000)]
Auto merge of #5415 - alexcrichton:rename-same-dep, r=matklad

Fix renaming crates as they come from 2 sources

Previously there was a verification in manifest parsing that the same dependency
must come from the same source, but this erroneously triggered an error to get
emitted when the `package` key was used to rename crates. The first change here
was to update that clause to key off the `rename` field rather than the `name`
field.

Afterwards, though, this exposed an existing bug in the implementation. During
compilation we have a `Resolve` which is a graph of crates, but we don't know
*why* each edge in the dependency graph exists. In other words we don't know,
when looking at an edge of the graph, what `Dependency` caused that edge to be
drawn. We need to know this when passing `--extern` flags because the
`Dependency` is what lists what's being renamed.

This commit then primarily refactors `Resolve::deps` from an iterator of package
ids to an iterator of a tuples. The first element is the package id from before
and the second element is a list of `Dependency` directives which caused the
edge to ber driven.

This refactoring cleaned up a few places in the backend where we had to work
around the lack of this knowledge. Namely this also fixes the extra test added
here.

Closes #5413

7 years agoFix renaming crates as they come from 2 sources
Alex Crichton [Wed, 25 Apr 2018 17:41:33 +0000 (10:41 -0700)]
Fix renaming crates as they come from 2 sources

Previously there was a verification in manifest parsing that the same dependency
must come from the same source, but this erroneously triggered an error to get
emitted when the `package` key was used to rename crates. The first change here
was to update that clause to key off the `rename` field rather than the `name`
field.

Afterwards, though, this exposed an existing bug in the implementation. During
compilation we have a `Resolve` which is a graph of crates, but we don't know
*why* each edge in the dependency graph exists. In other words we don't know,
when looking at an edge of the graph, what `Dependency` caused that edge to be
drawn. We need to know this when passing `--extern` flags because the
`Dependency` is what lists what's being renamed.

This commit then primarily refactors `Resolve::deps` from an iterator of package
ids to an iterator of a tuples. The first element is the package id from before
and the second element is a list of `Dependency` directives which caused the
edge to ber driven.

This refactoring cleaned up a few places in the backend where we had to work
around the lack of this knowledge. Namely this also fixes the extra test added
here.

Closes #5413

7 years agoAuto merge of #5349 - bmwill:fetch-by-target, r=alexcrichton
bors [Fri, 27 Apr 2018 15:36:16 +0000 (15:36 +0000)]
Auto merge of #5349 - bmwill:fetch-by-target, r=alexcrichton

cargo-fetch: add option to fetch for a target

Teach cargo-fetch how to optionally fetch dependencies based on a target
platform by specifying the target triple via `--target <TRIPLE>`.

#5216

7 years agoAuto merge of #5410 - klnusbaum:edition_5406, r=matklad
bors [Fri, 27 Apr 2018 15:14:03 +0000 (15:14 +0000)]
Auto merge of #5410 - klnusbaum:edition_5406, r=matklad

switch to using the --edition flag

Now that we have an `--edition` flag in the rust compiler, let's switch to using it.

fixes #5406

7 years agocargo-fetch: add option to fetch for a target
Brandon Williams [Mon, 9 Apr 2018 18:31:04 +0000 (11:31 -0700)]
cargo-fetch: add option to fetch for a target

Teach cargo-fetch how to optionally fetch dependencies based on a target
platform by specifying the target triple via `--target <TRIPLE>`.

Signed-off-by: Brandon Williams <bmwill@google.com>
7 years agoAuto merge of #5394 - henriklaxhuber:master, r=alexcrichton
bors [Tue, 24 Apr 2018 14:36:52 +0000 (14:36 +0000)]
Auto merge of #5394 - henriklaxhuber:master, r=alexcrichton

Pass linker path to build script

This change adds the environment variable LINKER to pass the path of the linker used by cargo to the build script. This complements the variable RUSTC (the rustc binary used) to give the build script full knowledge of its environment.

A specific usage example would be automatically generating bindings to system headers in cross compilation, e.g. by locating jni.h for android targets.

7 years agoAuto merge of #5393 - smithsps:master, r=matklad
bors [Tue, 24 Apr 2018 14:12:10 +0000 (14:12 +0000)]
Auto merge of #5393 - smithsps:master, r=matklad

Add target directory parameter --target-dir

Implements: https://github.com/rust-lang/cargo/issues/5308

Adds a target directory parameter, that acts in the same manner as the environment variable `CARGO_TARGET_DIR`, to the following subcommands:
- `bench`
- `build`
- `check`
- `clean`
- `doc`
- `package`
- `publish`
- `run`
- `rustc`
- `rustdoc`
- `test`

7 years agoAuto merge of #5398 - dwijnand:drop-legacy-paths, r=matklad
bors [Tue, 24 Apr 2018 09:07:18 +0000 (09:07 +0000)]
Auto merge of #5398 - dwijnand:drop-legacy-paths, r=matklad

Drop legacy path support under Rust edition 2018 (or later)

builds on #5335

submitted for early feedback: wdyt @matklad? is this what you had in mind? what should change? what should be added? how should we test this? is the current (2015) messaging enough to drop it in 2018?

r? @matklad

<!--{"baseBranch":"rust-lang:cargo:target-autodiscovery"}-->

7 years agoAdd target directory parameter: address suggestions
Simon Smith [Tue, 24 Apr 2018 06:15:55 +0000 (02:15 -0400)]
Add target directory parameter: address suggestions

7 years agoMoved RUSTC_LINKER test into its own fn
Henrik Laxhuber [Tue, 24 Apr 2018 06:18:33 +0000 (08:18 +0200)]
Moved RUSTC_LINKER test into its own fn

7 years agoAdd target directory parameter --target-dir
Simon Smith [Mon, 16 Apr 2018 23:50:30 +0000 (19:50 -0400)]
Add target directory parameter --target-dir

7 years agoFixed RUSTC_LINKER test for Windows hosts
Henrik Laxhuber [Mon, 23 Apr 2018 16:28:38 +0000 (18:28 +0200)]
Fixed RUSTC_LINKER test for Windows hosts

7 years agoFixed build script env var test
Henrik Laxhuber [Mon, 23 Apr 2018 15:45:17 +0000 (17:45 +0200)]
Fixed build script env var test

7 years agoAdded tests for RUSTC_LINKER buils script env var
Henrik Laxhuber [Mon, 23 Apr 2018 15:11:10 +0000 (17:11 +0200)]
Added tests for RUSTC_LINKER buils script env var

Added tests for the environment variable RUSTC_LINKER that is
passed to the build script.
Also slightly improved readability of the code responsible for
passing the env var.

7 years agoswitch to using the --edition flag
Kurtis Nusbaum [Sun, 22 Apr 2018 19:14:21 +0000 (12:14 -0700)]
switch to using the --edition flag