Commit graph

65 commits

Author SHA1 Message Date
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
Alex Crichton 22dfc52083 Deprecated [[lib]] in favor of [lib] 2014-08-13 23:10:16 -07:00
Alex Crichton 9feca9d922 Fix updating git sources a new lockfile is committed
This is the actual fix for #345
2014-08-10 20:50:33 -07:00
Alex Crichton b83e939819 Fix --extern for doc tests for the local crate.
Closes #340
2014-08-07 08:29:32 -07:00
Alex Crichton 2b58d83a49 Don't match the output of the submodule test
Apparently really old versions of git ignore --quiet and print things anyway,
causing the test to fail on the linux buildbot.
2014-08-06 18:46:26 -07:00
Alex Crichton f51a2f9234 Remove the update_remotes flag entirely
This will inadvertently fix #337 as no lockfile will imply that all dependencies
are not precise, and will hence be fetched.
2014-08-06 17:09:24 -07:00
Alex Crichton e219167738 Remove Location, use Url everywhere
Now that rust-url supports windows paths in URLs, this commit jettisons the
janky Location enum in favor of just using Url everywhere.
2014-08-06 17:09:24 -07:00
Alex Crichton 4d42cbd716 Fix submodules on the initial checkout
The fast path bypassed updating the submodule which wasn't correct if we were
the first checkout.
2014-08-05 22:26:38 -07:00
Björn Steinbrink dd0df64031 Fix running tests using git on systems with customized git templates
I customized my git repo template to default to the standard pre-commit
hook that checks for e.g. trailing whitespace and refuses to commit if
any trailing whitespace was found. This causes some of cargo's tests to
fail.

To be independent of the user's git template, create the repo for the
test without using any, by specifying an empty template.
2014-08-05 12:27:51 +02:00
Alex Crichton bfc1519490 Make freshness tests more robust with time travel
Add a helper function to forcibly move a tree back one hour so new edits are
picked up correctly.
2014-08-02 10:55:02 -07:00
Alex Crichton b7849f5457 Ensure update updates all shared deps 2014-08-01 10:39:11 -07:00
Alex Crichton 620b2fe1b5 Implement cargo-update 2014-07-31 15:39:52 -07:00
Alex Crichton 1a35097a9a Use sources from the lockfile
The sources in the lock file contain precise information about git deps so we
want them over the non-precise versions in the source.
2014-07-31 12:18:49 -07:00
Alex Crichton 3b77b2c763 Fix all tests and rebase conflicts
This rebases the lockfile branch to master and updates all code necessary to get
the tests passing again.
2014-07-31 10:16:03 -07:00
Alex Crichton f664874281 Migrate from liburl to rust-url
The standard url library is soon-to-be deprecated, and now that we're
bootstrapping it's trivial to move over to rust-url.

Closes #204
2014-07-30 09:55:48 -07:00
Alex Crichton 73947e5c3b Base get_fingerprint on a PackageId
The fingerprinting code was erroneously using all sources from a manifest when
calculating the fingerprint which meant that sources not yet downloaded were
attempted to be fingerprinted.

The correct source to fingerprint is located in the SourceId field of the
resolved PackageId.

Closes #259
2014-07-24 19:32:49 -07:00
Alex Crichton 5dc5381fcc Use a hash for -C metadata instead of a string
This ends up serving the same purpose, but a critical change is that it
canonicalizes the relevant git url (if one is used) to ensure that the same
package from two slightly different locations is always built the same way.

Sadly I'm not quite sure how to add a test for this as it involves using remote
git urls which are unusable during tests.
2014-07-22 10:06:36 -07:00
Alex Crichton b30892fc01 Use Path::display().to_string() less often
Unfortunately this cannot yet have a test for it as rustc itself does not work
if it is run on non-utf8 paths.
2014-07-21 19:34:17 -07:00
Alex Crichton 835e5ac1ac Fix inferred name of src/main.rs
The crate name should be the package name, not `main`.

Closes #207
2014-07-16 18:44:30 -07:00
Alex Crichton 3608fd4892 Update toml-rs
TOML recently grew multiline string literals as well as literal strings with no
escaping, which can be used instead of the hokey escape_path() function.
2014-07-16 08:08:55 -07:00
Alex Crichton f6d22b64b9 Use PackageId in the DependencyQueue
This allows the dependency queue to properly handle packages with the same
name but from different sources.

A test was added which exercieses this functionality by depending on two
different revs of the same git repo.
2014-07-11 14:20:24 -07:00
Yehuda Katz + Carl Lerche 59bc9adb29 Refactor PackageId.namespace -> source_id 2014-07-08 14:58:56 -07:00
Yehuda Katz + Carl Lerche a1980dc78b Add --release and related refactoring 2014-07-07 15:17:34 -07:00
Yehuda Katz ea3cb31cec Meta-packages 2014-06-30 18:36:27 -07:00
Arcterus 856f37091c Error out on ssh dependencies (fixes #55) 2014-06-26 21:41:06 -07:00