Auto merge of #2679 - sbeckeriv:alias, r=alexcrichton
Command alias or Alias command #1091
Dearest Reviewer,
This pull request closes #1091 which is a request to support aliases.
This is not as powerful as something like git's alias, however, I think
it sticks true to the original request.
I high jack the processing of the args. After a few flags are checked
and the args are parsed I check the config file for alias.COMMAND. If it
is there I split it like args does and replace args[1] (the original
command) with the alias command and its 'flags'.
As an extra measure I output the alias command with warn. I would be
willing to drop that or put it behind a verbose flag. Also the docs have
been updated.
Auto merge of #2863 - QuiltOS:specified-req, r=alexcrichton
Make the `DependencyInner::specified_req` field a bool.
I could almost get rid if it completely, but then the dependency verifier would have to abort on, say, no version req specified or the any req. Crates.io indeed doesn't want wildcards, but other registries some day may have a different policy.
Making it a mere bool---since all the information it contained is on the `req` field anyways---was the next best thing.
John Ericson [Tue, 12 Jul 2016 16:55:02 +0000 (09:55 -0700)]
Make the `DependencyInner::specified_req` field a bool.
This field is hardly used. I could almost get rid if it completely, but
then the dependency verifier would have to abort on, say, no version req
specified or the any req. Crates.io indeed doesn't want such wildcards, but
other registries some day may have a different policy.
Making it a mere bool---since all the information it contained is in the
`req` field anyways---was the next best thing.
Auto merge of #2853 - matklad:reduce-duplication, r=alexcrichton
Reduce duplication in `Context` creation
There was some duplicated code for `Context` creation in `cargo_clean` and `cargo_rustc`. I've tried to remove it by moving the common part into `Context::new`. Not sure that this is the right thing to do though, it's just something I came across while tracing `rustc_info` flow.
Additional possible refactoring would be to remove `Default` bound from `BuildConfig`.
Auto merge of #2839 - alexcrichton:same-root, r=brson
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.
Alex Crichton [Fri, 8 Jul 2016 06:11:22 +0000 (23:11 -0700)]
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.
This pull request closes #1091 which is a request to support aliases.
This is not as powerful as something like git's alias, however, I think
it sticks true to the original request.
I high jack the processing of the args. After a few flags are checked
and the args are parsed I check the config file for alias.COMMAND. If it
is there I split it like args does and replace args[1] (the original
command) with the alias command and its 'flags'.
I have also included default short hand commands b, t and r.
Auto merge of #2828 - bennofs:cargo-repackage, r=alexcrichton
cargo package: overwrite existing tarballs
Previously, cargo package did not do anything if a tarball already
existed. This is wrong, because the source may have changed and cargo
does not do any dependency tracking for package tarballs yet, so it did
not notice this.
This commit changes cargo package to always overwrite existing tarballs,
which works fine until proper dependency tracking is implemented.
Previously, cargo package did not do anything if a tarball already
existed. This is wrong, because the source may have changed and cargo
does not do any dependency tracking for package tarballs yet, so it did
not notice this.
This commit changes cargo package to always overwrite existing tarballs,
which works fine until proper dependency tracking is implemented.
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].
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].
Auto merge of #2821 - bennofs:no-transitive-dep-feature, r=alexcrichton
Disallow specifying features of transitive deps
Before this commit, it was possible to activate a feature in a transtive
dependency, using a Cargo.toml like the following one:
...
[features]
# this will enable feature fast in package bar, which is a
# dependency of foo
default = [ foo/bar/fast ]
This is a bug, and was never intended, and it is checked in other places
already. The behavior was possible because `build_features::add_feature`
treats the specification "foo/bar/fast" as just another feature. So when
we require the feature "foo/bar/fast", add_feature for foo will generate a
dependency on "foo" requiring that feature "bar/fast" is enabled. Then,
when resolving foo, add_feature will find that "bar/fast" is a required
feature, so it'll happily add "fast" as the required feature for the
dependency "foo".
The fix for this is to make sure that the `add_feature` function does
not treat `a/b` specifications as just another feature. Instead, it now
handles that case without recursion directly when it encounters it.
We can see how this resolves the above problem: when resolving foo,
add_feature for the required feature "bar/fast" will be called.
Because add_feature no longer treats such specifciations differently at
the top level, it will try to enable a feature with the exact name
"bar/fast", and Context::resolve_features will later find that no such
feature exists for package foo.
To give a friendlier error message, we also check in
Context::resolve_features that we never ever require a feature with a
slash in a name from a dependency.
Before this commit, it was possible to activate a feature in a transtive
dependency, using a Cargo.toml like the following one:
...
[features]
# this will enable feature fast in package bar, which is a
# dependency of foo
default = [ foo/bar/fast ]
This is a bug, and was never intended, and it is checked in other places
already. The behavior was possible because `build_features::add_feature`
treats the specification "foo/bar/fast" as just another feature. So when
we require the feature "foo/bar/fast", add_feature for foo will generate a
dependency on "foo" requiring that feature "bar/fast" is enabled. Then,
when resolving foo, add_feature will find that "bar/fast" is a required
feature, so it'll happily add "fast" as the required feature for the
dependency "foo".
The fix for this is to make sure that the `add_feature` function does
not treat `a/b` specifications as just another feature. Instead, it now
handles that case without recursion directly when it encounters it.
We can see how this resolves the above problem: when resolving foo,
add_feature for the required feature "bar/fast" will be called.
Because add_feature no longer treats such specifciations differently at
the top level, it will try to enable a feature with the exact name
"bar/fast", and Context::resolve_features will later find that no such
feature exists for package foo.
To give a friendlier error message, we also check in
Context::resolve_features that we never ever require a feature with a
slash in a name from a dependency.
bors [Wed, 29 Jun 2016 16:27:12 +0000 (09:27 -0700)]
Auto merge of #2809 - cardoe:config-updates, r=alexcrichton
respect configure options for paths
This change causes the installed paths of some files to respect the options passed to configure. It additionally adds another option and removes an unused option.
Doug Goldstein [Mon, 27 Jun 2016 13:46:36 +0000 (08:46 -0500)]
build: respect datadir, infodir, mandir, libdir, and sysconfdir
The configure script exposes datadir, infodir, mandir, libdir, and
sysconfdir but then they are unused so distros or users with
non-standard paths are not able to change things as would be expected by
the configure script.
Doug Goldstein [Tue, 28 Jun 2016 21:27:25 +0000 (16:27 -0500)]
build: strip CFG_PREFIX from CFG_{DATADIR,MANDIR,INFODIR,LIBDIR}
While these variables are not yet used by the Makefile, to be used
CFG_PREFIX must be stripped from them. The 'make install' rule creates
a tarball and then the install.sh script extracts it relative to the
prefix argument --prefix, which in the case of a Cargo install is
relative to CFG_PREFIX. This is why CFG_PREFIX needs to be stripped out
of CFG_DATADIR, CFG_MANDIR, CFG_INFODIR, and CFG_LIBDIR.
bors [Fri, 17 Jun 2016 15:01:14 +0000 (08:01 -0700)]
Auto merge of #2787 - alexcrichton:links-with-dots, r=brson
Don't re-look-up tables to avoid dots problem
If a `links` value has a `.` in the name Cargo would previously panic, but this
alters the code to be more principled about lookup in tables to ensure that we
don't misinterpret the names.
Alex Crichton [Fri, 17 Jun 2016 11:10:29 +0000 (04:10 -0700)]
Don't re-look-up tables to avoid dots problem
If a `links` value has a `.` in the name Cargo would previously panic, but this
alters the code to be more principled about lookup in tables to ensure that we
don't misinterpret the names.
bors [Tue, 14 Jun 2016 14:36:08 +0000 (07:36 -0700)]
Auto merge of #2630 - alexcrichton:build-script-warnings, r=brson
Add build script warnings, streaming output from build scripts to the console
These commits add a few features to Cargo:
* Cargo now recognizes the `warning` key in build scripts and will print warnings *after a build script has completed* if the build script is for a path dependency. That is, if a build script prints `cargo:warning=foo` then Cargo will forward that to the console if the crate's being developed.
* Cargo now accepts multiple `-v` flags for all commands. The `-vv` flag prints warnings for *all* upstream crates, not just the local ones.
* When the `-vv` flag is passed Cargo will stream the output of all build scripts to the console, allowing more easy debugging of what happened if the build fails later on.
More details can be found in each commit, and otherwise this
Alex Crichton [Thu, 14 Apr 2016 06:37:57 +0000 (23:37 -0700)]
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.
Alex Crichton [Tue, 12 Apr 2016 21:55:19 +0000 (14:55 -0700)]
Allow specifying -v multiple times
This commit modifies the CLI interface to allow the verbose (-v) flag to be
specified multiple times. This'll be used soon to have `-vv` indicate that more
output should be generated than `-v` during a normal build.
Currently this commit changes the behavior of whether warnings are printed to
print warnings for the **entire DAG of dependencies** if `-vv` is specified.
That is, `--cap-lints` is never passed nor is any warning from build scripts if
`-vv` is specified.
Alex Crichton [Tue, 12 Apr 2016 21:28:52 +0000 (14:28 -0700)]
Forward warnings from build scripts
This adds support for forwarding warnings from build scripts to the main console
for diagnosis. A new `warning` metadata key is recognized by Cargo and is
printed after a build script has finished executing.
The purpose of this key is for build dependencies to try to produce useful
warnings for local crates being developed. For example a parser generator could
emit warnings about ambiguous grammars or the gcc crate could print warnings
about the C/C++ code that's compiled.
Warnings are only emitted for path dependencies by default (like lints) so
warnings printed in crates.io crates are suppressed.
bors [Sun, 12 Jun 2016 12:21:23 +0000 (05:21 -0700)]
Auto merge of #2680 - alexcrichton:update-toml, r=brson
Update TOML parser to pick up a bugfix
Cargo has previously accepted invalid TOML as valid, but this bugfix should fix
the problem. In order to prevent breaking all crates immediately toml-rs has a
compatibility mode which emulates the bug that was fixed. Cargo will issue a
warning if this compatibility is required to parse a crate.
bors [Sun, 12 Jun 2016 11:46:54 +0000 (04:46 -0700)]
Auto merge of #2668 - alexcrichton:dont-warn-about-metadata, r=brson
Don't warn about `metadata` keys in the manifest
External tools may want to store metadata in `Cargo.toml` that they read but
Cargo itself doesn't read. For example `cargo-apk` uses this for pieces of
configuration. Cargo unfortunately, however, warns about these keys as "unused
keys in the manifest"
This commit instead whitelists the `package.metadata` key to not warn about any
data inside.
Alex Crichton [Thu, 12 May 2016 18:44:00 +0000 (11:44 -0700)]
Update TOML parser to pick up a bugfix
Cargo has previously accepted invalid TOML as valid, but this bugfix should fix
the problem. In order to prevent breaking all crates immediately toml-rs has a
compatibility mode which emulates the bug that was fixed. Cargo will issue a
warning if this compatibility is required to parse a crate.
Alex Crichton [Tue, 10 May 2016 19:55:19 +0000 (12:55 -0700)]
Don't warn about `metadata` keys in the manifest
External tools may want to store metadata in `Cargo.toml` that they read but
Cargo itself doesn't read. For example `cargo-apk` uses this for pieces of
configuration. Cargo unfortunately, however, warns about these keys as "unused
keys in the manifest"
This commit instead whitelists the `package.metadata` key to not warn about any
data inside.
bors [Sat, 11 Jun 2016 02:09:39 +0000 (19:09 -0700)]
Auto merge of #2781 - alexcrichton:block-if-dirty, r=brson
Prevent packaging a crate if any files are dirty
This commit alters Cargo's behavior to prevent publishing a crate by default if
any files in that crate are determined to be dirty, that is either modified or
not part of the working tree.
This can prevent common mistakes like many listed in #2063 and enables features like https://github.com/rust-lang/cargo/issues/841.
bors [Fri, 10 Jun 2016 14:23:32 +0000 (07:23 -0700)]
Auto merge of #2779 - matklad:propagete-color-config, r=alexcrichton
Propagate --color option to rustc
closes #2740
Will try to add a test for this soon (and fix failing tests if any, compiling/running tests locally is slow :( ).
I am not sure what is the right place to add `--color` option to the command line. I use [`build_base_args`]. [`process`] also looks like a good candidate, because it is more general, but if we look at the [`CommandType`] we see that only `rustc` command supports `--color`.
Alex Crichton [Fri, 10 Jun 2016 13:43:34 +0000 (06:43 -0700)]
Prevent packaging a crate if any files are dirty
This commit alters Cargo's behavior to prevent publishing a crate by default if
any files in that crate are determined to be dirty, that is either modified or
not part of the working tree.
This can prevent common mistakes like many listed in #2063, and subsequently...
bors [Tue, 7 Jun 2016 08:05:44 +0000 (01:05 -0700)]
Auto merge of #2763 - mbrubeck:native-dirs, r=alexcrichton
Correctly record multiple native dirs per package
This fixes a bug when a package's build script outputs multiple library search
paths. Because Compilation::native_dirs is a `HashMap<PackageId, PathBuf>` it
can only store one path per package. Currently if there are multiple paths,
all but the last will be inserted and then overwritten.
The key from this map is never used anyway, so this fixes the bug by changing
it from a HashMap to a HashSet.
Matt Brubeck [Thu, 2 Jun 2016 18:37:32 +0000 (11:37 -0700)]
Correctly record multiple native dirs per package
This fixes a bug when a package's build script outputs multiple library search
paths. Because Compilation::native_dirs is a `HashMap<PackageId, PathBuf>` it
can only store one path per package. Currently if there are multiple paths,
all but the last will be inserted and then overwritten.
The key from this map is never used anyway, so this fixes the bug by changing
it from a HashMap to a HashSet.