Commit graph

37 commits

Author SHA1 Message Date
Anthony Ramine 3ce50d02a9 Don't recurse out of CARGO_HOME when looking for workspace root
This fixes #4765.
2017-12-01 02:41:02 +01:00
Simon Sapin 8d5e73c63b Make default-members apply to non-virtual workspaces too 2017-11-29 10:59:19 +01:00
Simon Sapin ba7911dda4 Add a workspace.default-members config that overrides implied --all
When no package is selected with `-p`, the default behavior
for virtual workspaces is to select every member
as if `--all` were used.
2017-11-29 10:59:19 +01:00
bors 5763451096 Auto merge of #4314 - nodakai:phantom-type-in-projectbuilder, r=matklad
cargotest/support: remove internal mutability in favor of switching types

`Cell<bool>` was removed from `ProjectBuilder`. Instead `PhantomData<T>` was added to it (and `RepoBuilder`) to manage state transition in the type level (`T` is either `Configuring` or `Done`.)
`ProjectBuilder::cargo_process()` was removed as its design heavily depended on the internal mutability.

Also added `#[must_use]` to `ProjectBuilder` and `RepoBuilder` to check for call sites of their `build()` method.
2017-10-12 08:52:44 +00:00
NODA, Kai d43ee1dd22
cargotest/support: remove internal mutability in favor of switching types
Remove is_build: Cell<bool> from ProjectBuilder and introduce a new type Project.

is_build==false <-> ProjectBuilder
is_build==true <-> Project

Also add #[must_use] to ProjectBuilder to confirm its instances are surely consumed by its build() method to produce Project.

The same goes for RepoBuilder.

ProjectBuilder::cargo_process() was removed as its design heavily depended on the internal mutability.

Signed-off-by: NODA, Kai <nodakai@gmail.com>
2017-10-10 16:47:12 +08:00
Behnam Esfahbod f320997f6f [core/workspace] Create WorkspaceRootConfig
Create `WorkspaceRootConfig`, which knows its `root_dir` and lists of
`members` and `excludes`, to answer queries on which paths are a member
and which are not.
2017-10-07 14:17:19 -07:00
Ray Tung 850fbdc0b5 Removed extraneous logic that generates [root] in cargo.lock 2017-10-03 23:18:08 +11:00
Ralf Jung 56274af098 fix confusing error for virtual manifest with no member 2017-09-14 13:52:06 +02:00
Nipunn Koorapati d2ca374c89 Cleanup debug statements 2017-09-09 13:46:02 -07:00
Nipunn Koorapati 7336e3229e Refactor to share code from dep_targets. Fixes the plat-specific case 2017-09-09 13:46:02 -07:00
Nipunn Koorapati 46a5fe9a41 Hashed dependencies of metadata into the metadata of a lib 2017-09-09 13:46:02 -07:00
Romain Sertelon 15791c74cb Adds tests 2017-07-27 21:49:27 +02:00
Herman J. Radtke III 98170335a7
fixes
- fix glob missing members test to use proper expectations
- update code to handle case where glob does not match anything
2017-05-08 22:30:23 -07:00
Herman J. Radtke III 06a1371420
Add test with workspace path that has no Cargo.toml 2017-05-06 23:33:45 -07:00
Herman J. Radtke III b3a747cfe8
Support glob syntax in workspace members
Fixes #3911
2017-04-29 11:24:17 -07:00
Alex Crichton 67364baa9f Add a workspace.exclude key
This commit adds a new key to the `Cargo.toml` manifest, `workspace.exclude`.
This new key is a list of strings which is an array of directories that are
excluded from the workspace explicitly. This is intended for use cases such as
vendoring where path dependencies into a vendored directory don't want to pull
in the workspace dependencies.

There's a number of use cases mentioned on #3192 which I believe should all be
covered with this strategy. At a bare minimum it should suffice to `exclude`
every directory and then just explicitly whitelist crates through `members`
through inclusion, and that should give precise control over the structure of a
workspace.

Closes #3192
2017-03-16 14:50:23 -07:00
Aleksey Kladov 0a3db8b709 Normalize ws root path
closes #3586
2017-02-14 23:12:55 +03:00
Aleksey Kladov 3435414edb Find workspace via workspace_root link in containing member 2017-01-19 16:09:51 +03:00
Aleksey Kladov 2a9eacb1d0 Fix a test.
Presumably, it should failed when it was first written, but Cargo does not do such validation yet.
2017-01-18 10:36:55 +03:00
Aleksey Kladov 7429347eb3 More test for workspaces \w path dependencies 2017-01-15 01:14:47 +03:00
Aleksey Kladov 07c667fb26 Path deps outside workspace are not members
closes #3192
2017-01-14 23:52:19 +03:00
Justin Geibel 34628b6574 Rename debug target to dev in build output
This renames the debug target to dev in the build output for non-release
builds.  This includes the output of commands such as `cargo build`,
`cargo test`, and `cargo doc`.

Closes #3519
2017-01-11 21:10:29 -05:00
Aleksey Kladov 083da14177 Normalize paths before checking for equality 2017-01-07 20:46:35 +03:00
Aleksey Kladov 6d7049218a Don't ignore errors in workspace manifest 2016-12-15 20:27:48 +03:00
Aleksey Kladov 23faf5c916 Add test for --package and virtual manifest
closes #3194
2016-12-12 16:05:19 +03:00
Andy Russell 25518da782 avoid panic when virtual workspace has no members 2016-12-08 16:11:19 -05:00
Matt Brubeck bb058d9c59 Build transitive dev-dependencies when needed
When running `cargo test -p foo` where `foo` is a crate in the current
workspace, build and link `foo`'s dev-dependencies. Fixes #860.
2016-09-27 15:22:59 -07:00
Juan Hernández 015e79728c FIX: Don't try to generate Gargo.lock on empty workspaces.
There was a panic! when the command `cargo update` was
executed in a workspace like this:

    mkdir ws
    cd ws
    echo '[workspace]' > Cargo.toml
    cargo new p1
    cargo new p2
    cargo update

The problem is that cargo tries to generate the Cargo.lock file
even if there aren't any members on the workspace.

This fix checks the existence of members in the workspace before trying
to do anything so at least we report an error instead of throwing a
panic!
2016-09-14 15:02:47 -04:00
Aleksey Kladov ab3a1c5386 Don't use current package when reading lockfile 2016-08-25 13:26:48 +03:00
Alex Crichton 8214bb953d Implement source redirection
This commit implements a scheme for .cargo/config files where sources can be
redirected to other sources. The purpose of this will be to override crates.io
for a few use cases:

  * Replace it with a mirror site that is sync'd to crates.io
  * Replace it with a "directory source" or some other local source

This major feature of this redirection, however, is that none of it is encoded
into the lock file. If one source is redirected to another then it is assumed
that packages from both are exactly the same (e.g. `foo v0.0.1` is the same in
both location). The lock file simply encodes the canonical soure (e.g.
crates.io) rather than the replacement source. In the end this means that
Cargo.lock files can be generated from any replacement source and shipped to
other locations without the lockfile oscillating about where packages came from.

Eventually this support will be extended to `Cargo.toml` itself (which will be
encoded into the lock file), but that support is not implemented today. The
syntax for what was implemented today looks like:

    # .cargo/config
    [source.my-awesome-registry]
    registry = 'https://example.com/path/to/index'

    [source.crates-io]
    replace-with = 'my-awesome-registry'

Each source will have a canonical name and will be configured with the various
keys underneath it (today just 'registry' and 'directory' will be accepted). The
global `crates-io` source represents crates from the standard registry, and this
can be replaced with other mirror sources.

All tests have been modified to use this new infrastructure instead of the old
`registry.index` configuration. This configuration is now also deprecated and
will emit an unconditional warning about how it will no longer be used in the
future.

Finally, all subcommands now use this "source map" except for `cargo publish`,
which will always publish to the default registry (in this case crates.io).
2016-08-01 10:14:52 -07:00
Alex Crichton 9243f06d40 Fix depending on git repos with workspaces
When we're recursively walking over a git repository we can safely ignore any
workspace Cargo.toml files we find instead of generating an error.
2016-07-31 17:06:35 -07:00
Jonathan Turner a882abe73c Add --lib to init/new. Add status message for completed creation 2016-07-29 12:52:33 -07:00
Alex Crichton 0f973c2f60 Add a sleep to a rebuilding test to fix nightlies
Just the standard issue with fs timestamps, OSX, etc.
2016-07-28 10:26:32 -07:00
Alex Crichton 0863469c8b Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.

Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.

This is fixed by taking a few steps:

* Everything is now compiled into the `deps` directory, regardless of whether
  it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
  up one level to where they are today. This means that your binaries, dylibs,
  staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
  dependencies are always path dependencies and already all have unique crate
  names. Additionally, they're the only crates in the DAG without metadata, so
  there's no need to provide additional metadata. This in turn means that none
  of the file names of the generated crates are mangled.

Closes #2855
2016-07-26 17:52:45 -07:00
Jonathan Turner cd955f129d Add 'Finished' line after compile finishes with compile timing and build type 2016-07-25 16:30:03 -07:00
Alex Crichton c33dddd505 Generate the same lock always in a workspace
Previously the "root" of a lock file would erroneously change over time, so
instead just ensure that the root of a lock file is always the root of the
workspace. Otherwise the contents should always be the same.

Closes #2837
2016-07-08 10:23:41 -07:00
Alex Crichton 58ddb28a49 Implement workspaces in Cargo
This commit is an implementation of [RFC 1525] which specifies the addition of
**workspaces** to Cargo.

[RFC 1525]: https://github.com/rust-lang/rfcs/blob/master/text/1525-cargo-workspace.md

A workspace is a group of crates which are all compiled into the same output
directory and share the same `Cargo.lock` file. This means that dependencies are
cached between builds as well as dependencies all being shared at the same
versions. An update to any one dependency transitively affects all other members
of the workspace.

Typical repository layouts with a crate at the root and a number of path
dependencies simply need to add the following to the root `Cargo.toml`:

```toml
[workspace]
```

Otherwise more advanced configuration may be necessary through the
`package.workspace` or `workspace.members` keys. More information can be found
as part of [RFC 1525].
2016-07-05 15:42:22 -07:00