auto merge of #628 : alexcrichton/cargo/issue-537, r=brson
This is rebased on https://github.com/rust-lang/cargo/pull/617 as I wanted to use one of the functions added in the patch. Otherwise the details are in the commits.
Alex Crichton [Sat, 27 Sep 2014 04:24:31 +0000 (21:24 -0700)]
Deprecate `cargo update foo`
To maintain consistency with `cargo {build,test,bench,clean}` the `update`
subcommand now takes a specific package via the `-p` argument instead of as a
positional argument.
Alex Crichton [Wed, 24 Sep 2014 01:10:27 +0000 (18:10 -0700)]
Add cargo {test,bench} -p <spec>
This functionality allows running tests and benchmarks on any upstream
dependencies in the dependency graph. This is most useful for path sources all
developed in tandem (see Servo for instance).
In terms of built artifacts, this will actually preserve as many artifacts as
possible. That means that if you test a low-level dependency with the high-level
artifacts already built, the high-level artifacts will not get removed. This
means that it's possible to accidentally have a low-level dependency to depend
on a higher level one just because it's lib is picked up via -L, but this is
generally a necessary evil to get testing to not rebuild packages too often.
Alex Crichton [Tue, 23 Sep 2014 16:03:34 +0000 (09:03 -0700)]
Allow selectively cleaning packages
This adds a new argument to `cargo clean` which will enable selectively cleaning
particular packages. The command only cleans the package specified, no other
(not the dependencies of the package).
auto merge of #624 : alexcrichton/cargo/issue-484, r=wycats
This commit adds a flag, --precise, to cargo update. This flag is used to update
a dependency to precisely an exact revision (or branch) as part of an update
step. For git repositories the argument is some form of reference, while
registry packages this will be a version number.
The flag --precise forces a non-aggressive update and will fail if the
--aggresive flag is specified.
Alex Crichton [Tue, 23 Sep 2014 14:30:16 +0000 (07:30 -0700)]
Allow updating to a precise revision
This commit adds a flag, --precise, to cargo update. This flag is used to update
a dependency to precisely an exact revision (or branch) as part of an update
step. For git repositories the argument is some form of reference, while
registry packages this will be a version number.
The flag --precise forces a non-aggressive update and will fail if the
--aggresive flag is specified.
auto merge of #618 : alexcrichton/cargo/issue-593, r=wycats
This gives cargo a way to uniquely reference a package within a dependency graph. This is currently only used for `cargo update` and `cargo pkgid`, but this will extend in the future to possible configuration keys in the manifest, other commands like `clean`, etc.
auto merge of #614 : alexcrichton/cargo/issue-613, r=brson
As described in #613, this commit switches the semantics of `cargo update foo`
to updating *only* `foo`, not any of its dependencies. A new flag,
`--aggressive` was added to restore the old behavior.
The behavior of attempting to only unlock `foo`, and then if resolve fails
unlock all dependencies of `foo` is unimplemented as it's not super relevant
right now when the majority of dependencies are git dependencies and resolution
cannot fail for version-related reasons.
Alex Crichton [Sun, 21 Sep 2014 21:27:30 +0000 (14:27 -0700)]
Make `cargo update` more conservative.
As described in #613, this commit switches the semantics of `cargo update foo`
to updating *only* `foo`, not any of its dependencies. A new flag,
`--aggressive` was added to restore the old behavior.
The behavior of attempting to only unlock `foo`, and then if resolve fails
unlock all dependencies of `foo` is unimplemented as it's not super relevant
right now when the majority of dependencies are git dependencies and resolution
cannot fail for version-related reasons.
auto merge of #612 : alexcrichton/cargo/nocapture, r=wycats
There are some competing concerns when it comes to the output of compiling
dependencies:
* Not capturing anything leads to getting drowned in unrelated output
* Capturing requires coloration be compromised because of the way windows
terminal colors are implemented.
* Path dependencies are often developed in tandem with the rest of a package,
and capturing their output is not always desired.
To address these concerns, cargo previously captured output of dependent
compilations and then re-printed it to the screen if an error occurred. This
patch modifies the behavior to as follows:
* No output is captured. This preserves any coloration rustc provides.
* All dependencies are compiled with `-Awarnings`. This should suppress any
extraneous output from the compiler and it is considered a bug otherwise if
the compiler prints a warnings when `-Awarnings` is specified.
* All *path* dependencies (`path="..."`, overrides, etc) are *not* compiled with
`-Awarnings`. The reason for this is that you are always in control of these
packages and probably want to see warnings anyway.
Alex Crichton [Sun, 21 Sep 2014 17:22:46 +0000 (10:22 -0700)]
Stop capturing output of all dependencies
There are some competing concerns when it comes to the output of compiling
dependencies:
* Not capturing anything leads to getting drowned in unrelated output
* Capturing requires coloration be compromised because of the way windows
terminal colors are implemented.
* Path dependencies are often developed in tandem with the rest of a package,
and capturing their output is not always desired.
To address these concerns, cargo previously captured output of dependent
compilations and then re-printed it to the screen if an error occurred. This
patch modifies the behavior to as follows:
* No output is captured. This preserves any coloration rustc provides.
* All dependencies are compiled with `-Awarnings`. This should suppress any
extraneous output from the compiler and it is considered a bug otherwise if
the compiler prints a warnings when `-Awarnings` is specified.
* All *path* dependencies (`path="..."`, overrides, etc) are *not* compiled with
`-Awarnings`. The reason for this is that you are always in control of these
packages and probably want to see warnings anyway.
auto merge of #604 : klutzy/cargo/win-make-install, r=alexcrichton
Since `Makefile` passes `--destdir="$$(DESTDIR)/"` to `install.sh`,
`make install` tries to install libraries to
`$CFG_DESTDIR$CFG_PREFIX/$CFG_LIBDIR_RELATIVE` which is usually
`//path/to/usr/$CFG_LIBDIR_RELATIVE`.
The POSIX spec [1] states that if path begins with `//` it is
implementation-defined.
Usual systems treat them as normal abaolute path, but cygwin and MSYS
does not! They use `//hostname/path` syntax for network drives.
This caused `make install` issue on Windows.
This patch removes `/` of destdir to solve the issue.
Since `Makefile` passes `--destdir="$$(DESTDIR)/"` to `install.sh`,
`make install` tries to install libraries to
`$CFG_DESTDIR$CFG_PREFIX/$CFG_LIBDIR_RELATIVE` which is usually
`//path/to/usr/$CFG_LIBDIR_RELATIVE`.
The POSIX spec [1] states that if path begins with `//` it is
implementation-defined.
Usual systems treat them as normal abaolute path, but cygwin and MSYS
does not! They use `//hostname/path` syntax for network drives.
This caused `make install` issue on Windows.
This patch removes `/` of destdir to solve the issue.
auto merge of #596 : alexcrichton/cargo/update-git2, r=brson
This brings in a commit which enables global template options by default as part
of initializing new git repositories, allowing a templates to be used as part of
`cargo new`.
auto merge of #599 : epdtry/cargo/profile-codegen-units, r=alexcrichton
If the profile sets `codegen-units`, the value will be passed to `rustc`'s `-C codegen-units` option. If no value is set, then no argument will be passed, so `rustc` will use its default settings.
Alex Crichton [Thu, 18 Sep 2014 15:51:00 +0000 (08:51 -0700)]
Update git2-rs
This brings in a commit which enables global template options by default as part
of initializing new git repositories, allowing a templates to be used as part of
`cargo new`.
auto merge of #586 : alexcrichton/cargo/fix-win64, r=brson
Right now the win64 snapshot builders are failing to produce a snapshot, and
I've managed to track it down to a path length issue. Windows paths have a
maximum of 260 characters, and the characters add up pretty fast for a path
like:
The normal builders aren't failing I presume because `cargo-nightly-win-64` is
longer than `cargo-win64-64` (we must be *right up* against the limit). I've
confirmed that this shortening fixes the tests on the bots.
Alex Crichton [Wed, 17 Sep 2014 15:30:35 +0000 (08:30 -0700)]
Shorten the cargo integration test directory name
Right now the win64 snapshot builders are failing to produce a snapshot, and
I've managed to track it down to a path length issue. Windows paths have a
maximum of 260 characters, and the characters add up pretty fast for a path
like:
The normal builders aren't failing I presume because `cargo-nightly-win-64` is
longer than `cargo-win64-64` (we must be *right up* against the limit). I've
confirmed that this shortening fixes the tests on the bots.
auto merge of #570 : alexcrichton/cargo/fetch, r=brson
This command is used to download all dependencies of a package ahead of time to
ensure that no more network communication will be necessary as part of a build.
Alex Crichton [Thu, 11 Sep 2014 18:50:57 +0000 (11:50 -0700)]
Implement a `cargo fetch` command
This command is used to download all dependencies of a package ahead of time to
ensure that no more network communication will be necessary as part of a build.
auto merge of #541 : alexcrichton/cargo/cargo-upload, r=brson
This PR implements the plumbing necessary for uploading packages to a registry, downloading packages, depending on those packages, etc. All APIs (upload/download) are tied to the current implementation of [the registry](https://github.com/alexcrichton/cargo-registry).
Most of the design-level details in this PR are in the first commit. The later commits are largely adding tests, polishing it off, and making it work on windows.
Dependency-wise, this picks up a dependency on `curl-rust`, albeit a small fork until the upstream linkage changes are merged. Linkage details can be found [here](https://github.com/carllerche/curl-rust/pull/16). I'll probably have to do some configuration of the bots to get this to work (or hopefully not!).
Alex Crichton [Fri, 18 Jul 2014 15:40:45 +0000 (08:40 -0700)]
Implement a registry source
# cargo upload
The cargo-upload command will take the local package and upload it to the
specified registry. The local package is uploaded as a tarball compressed with
gzip under maximum compression. Most of this is done by just delegating to
`cargo package` The host to upload to is specified, in order of priority, by a
command line `--host` flag, the `registry.host` config key, and then the default
registry. The default registry is still `example.com`
The registry itself is still a work in progress, but the general plumbing for a
command such as this would look like:
1. Ensure the local package has been compressed into an archive.
2. Fetch the relevant registry and login token from config files.
3. Ensure all dependencies for a package are listed as coming from the same
registry.
4. Upload the archive to the registry with the login token.
5. The registry will verify the package is under 2MB (configurable).
6. The registry will upload the archive to S3, calculating a checksum in the
process.
7. The registry will add an entry to the registry's index (a git repository).
The entry will include the name of the package, the version uploaded, the
checksum of the upload, and then the list of dependencies (name/version req)
8. The local `cargo upload` command will succeed.
# cargo login
Uploading requires a token from the api server, and this token follows the same
config chain for the host except that there is no fallback. To implement login,
the `cargo login` command is used. With 0 arguments, the command will request
that a site be visited for a login token, and with an argument it will set the
argument as the new login token.
The `util::config` module was modified to allow writing configuration as well as
reading it. The support is a little lacking in that comments are blown away, but
the support is there at least.
# RegistrySource
An implementation of `RegistrySource` has been created (deleting the old
`DummyRegistrySource`). This implementation only needs a URL to be constructed,
and it is assumed that the URL is running an instance of the cargo registry.
## RegistrySource::update
Currently this will unconditionally update the registry's index (a git
repository). Tuning is necessary to prevent updating the index each time (more
coming soon).
## RegistrySource::query
This is called in the resolve phase of cargo. This function is given a
dependency to query for, and the source will simply look into the index to see
if any package with the name is present. If found, the package's index file will
be loaded and parsed into a list of summaries.
The main optimization of this function is to not require the entire registry to
ever be resident in memory. Instead, only necessary packages are loaded into
memory and parsed.
## RegistrySource::download
This is also called during the resolve phase of cargo, but only when a package
has been selected to be built (actually resolved). This phase of the source will
actually download and unpack the tarball for the package.
Currently a configuration file is located in the root of a registry's index
describing the root url to download packages from.
This function is optimized for two different metrics:
1. If a tarball is downloaded, it is not downloaded again. It is assumed that
once a tarball is successfully downloaded it will never change.
2. If the unpacking destination has a `.cargo-ok` file, it is assumed that the
unpacking has already occurred and does not need to happen again.
With these in place, a rebuild should take almost no time at all.
## RegistrySource::get
This function is simply implemented in terms of a PathSource's `get` function by
creating a `PathSource` for all unpacked tarballs as part of the `download`
stage.
## Filesystem layout
There are a few new directories as part of the `.cargo` home folder:
* `.cargo/registry/index/$hostname-$hash` - This is the directory containing the
actual index of the registry. `$hostname` comes from its url, and `$hash` is
the hash of the entire url.
* `.cargo/registry/cache/$hostname-$hash/$pkg-$vers.tar.gz` - This is a
directory used to cache the downloads of packages from the registry.
* `.cargo/registry/src/$hostname-$hash/$pkg-$vers` - This is the location of the
unpacked packages. They will be compiled from this location.
# New Dependencies
Cargo has picked up a new dependency on the `curl-rust` package in order to send
HTTP requests to the registry as well as send HTTP requests to download
tarballs.
Alex Crichton [Fri, 12 Sep 2014 15:02:14 +0000 (08:02 -0700)]
Rewrite git tests to not rely on the CLI
The CLI has started to have differences on windows than on other systems, and
instead of coding against multiple CLI versions, instead just rewrite everything
to use libgit2.