Alex Crichton [Sat, 16 Aug 2014 01:25:12 +0000 (18:25 -0700)]
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.
Alex Crichton [Sat, 16 Aug 2014 01:15:13 +0000 (18:15 -0700)]
Preserve $OUT_DIR across rebuilds
The original choice for completely destroying $OUT_DIR was to focus on
repeatable builds to ensure that stale items in $OUT_DIR don't affect later
compilations. This commit moves this responsibility from cargo to the build
command itself.
Build commands are now responsible for cleaning out old artifacts and ensuring
that when invoked the state of $OUT_DIR is as it would be if it started with an
empty $OUT_DIR. This will allow for very long build commands based on `make` to
have a much faster incremental build time as they won't have to rebuild
everything when updated.
This can cause non-repeatable builds with build commands if stale artifacts are
never removed (but still used in the rust compilation step), but this will now
be considered a bug in the build command rather than for cargo itself.
Alex Crichton [Sat, 16 Aug 2014 00:57:16 +0000 (17:57 -0700)]
Add an exclude key to the manifest
This key is used to help determine the set of input files for a package. The
normal method (via walking or git ls-files) is filtered via all the patterns
provided in `exclude` of the project section.
The toml key is a string array corresponding to a set of glob patterns according
to the syntax of libglob (provided in the standard distribution). The set of
files normally found will be filtered by each pattern, and if any pattern
matches then the path is excluded.
This will later on be used for `cargo package` when generating a tarball to get
uploaded.
Alex Crichton [Sat, 16 Aug 2014 00:40:08 +0000 (17:40 -0700)]
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.
bors [Tue, 19 Aug 2014 06:32:54 +0000 (06:32 +0000)]
auto merge of #401 : alexcrichton/cargo/issue-348, r=wycats
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.
Alex Crichton [Tue, 19 Aug 2014 04:38:04 +0000 (21:38 -0700)]
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.
bors [Tue, 19 Aug 2014 05:56:43 +0000 (05:56 +0000)]
auto merge of #389 : alexcrichton/cargo/dev-dependency-lockfile, r=wycats
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.
Alex Crichton [Sun, 17 Aug 2014 05:38:32 +0000 (22:38 -0700)]
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.
bors [Sat, 16 Aug 2014 23:18:45 +0000 (23:18 +0000)]
auto merge of #367 : alexcrichton/cargo/git2-rs, r=wycats
In general relying on external programs is dicey and tricky as they're very
different across systems in both how they're used as well as what versions
you'll find. Instead of binding to the least common denominator of CLI, we can
code against an exact version of libgit2.
This introduces a build-time dependency on cmake which libgit2 requires to build
itself, which is unfortunate, but thankfully it's only a build time dep. The
build process for libgit2 also automatically detects as many system libraries as
possible to use (if available), falling back to bundled versions if not
available. I have currently not figured how to control this, so the link-config
package is used to build libgit2 which requires that pkg-config be installed to
build cargo as well.
Alex Crichton [Wed, 6 Aug 2014 15:01:17 +0000 (08:01 -0700)]
Use libgit2 for driving git instead of the CLI
In general relying on external programs is dicey and tricky as they're very
different across systems in both how they're used as well as what versions
you'll find. Instead of binding to the least common denominator of CLI, we can
code against an exact version of libgit2.
This introduces a build-time dependency on cmake which libgit2 requires to build
itself, which is unfortunate, but thankfully it's only a build time dep. The
build process for libgit2 also automatically detects as many system libraries as
possible to use (if available), falling back to bundled versions if not
available. I have currently not figured how to control this, so the link-config
package is used to build libgit2 which requires that pkg-config be installed to
build cargo as well.
bors [Fri, 15 Aug 2014 04:28:57 +0000 (04:28 +0000)]
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).
bors [Fri, 15 Aug 2014 04:00:13 +0000 (04:00 +0000)]
auto merge of #307 : erickt/cargo/bench, r=wycats
This adds initial support for benchmarking at `--opt-level=3` for cargo. It's run just like `cargo-test`, and can actually run tests at the higher optimization level with `cargo bench -- --test`.
One question I had though is if we should include the `-Zlto` for link time optimizations. I'm not sure how well supported that is. What do you all think?
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.
Alex Crichton [Thu, 14 Aug 2014 06:02:08 +0000 (23:02 -0700)]
Start accepting [lib], allow `bin = []`
This commit starts to accept `[lib]` as a single library per package. It also
allows opting-out of binaries/tests/examples with a top level `foo = []` rather
than taking an empty array to mean that inference should be enabled.
bors [Tue, 12 Aug 2014 04:31:21 +0000 (04:31 +0000)]
auto merge of #363 : alexcrichton/cargo/fix-some-bugs, r=wycats
This also pulls in #316 to land everything at the same time. The major fix is "Fix updating git sources when a new lockfile is committed", and everything else was just issues that had accumulated over time. Once this has landed (may take some finesse), I'll make a new snapshot so cargo can actually start properly updating itself.
Alex Crichton [Mon, 11 Aug 2014 04:48:43 +0000 (21:48 -0700)]
Don't always print an error on test failures
Only print a failure if the command didn't have an exit status. Also, clarify
the failure message in the case that an exit was detected but it was not a
successful status.
Alex Crichton [Mon, 11 Aug 2014 04:27:17 +0000 (21:27 -0700)]
Disable doctests separately from tests
This adds a `doctest = false` option to the `Cargo.toml` config for a target to
disable doc tests for the target. Notably `test = false` does not disable this
as it is separately toggleable.
Alex Crichton [Thu, 7 Aug 2014 00:50:55 +0000 (17:50 -0700)]
Robustly run binaries and tests after compilation
These were previously just run by executing the raw binary, but this didn't
ensure that any of the necessary paths were in the dylib search path for the
host platform.
This commit enhances the return type of `compile_targets` to have information
about the result of compilation, along with the ability to spawn correctly
configured processes.
This primarily fixes `cargo test` and `cargo run` whenever dynamic dependencies
are involved, but it also fixes the two commands whenever there's a native
dynamic dependency involved as well.
bors [Wed, 6 Aug 2014 23:57:54 +0000 (23:57 +0000)]
auto merge of #302 : alexcrichton/cargo/doc-test, r=wycats
Whenever `cargo test` is run and a testable library target is available, the doc
tests will be run. This can be opted out of with `test = false` as usual.
This is currently not super useful due to rust-lang/rust#16157, but I expect
that to be merged soon. In the meantime examples will need to `extern crate foo`
explicitly.
bors [Wed, 6 Aug 2014 19:20:56 +0000 (19:20 +0000)]
auto merge of #328 : alexcrichton/cargo/cargo-building-cargo, r=wycats
Cargo should be able to build with cargo so others can depend on the cargo
library. This means that the one requirement of the CFG_VERSION env var will not
be available. This alters `version()` to prioritize CFG_VERSION but fall back to
the cargo-specified variables.
bors [Wed, 6 Aug 2014 18:58:18 +0000 (18:58 +0000)]
auto merge of #320 : alexcrichton/cargo/fix-doc-bins, r=wycats
This removes the check in the compilation phase, but adds an error if you're
documenting a library and a binary with the same name (as the rustdoc output
would conflict).
Alex Crichton [Wed, 6 Aug 2014 03:54:32 +0000 (20:54 -0700)]
Lift the requirement that cargo is built with make
Cargo should be able to build with cargo so others can depend on the cargo
library. This means that the one requirement of the CFG_VERSION env var will not
be available. This alters `version()` to prioritize CFG_VERSION but fall back to
the cargo-specified variables.
Alex Crichton [Fri, 1 Aug 2014 03:21:13 +0000 (20:21 -0700)]
Implement doc tests
Whenever `cargo test` is run and a testable library target is available, the doc
tests will be run. This can be opted out of with `test = false` as usual.
This is currently not super useful due to rust-lang/rust#16157, but I expect
that to be merged soon. In the meantime examples will need to `extern crate foo`
explicitly.
bors [Tue, 5 Aug 2014 14:44:33 +0000 (14:44 +0000)]
auto merge of #325 : dotdash/cargo/git_no_template, r=alexcrichton
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.
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.
Alex Crichton [Mon, 4 Aug 2014 14:21:31 +0000 (07:21 -0700)]
Allow documenting binary targets.
This removes the check in the compilation phase, but adds an error if you're
documenting a library and a binary with the same name (as the rustdoc output
would conflict).
bors [Mon, 4 Aug 2014 03:25:05 +0000 (03:25 +0000)]
auto merge of #314 : alexcrichton/cargo/hurray-for-windows, r=wycats
On windows, git will check out files with different line endings causing the
same serialized resolve to be resolved slightly differently. Instead of
comparing contents, this commit alters by testing whether the decoded resolve is
equivalent to the to-be-written resolve and only aborts writing if the two are
equal.
Alex Crichton [Mon, 4 Aug 2014 01:38:25 +0000 (18:38 -0700)]
Deal with different encodings of Cargo.lock
On windows, git will check out files with different line endings causing the
same serialized resolve to be resolved slightly differently. Instead of
comparing contents, this commit alters by testing whether the decoded resolve is
equivalent to the to-be-written resolve and only aborts writing if the two are
equal.