Commit graph

89 commits

Author SHA1 Message Date
Alex Crichton ed58e0bea9 Improve errors for invalid manifests
Print out the path to the manifest in question whenever a parsing error is
encountered.
2015-01-13 18:51:24 -08:00
Alex Crichton 553211119b Update to rust master 2015-01-13 14:11:20 -08:00
Alex Crichton 9ed3a6ea1d Clean up Cargo's util::errors module
This commit cleans up cargo's error module to reduce the duplication of
`CargoError` and the standard library's `Error` trait. The `CargoError` trait
remains, but only has one methods, `is_human`.

A number of other modifications were made:

* ChainError was altered to work over unboxed closures
* Wrap and Require were removed as they're duplicates of the ChainError
  functionality.
* Many public error types are now private from util::errors as they're only
  returned as boxed trait objects.
* The `concrete` was removed, all calls to `make_human` are now done through a
  newtype `Human` wrapper.
* Cargo's custom `try!` macro was removed.
2014-12-29 18:59:15 -08:00
Alex Crichton aa256ffddc Refactor git rev handling infrastructure
This commit unifies the notion of a "git revision" between a SourceId and the
GitSource. This pushes the request of a branch, tag, or revision all the way
down into a GitSource so special care can be taken for each case.

This primarily was discovered by #1069 where a git tag's id is different from
the commit that it points at, and we need to push the knowledge of whether it's
a tag or not all the way down to the point where we resolve what revision we
want (and perform appropriate operations to find the commit we want).

Closes #1069
2014-12-29 16:00:18 -08:00
Alex Crichton 157d639afc Update rust and all deps 2014-12-19 20:55:17 -08:00
Alex Crichton 673d318021 Bump libgit2 dep to hopefully fix win32 2014-12-08 11:14:09 -08:00
Cody P Schafer 631210790d Update for nightly
I'm a bit shaky on the profile.rs changes (`thread_local!` and `RefCell`
relplacing `local_data_key!`), do make sure I haven't royally screwed
something up there.

Note that I haven't sucessfully run the various test_cargo_cross_compile
tests as I don't have an i686-unknown-linux-gnu rustc sitting around.
2014-12-03 02:25:18 -05:00
Alex Crichton 2ba5c5ec45 Test source equality when locking dependencies
When applying the lockfile to a resolve graph, we need to take into account that
the listed source of dependencies can change over time, in which case we cannot
lock to the previous version but instead need to continue onwards with updating
the listed source.

Closes #951
2014-11-23 17:46:04 -08:00
Jakub Bukaj df9cf06663 Update to newest Rust 2014-11-23 17:02:45 -05:00
Alex Crichton 2833358294 Fix some flaky tests 2014-11-05 11:37:34 -08:00
Alex Crichton ce14ff2f77 Be sure to update all packages from a git source
With the recent resolve rewrite, `cargo update -p foo` would only update one
package in a git repository, even if the repository provided many packages.
Cargo does not currently support depending on the same git repository source
with different precise revisions, and this would cause errors down the line
depending on what happened.

This adds a fix to the `resolve_with_previous` method to ensure that any
non-registry sources being updated will not have any locked packages inside them
which would result in an invalid lockfile.
2014-10-29 11:50:24 -07:00
Alex Crichton 6ab9311754 Fix a flaky test relying on nondeterminsm
When updating a source with multiple packages, the registry will lazily discover
both the precise and imprecise versions of the source at some point. Previously
the source would be updated depending on which was discovered first, but this
commit adds logic to understand that if an imprecise version is discovered after
a precise version then the imprecise version should be favored (because it will
always trigger an update).

This needs to understand, however, that if `cargo update --precise` is used that
those sources should not be updated again, so the sources treated in
`add_sources` are considered "special" in the sense that they're locked and will
not be updated again.
2014-10-27 12:40:23 -07:00
Alex Crichton ebd3c1da77 Remove the hokey add_lockfile_sources
This method shouldn't be necessary as it should be possible to simply add all
sources known in the lockfile to a package registry, and
core::{resolve, registry} should take care of weeding them out if necessary.

In the process of doing so, this actually ends up fixing a problem with
rewriting a dependency to a new one which shares transitive deps. Previously all
the transitive deps were updated, but now the transitive deps remain locked at
where they were previously locked.
2014-10-27 12:40:23 -07:00
Alex Crichton c2e9996011 Fix updating sources with more than one crate
When a source has multiple crates inside of it, `cargo update -p foo` would
previously not actually update anything because the extra crates were continuing
to lock the source to the same revision. This change updates the "avoid me"
logic to avoid *sources*, not *packages*.

Closes #697
2014-10-13 09:54:08 -07:00
Alex Crichton 78bd836023 Update to rust master 2014-10-10 08:03:45 -07:00
Alex Crichton 1ef09734ed Refine dependencies on dev-deps
Currently whenever a dev-dep is brought in to the build process the entire
library is rebuilt, but this is just unnecessary recompilation because the
library *can't* depend on the dev-dep.

This commit refines the dependency graph so the lib stage only depends on
transitive dependencies (non-dev-deps), and a new stage for tests was added
which depends on the packages libraries *and* the dev-deps. This way only the
test are rebuilt when dev-deps change, not libraries.
2014-10-02 18:38:15 -07:00
Alex Crichton 37dbfd2ec6 Improve the error message for ambiguous specs 2014-09-29 16:55:45 -07:00
Alex Crichton 217ff7fb93 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.
2014-09-29 16:54:45 -07:00
Alex Crichton f97cef0c30 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.

Closes #483
2014-09-29 16:54:45 -07:00
Alex Crichton 325c5f2def 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).

cc #537
2014-09-29 16:54:24 -07:00
Alex Crichton c098a9a7a9 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.

Closes #484
2014-09-25 08:51:45 -07:00
bors 262c794949 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.

Closes #613
2014-09-22 20:58:34 +00:00
Alex Crichton d1a332d19a 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.

Closes #613
2014-09-21 14:27:30 -07:00
Alex Crichton 541a535f71 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.

Closes #490
Closes #496
2014-09-21 14:06:58 -07:00
Alex Crichton dfae53c406 Fix some more deprecation warnings 2014-09-17 08:27:41 -07:00
Alex Crichton 2dff1ed610 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.

cc #358
2014-09-16 15:59:39 -07:00
Alex Crichton 2d994b93a4 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.
2014-09-15 09:43:54 -07:00
Alex Crichton a09ad635cc Update to rust master 2014-09-15 08:31:21 -07:00
Matt Brubeck 2e0ba67704 Try to fix intermittent test failures
Travis is showing intermittent failures in
`test_cargo_compile_path_deps::path_dep_build_cmd` and
`test_cargo_compile_git_deps::git_dep_build_cmd` (added in #561 and #563).

I haven't managed to reproduce these failures locally, but I suspect the tests
are timing-sensitive.  This tries to guarantee that the timestamps during the
two operations can't be the same.
2014-09-13 08:27:15 -07:00
bors 287abd87d2 auto merge of #563 : mbrubeck/cargo/list-files-git, r=alexcrichton
`list_files_git` assumes that the package is at the root of the git repository. This breaks when trying to list files for a package in a subdirectory of a repo, or in other cases, e.g. if the user's home directory is a git repo.
2014-09-13 02:43:50 +00:00
Matt Brubeck b4adda4d15 Test for build commands in git subdirs 2014-09-12 15:30:43 -07:00
Alex Crichton 6742dde83b Don't clone remote repos, use fetch instead
When cloning a remote repository, the default behavior of libgit2 is to only
update the local ref that's actually checked out, when we actually would prefer
to update all refs of the remote repo. This removes a call to clone() to a
init_bare() + fetch() which should update all refs accordingly

Closes #565
2014-09-11 19:05:14 -07:00
bors 96d07d9aaf auto merge of #549 : alexcrichton/cargo/git-no-delete, r=brson
This primarily blows away all *submodules* as well, which sometimes can be quite
large and take some time to update. Instead, re-use an existing checkout, just
reset it to the right revision if possible.

Also, move the submodule update step to occur unconditionally to account for
corrupt submodule checkouts or interrupted downloads. This update step should be
much faster than `git submodule update` because we're using libgit2, so yay!
2014-09-10 18:27:54 +00:00
Alex Crichton 78acc73989 Don't blow away checked out git repos
This primarily blows away all *submodules* as well, which sometimes can be quite
large and take some time to update. Instead, re-use an existing checkout, just
reset it to the right revision if possible.

Also, move the submodule update step to occur unconditionally to account for
corrupt submodule checkouts or interrupted downloads. This update step should be
much faster than `git submodule update` because we're using libgit2, so yay!
2014-09-10 07:47:11 -07:00
Alex Crichton c0127391bf Don't recompile git deps so frequently
The previous logic for recompiling any dependency was almost entirely based on
the mtimes of the relevant input files. This isn't quite what's desired for git
and registry dependencies because the mtime could be fluctuating while the files
aren't changing. For example:

1. Project A checks out git repo C at revision C1
2. Project A builds, records mtimes of C
3. Project B checks out git repo C at revision C2
4. Project B builds, records new mtimes of C
5. Project A is rebuilt, rebuilding C b/c mtimes are different

In step 5 here C should not be rebuilt because the revision didn't actually
change.

This commit alters git/registry dependencies to completely bypass the --dep-info
emitted and only rely on the git/registry source to inform what the fingerprint
is. This is the revision/version, respectively, and should be all that's
necessary to track changes to the repo and trigger a rebuild.
2014-09-10 07:26:42 -07:00
Alex Crichton 4a70a7a111 Don't show Fresh by default
But still show it with --verbose

Closes #473
2014-09-05 10:16:21 -07:00
Alex Crichton 20e37c6a81 Update the git2 dependency
It turned out most of the methods in libgit2 don't actually require a Signature
structure, they're all mostly optional. This commit updates to this version of
libgit2 where the arguments are all optional.
2014-08-28 11:15:49 -07:00
Alex Crichton d5cb12cad2 Roll back git2 a bit to fix tests 2014-08-26 22:33:06 -07:00
Alex Crichton 8cce8996be Remove all subcommand executables
This commit removes all distributed executables except for `cargo`. All
builtin subcommands are implemented through library calls, and the fallback
methods are retained to maintain extensability through new subcommands.

Closes #393
2014-08-26 18:25:28 -07:00
Tim Carey-Smith 2c12269e20 Syncs submodules after remote update (closes #370)
Previously, the Git code avoided cloning a local copy of the local
database for a repository if the repo already existed (and instead tried
to fetch). However, fetching does not sync and reinitialize submodules,
which would require more work.

To avoid this problem, and possibly other subtle updating issues in the
future, the code now wipes the local clone whenever it detects that the
HEAD of a particular branch has changed. This avoids subtle
inconsistencies between fresh clones and updates.

Note: This only affects local-to-local clones. It does not initiate any
new network activity. It may require some additional disk usage, but
only when a remote fetch that was already happening discovers new
commits on the checked-out branch.
2014-08-19 09:10:15 -07:00
Alex Crichton fff5de375a Make a timing test a little less flaky 2014-08-18 23:47:57 -07:00
Alex Crichton ae1962d759 Allow updating transitive deps
Previously `cargo update foo` would only update the package `foo` if it were a
direct dependency of the local package. This meant that to update a transitive
dependency you would have to update the top-level dependency.

This commit adds the ability to update any dependency by name, regardless of
where it is in the dependency graph. This commit is a bit lossy in terms of
behavior. We are guaranteed that the set of immediate dependencies for any one
package have unique names, but not for the entire package graph. This means that
when you invoke `cargo update foo` it could possibly update two packages named
`foo`.

I believe this behavior to be acceptable for now and we can add a more stringent
update syntax later (something like `cargo update --namespace foo bar`). I
believe we'll always want this CLI usage, however.
2014-08-18 23:43:27 -07:00
Alex Crichton 8a19eb7437 Factor in .gitignore for build cmd freshness
When testing the freshness of a build command, the fingerprint of an entire
package is generated. The current method of fingerprinting a path source is to
just stat() the entire tree and look at mtimes. This works fine when the build
command places *all* output in the build directory.

Some systems, like autotools, place *most* output in the build directory and
some output in the source directory, however (see spidermonkey). In this case
the coarse-grained "consider all files in a directory as input" is too painful
for the build command as the package will forever be rebuilt.

This commit adds support for filtering the list of files in a directory
considered to be part of a package by using `git ls-files`. This git-specific
logic can be extended to other VCSs when cargo grows support for them.

Closes #379
2014-08-18 23:43:27 -07:00
Alex Crichton 37538a13ac Don't build docs/tests into separate dirs
This commit changes the hash of Profile to only take into account
flags/variables that affect the actual output file itself (as opposed to its
location), and then changes cargo {test, build, doc} to all use the same
directory of output (in order to share deps).

This will cause a `cargo build` to remove all of the tests generated by `cargo
test`, but it speeds up the cycle of `cargo test` followed by a `cargo build` by
not needing to rebuild all dependencies.

Additionally, `cargo bench` now shares the same directory as
`cargo build --release` for the same reasons as above.

Closes #348
2014-08-18 23:16:13 -07:00
Alex Crichton 8626fa725d Always generate a lockfile with dev-dependencies
Previously an invocation of `cargo build` would generate a lockfile *without*
dev dependencies, but an invocation of `cargo test` would generate a lockfile
*with* dependencies. This causes odd problems and diffs with the lockfile.

This commit switches the resolve-to-be-a-lockfile to using all dependencies of a
package, while the resolve-to-be-compiled continues to use just the dependencies
needed for the current build.
2014-08-16 22:38:32 -07:00
Alex Crichton 51de050e6c If --target is specified, pass that to build commands
0c834d7b accidentally broke this by favoring rustc's target triple over the
actual target triple.
2014-08-16 22:17:55 -07:00
Alex Crichton e090e2ad78 Run cargo off the main thread.
On windows the main thread suffers the same fate as rustdoc (as linked in the
comments), and hence needs to run off the main thread for now.
2014-08-16 16:16:32 -07:00
Alex Crichton 793134c2c4 Add submodule test from #381 2014-08-16 15:54:07 -07:00
bors 002bf7d080 auto merge of #369 : alexcrichton/cargo/issue-327, r=wycats
The syntax was originally chosen to perhaps allow multiple libraries in the future, but that is less and less likely to happen at this point. This commit deprecates the now-misleading `[[lib]]` in favor of `[lib]` to indicate that only one can be present.

This does not start allowing `[bin]` or `[example]` and such as I felt that it was too many ways to specify what's essentially the same thing. This also as a bonus allows a top-level `bin = []` to completely opt-out of binary inference (as well as for tests and examples).

Closes #327
2014-08-15 04:28:57 +00:00
Yehuda Katz + Carl Lerche abe2686caf Fix issues related to git updates
We observed that after updating the git repo in a test, unless we waited
for 1s, we got intermittent cases where a subsequent update of the git
source would not pick up the changes.

We observed this both with the git CLI and the branch using libgit2.
There may be a better solution, but we did not find it.
2014-08-14 17:05:01 -07:00