Commit graph

92 commits

Author SHA1 Message Date
Alex Crichton c54fc00626 Remove ndebug, add config of debug assertions
This commit removes the ndebug support from Cargo and also adds a new
configuration option for profiles, `debug-assertions`, which controls whether
debug assertions in the compiler are turned on or not.

Closes #1398
2015-03-24 10:54:41 -07:00
bors c6b93247c6 Auto merge of #1441 - alexcrichton:issue-1323, r=bson
This commit is a complete overhaul of how Cargo handles compilation profiles
internally. The external interface of Cargo is not affected by this change.

Previously each Target had a Profile embedded within it. Conceptually a Target
is an entry in the manifest (a binary, benchmark, etc) and a Profile controlled
various flags (e.g. --test, -C opt-level, etc). Each Package then contained many
profiles for each possible compilation mode. For example a Package would have
one target for testing a library, benchmarking a library, documenting a library,
etc. When it came to building these targets, Cargo would filter out the targets
listed to determine what needed to be built.

This filtering was largely done based off an "environment" represented as a
string. Each mode of compilation got a separate environment string like `"test"`
or `"bench"`. Altogether, however, this approach had a number of drawbacks:

* Examples in release mode do not currently work. This is due to how examples
  are classified and how release mode is handled (e.g. the "release" environment
  where examples are meant to be built in the "test" environment).
* It is not trivial to implement `cargo test --release` today.
* It is not trivial to implement `cargo build --bin foo` where *only* the binary
  `foo` is built. The same is true for examples.
* It is not trivial to add selective building of a number of
  binaries/examples/etc.
* Filtering the list of targets to build has some pretty hokey logic that
  involves pseudo-environments like "doc-all" vs "doc". This logic is duplicated
  in a few places and in general is quite brittle.
* The TOML parser greatly affects compilation due to the time at which profiles
  are generated, which seems somewhat backwards.
* Profiles must be overridden, but only partially, at compile time becuase only
  the top-level package's profile is applied.

In general, this system just needed an overhaul. This commit made a single
change of separating `Profile` from `Target` and then basically hit `make` until
all the tests passed again. The other large architectural changes are:

* Environment strings are now entirely gone.
* Filters are implemented in a much more robust fashion.
* Release mode is now handled much more gracefully.
* The unit of compilation in the backend is no longer (package, target) but
  rather (package, target, profile). This change had to be propagated many
  location in the `cargo_rustc` module.
* The backend does not filter targets to build *at all*. All filtering now
  happens entirely in the frontend.

I'll test issues after this change lands, but the motivation behind this is to
open the door to quickly fixing a number of outstanding issues against Cargo.
This change itself is not intended to close many bugs.
2015-03-24 00:15:20 +00:00
Tamir Duberstein 1ced1dc8dd Update to rust 2015-03-22 2015-03-23 13:59:59 -07:00
Alex Crichton 7d1419db19 Update tests for tweaked error messages 2015-03-20 20:23:53 -07:00
Alex Crichton c18158b812 Update error message for missing examples 2015-03-20 19:33:12 -07:00
Alex Crichton 8989d8272d Fix test for bins/examples
Binaries are no longer always built when examples are built, so update the test
accordingly.
2015-03-20 19:31:12 -07:00
Alex Crichton a54d240a1e Fix a subtesting test
Libraries are no longer built if they aren't doctested, so something else needed
to be present to trigger the library being built.
2015-03-20 18:53:00 -07:00
Alex Crichton 1a452fb151 Fix test for --test filtering
The flag now only applies to integration tests, not all targets with the
specified name.
2015-03-20 17:48:55 -07:00
Alex Crichton 26cf00490a Fix cargo test filtering for binaries
This adds a new `--bin` flag to `cargo test` to specifically say that a binary
should be tested. Additionally the dependencies are tweaked such that binaries
to not depend on themselves being available.
2015-03-20 17:48:17 -07:00
Alex Crichton 9e77919855 Overhaul how cargo treats profiles
This commit is a complete overhaul of how Cargo handles compilation profiles
internally. The external interface of Cargo is not affected by this change.

Previously each Target had a Profile embedded within it. Conceptually a Target
is an entry in the manifest (a binary, benchmark, etc) and a Profile controlled
various flags (e.g. --test, -C opt-level, etc). Each Package then contained many
profiles for each possible compilation mode. For example a Package would have
one target for testing a library, benchmarking a library, documenting a library,
etc. When it came to building these targets, Cargo would filter out the targets
listed to determine what needed to be built.

This filtering was largely done based off an "environment" represented as a
string. Each mode of compilation got a separate environment string like `"test"`
or `"bench"`. Altogether, however, this approach had a number of drawbacks:

* Examples in release mode do not currently work. This is due to how examples
  are classified and how release mode is handled (e.g. the "release" environment
  where examples are meant to be built in the "test" environment).
* It is not trivial to implement `cargo test --release` today.
* It is not trivial to implement `cargo build --bin foo` where *only* the binary
  `foo` is built. The same is true for examples.
* It is not trivial to add selective building of a number of
  binaries/examples/etc.
* Filtering the list of targets to build has some pretty hokey logic that
  involves pseudo-environments like "doc-all" vs "doc". This logic is duplicated
  in a few places and in general is quite brittle.
* The TOML parser greatly affects compilation due to the time at which profiles
  are generated, which seems somewhat backwards.
* Profiles must be overridden, but only partially, at compile time becuase only
  the top-level package's profile is applied.

In general, this system just needed an overhaul. This commit made a single
change of separating `Profile` from `Target` and then basically hit `make` until
all the tests passed again. The other large architectural changes are:

* Environment strings are now entirely gone.
* Filters are implemented in a much more robust fashion.
* Release mode is now handled much more gracefully.
* The unit of compilation in the backend is no longer (package, target) but
  rather (package, target, profile). This change had to be propagated many
  location in the `cargo_rustc` module.
* The backend does not filter targets to build *at all*. All filtering now
  happens entirely in the frontend.

I'll test issues after this change lands, but the motivation behind this is to
open the door to quickly fixing a number of outstanding issues against Cargo.
This change itself is not intended to close many bugs.
2015-03-20 17:20:37 -07:00
Alex Crichton 14ff482dda Change the default output location to target/debug
This commit now funnels all output of Cargo by default to be in `target/debug`
instead of the bare `target` directory. This change is targeted at raising
awareness of whether a debug build is being used (as opposed to a release
build). It is also aimed at remedying a common scenario where `cargo build` is
followed by `cargo build --release` and then the debug binaries are run by
accident.

This does not yet explore the option of providing symlinks to the most recent
build, hence this commit is a breaking change due to the restructuring of the
layout of the output.

Note that this commit does **not** change the output location for documentation.
All output of `cargo doc` continues to be funneled into the `target/doc`
directory.

Closes #785
2015-03-06 10:53:43 -08:00
Alex Crichton a6dad62221 Update to rust master and std::{io, path} 2015-02-27 15:34:13 -08:00
Andrew Paseltiner 256faff1e8 pass features to doctest binary 2015-02-13 08:52:42 -05:00
bors fc4b033ba7 Auto merge of #1283 - alexcrichton:bad-error, r=huonw
Closes rust-lang/crates.io#130
2015-02-13 00:24:36 +00:00
Alex Crichton 17dc427cca Improve error message for missing example/bin
Closes rust-lang/crates.io#130
2015-02-09 08:28:36 -08:00
Alex Crichton ee5e24ff8b Update to rust master 2015-02-06 15:10:05 -08:00
Alex Crichton cd869ef636 Remove auto-cleaning of the build directory
Over time this functionality has become obsolete through other means. Due to the
usage of `-L dependency=foo` it's not possible to pick up stale dependencies by
accident, and due to `--extern` you can only pick up a dependency. All of the
cases that auto-cleaning was fixing are now fixed through other methods, so
there's not much use ensuring a "clean build directory" any more.

This has the benefit of fixing issues like #961 where the downside of long
compiles outweighs the benefits of a "let's pretend we started from scratch"
build.

Closes #961
2015-02-04 14:58:33 -08:00
Gabriel Souza Franco af45e08862 std::io → std::old_io 2015-01-30 16:03:53 -02:00
Alex Crichton a40d3b03b8 Consider transitive fingerprints for freshness
Originally discovered through #1236, this commit fixes a bug in Cargo where
crates may not be recompiled when they need to (leading to obscure errors from
the compiler). The scenario in question looks like:

* Assume a dependency graph of `A -> B -> C` and `A -> C`
* Build all packages
* Modify C
* Rebuild, but hit Ctrl+C while B is building
* Modify A
* Rebuild again

Previously, Cargo only considered the freshness of a package to be the freshness
of the package itself (checking source files, for example). To handle transitive
recompilations, Cargo propagates a dirty bit throughout the dependency graph
automatically (instead if calculating it as such).

In the above example, however, we have a problem where as part of the last
rebuild Cargo thinks `B` and `C` are fresh! The artifact for `C` was just
recompiled, but `B`'s source code is untainted, so Cargo does not think that it
needs to recompile `B`. This is wrong, however, because one of `B`'s
dependencies was rebuilt, so it needs to be rebuilt.

To fix this problem, the fingerprint (a short hash) for all packages is now
transitively propagated (the fingerprint changes when an upstream package
changes). This should ensure that even when Ctrl+C is hit (or the situation
explained in #1236) that Cargo will still consider packages whose source code is
untainted as candidates for recompilation.

The implementation is somewhat tricky due to the actual fingerprint for a path
dependency not being known until *after* the crate is compiled (the fingerprint
is the mtime of the dep-info file).

Closes #1236
2015-01-28 22:01:35 -08:00
Alex Crichton d73a110d36 Update to rust 2015-01-24 2015-01-24 23:48:18 -08:00
Alex Crichton 0fdaf507a1 Remove infrastructure for the old custom build command
This aspect of the manifest has been deprecated for quite some time now, and
this commit purges the support entirely.
2015-01-19 15:48:06 -08:00
Alex Crichton 553211119b Update to rust master 2015-01-13 14:11:20 -08:00
Alex Crichton b9dddc22b1 Update usage of git2-rs 2014-12-31 13:09:21 -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 a6dc8ed755 Be sure to include --extern for dev-deps and examples 2014-12-28 01:04:10 -08:00
David Davidović c55a992cb4 Temporary fix for tests
Two tests (test_with_deep_lib_dep and lib_with_standard_name) fail due
to a bug in rustdoc (see rust-lang/rust#20183) so temporarily changing
these so they pass. Be sure to change it back when the fix lands in the
current rust nightly
2014-12-24 21:40:14 +01:00
Alex Crichton 48420965e6 Update to rust master 2014-12-21 12:33:09 -08:00
Alex Crichton 157d639afc Update rust and all deps 2014-12-19 20:55:17 -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
Jakub Bukaj df9cf06663 Update to newest Rust 2014-11-23 17:02:45 -05:00
Alex Crichton ac43ce1ae0 Rename --name flags to --<target-name>
With #843 and #839 coming around the bend soon, the original decision for
`--name` everywhere isn't making as much sense, for consistence this is renaming
these flags back to `--<target-name>` for the respective targets.
2014-11-13 09:39:53 -08:00
Alex Crichton 4358288600 Fix lines_match test for matching process output 2014-11-05 11:37:34 -08:00
bors 492bc86063 auto merge of #775 : alexcrichton/cargo/issue-771, r=brson
The examples output directory was accidentally taken into account twice, and
this removes one source of the output directory confusion.

Closes #771
2014-10-31 22:14:45 +00:00
Alex Crichton efb36f51ba Update deps with fail => panic
Also fix a few test's assertion messages
2014-10-30 08:48:32 -07:00
Steve Klabnik 33c6edba07 fail -> panic 2014-10-29 21:59:06 -04:00
Alex Crichton d188fcc9d1 Fix a repeated cargo test with examples
The examples output directory was accidentally taken into account twice, and
this removes one source of the output directory confusion.
2014-10-29 16:49:59 -07:00
Tomas Sedovic f93506aff2 Add --name to cargo test and cargo bench
You can now run a single test/bench file by passing its name to `cargo
test` or `cargo bench`.
2014-10-29 11:13:24 +01:00
Alex Crichton e969e495b8 Build examples into target/examples
This ends up killing two birds with one stone! The rationale behind this is that
the example and bin namespaces are not the same, and we don't mix metadata into
either filename, so the outputs need to be in different locations.

Closes #193
Closes #751
2014-10-27 12:57:49 -07:00
Alex Crichton e535c7b1c8 Use the right package for doc test variables 2014-10-07 12:01:10 -07:00
Alex Crichton f59416d092 Make sure dev-deps are compiled for examples
Examples are classified as binaries, but do not have the `test` flag set on
their Profile. They do, however, have their environment set to `test`. Be sure
to place them into the `tests` bucket so they have development dependencies
available for their compilation.
2014-10-06 19:52:01 -07:00
Alex Crichton a9f650b02b Don't always run doc tests for the root package
When using `cargo test -p`, be sure to run only the doc tests for the package
actually being tested.

Closes #660
2014-10-06 16:04:07 -07:00
Alex Crichton ec1091e9ee Remove the notion of "primary" from Context
Now that we have selective testing, this no longer makes any sense and all
queries to the path layout need to be based on the package being queried for.
This removes the primary flag from the Context, and requires that the `layout`
method have a local Package available

cc servo/servo#3580
2014-10-06 11:27:16 -07:00
Alex Crichton a7423e6765 Add a test for #432
All problems have been fixed in the previous commits, and this now closes #432
2014-10-02 18:43:26 -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
bors 9d93ba09d1 auto merge of #555 : alexcrichton/cargo/issue-215, r=brson
Also print the commands only right before they're actually run.

Closes #215
2014-09-11 21:28:53 +00:00
Alex Crichton 7a542c51b7 Don't print Running for commands that aren't run
Also print the commands only right before they're actually run.

Closes #215
2014-09-11 07:35:25 -07:00
Brian Koropoff 11d2e999b3 Fix obsolete extern crate syntax in some of the tests 2014-09-10 22:36:23 -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 d187620718 Update docopt to fix -- option parsing
Closes #492
2014-09-02 11:48:51 -07:00
Alex Crichton a658968135 Add a harness manifest option
This option is used to disable the --test flag to rustc for a test or benchmark
target in order to signal that the binary already knows how to run the testing
infrastructure.

The test/benchmark is still compiled and run as usual, and the exit code is
expected to reflect the result of the test/benchmark.

Closes #431
2014-08-26 18:51:47 -07:00