Commit graph

5362 commits

Author SHA1 Message Date
Alex Crichton 9f5d9b8166 Blow away all directories/files on each build
And aftewards selectively move them back into place if they're fresh. This
prevents stale files from showing up from old builds.

This currently breaks anyone build `build=` scripts, the fix is coming in the
next commit.

Closes #205
2014-07-18 15:56:16 -07:00
bors 7a2aa75414 auto merge of #212 : fhahn/cargo/version, r=alexcrichton
This PR adds a rustc style version command
2014-07-18 14:53:17 +00:00
Alex Crichton aaaf9dbf1e Update to master 2014-07-18 07:40:15 -07:00
Florian Hahn fc9825318f Add version command, closes #201 2014-07-18 14:42:26 +02:00
Florian Hahn c4710b74e7 Use indexing instead of get() function to access Vec 2014-07-17 22:27:02 +02: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 12af54e17a Allow configuratin ar/ld for rustc
This adds a new .cargo/config option which allows configuring the ar and linker
tools that rustc invokes. This should aid in any cross-compilation attempts.
2014-07-14 11:28:40 -07:00
bors 811d70d148 auto merge of #190 : alexcrichton/cargo/cargo-run, r=wycats
This currently only supports executing the `src/main.rs` convention, no other.

Close #149
2014-07-14 18:16:57 +00:00
Alex Crichton a64b9073f4 Add a cargo run command
This currently only supports executing the `src/main.rs` convention, no other.

Close #149
2014-07-14 06:40:51 -07:00
Alex Crichton 8defed6160 Pass all formats via --extern for libs
While we support the `crate_type` key in the manifest, we need to pass through
all crate types to the `--extern` flag.

Closes #177
2014-07-13 11:33:11 -07:00
bors ec0895b460 auto merge of #188 : huonw/cargo/remove-src-test, r=wycats
It's not unreasonable to have unittests in a separate submodule of the
crate (being called `test` or `tests`), and having them in their own
file can be very sensible. Thus, the `src/test.rs` implicit default is
likely to trip up some perfectly reasonable use-cases. There's already
the `tests/...` default, so repairing a codebase after this removal is
just moving `src/test.rs` to `tests/whatever_name_you_want.rs`.

Closes #187.
2014-07-13 15:48:50 +00:00
Huon Wilson 22c254af74 Remove the src/test.rs implicit test.
It's not unreasonable to have unittests in a separate submodule of the
crate (being called `test` or `tests`), and having them in their own
file can be very sensible. Thus, the `src/test.rs` implicit default is
likely to trip up some perfectly reasonable use-cases. There's already
the `tests/...` default, so repairing a codebase after this removal is
just moving `src/test.rs` to `tests/whatever_name_you_want.rs`.

Closes #187.
2014-07-13 22:48:45 +10:00
bors 2f60ba328b auto merge of #180 : sfackler/cargo/ndebug, r=wycats
This will disable debug!() and debug_assert!() statements.
2014-07-13 05:44:50 +00:00
Steven Fackler a12a909c04 Pass --cfg ndebug when debug = false
This will disable debug!() and debug_assert!() statements.
2014-07-12 20:46:11 -07:00
Alex Crichton a70be72342 Pass through extra arguments to cargo test
This allows `cargo test` usage to filter test being run, use --nocapture, etc.
2014-07-12 20:29:51 -07:00
bors 9d13d8a184 auto merge of #170 : alexcrichton/cargo/same-name, r=wycats
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-12 03:59:51 +00: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
Ben Longbons 2e90972004 Do not run examples during 'cargo test' 2014-07-11 13:41:26 -07:00
Ben Longbons b7379e51b4 Add support for external tests 2014-07-11 13:41:26 -07:00
Ben Longbons 246c9e2a55 Add support for examples 2014-07-11 13:41:26 -07:00
Alex Crichton ff19a48290 Finish plugin support
This commit implements full support for plugins by answering the question of
whether any target needed as a plugin or needed as a target dependency. This
commit builds on the previous abstractions to enable parallel compilation
wherever possible.
2014-07-11 12:20:25 -07:00
Alex Crichton 685f2b4ee7 Add some simple tests for cross compilation 2014-07-11 09:08:51 -07:00
Alex Crichton 662b8553d6 Fix some tests 2014-07-10 12:51:13 -07:00
Alex Crichton 16df1ab41e Tighten up some tests 2014-07-10 12:08:13 -07:00
Alex Crichton d29910068c Fix filtering for test deps
This fixes `cargo test` to only test the *local* package
2014-07-10 11:50:03 -07:00
Michael Gehring 139e81ea82 ToStr::to_str -> ToString::to_string
Conflicts:
	src/cargo/core/resolver.rs
	src/cargo/ops/cargo_rustc.rs
2014-07-10 08:37:57 -07:00
Yehuda Katz 215ae2f9a1 Remove hardcoding 2014-07-10 01:26:51 -07:00
Yehuda Katz 7eb5ea543d Fixed a number of bugs related to rustc building
Most notably, `resolve` now takes the root, so it can properly link the
root package with its dependencies (which is required to build the
--externs for the root package).
2014-07-10 00:27:40 -07:00
Yehuda Katz + Carl Lerche e143491356 Resolve more correctly and add --extern
This commit adds support for passing --extern to dependencies. It allows
multiple copies of the same named dependency in the system, as long as
they come from different repos.
2014-07-09 20:17:08 -07:00
Alex Crichton 558e75347e Fix --release not compiling upstream deps with -O3
This touches up the filtering logic to ensure that upstream dependencies as well
as local dependencies are built with optimizations when `cargo build --release`
is used.
2014-07-09 13:55:00 -07:00
Alex Crichton 3550dd5040 Fix testing bins with lib deps
If a package had both bin and lib deps, `cargo test` was not building the `lib`
dependency when building the bins with `--test`. This commit adds an extra
"test" profile (not compiled with --test) for situations such as this which is
filtered out normally but kept around for the `cargo test` case.
2014-07-09 13:08:44 -07:00
Yehuda Katz + Carl Lerche 59bc9adb29 Refactor PackageId.namespace -> source_id 2014-07-08 14:58:56 -07:00
Joshua DeSeno 0025dbde64 cargo clean. resolves #51 2014-07-08 21:54:15 +09:00
bors a6061db0d0 auto merge of #142 : rust-lang/cargo/new-names, r=alexcrichton
This PR moves Cargo over to the new naming based on [RFC 35](https://github.com/rust-lang/rfcs/blob/master/complete/0035-remove-crate-id.md).

* You should no longer use `#[crate_name]` or `#[crate_id]` in any crate managed by Cargo.
* You no longer need a `[[lib]]` section in your `Cargo.toml` if you name your library `src/lib.rs`.
* You no longer need a `[[bin]]` section in your `Cargo.toml` if you name your library `src/main.rs`.
* You can include multiple `[[bins]]` in `src/bin/*.rs` and Cargo will treat them as if they were specified via `[[bin]]`.

This commit does not yet add support for `-C metadata` or `-C extra-file-name`, but that is coming soon.
2014-07-08 06:14:56 +00:00
Yehuda Katz + Carl Lerche ee1a81a801 This updates Cargo for #[crate_name] 2014-07-07 21:42:34 -07:00
Alex Crichton 03ccdd8169 Warn about missing [[lib]] and [[bin]] sections
Closes #120
2014-07-07 20:59:47 -07:00
bors 6248ebe5b2 auto merge of #139 : tomjakubowski/cargo/fix-symlink-blowup, r=alexcrichton
Fingerprinting will fail at an `fs::stat()` call if there is a symlink in
a package's directory pointing to a non-existent file or directory.
This commit recovers from an `fs::stat(`) error on these bogus symlinks by
faking an mtime of 0, which should not affect the overall fingerprint.

Fix #135
2014-07-08 01:46:02 +00:00
Tom Jakubowski 94ba70881d Ignore the broken symlinks test on windows 2014-07-07 18:42:53 -07:00
Tom Jakubowski f488174208 fingerprint: Recover from fs::stat errors
Fingerprinting will fail at an fs::stat() call if there is a broken
symlink in a package's directory.  This commit recovers from fs::stat()
errors on broken symlinks by treating them as having mtime 0, which
should not affect the overall fingerprint.

Fix #135
2014-07-07 15:33:40 -07:00
bors d0ac39d40b auto merge of #140 : rust-lang/cargo/release, r=carllerche 2014-07-07 22:29:56 +00:00
Yehuda Katz + Carl Lerche a1980dc78b Add --release and related refactoring 2014-07-07 15:17:34 -07:00
Tomaka17 c545221c25 Support for multiple and cleaner build commands 2014-07-07 22:12:26 +02:00
Yehuda Katz + Carl Lerche 9cbb91ac06 Fix up dev-dependencies 2014-07-03 12:42:18 -07:00
Yehuda Katz + Carl Lerche 172cbefc3b Added [dev-dependencies] sections to Cargo.toml
If you put a dependency in [dev-dependencies], it will only be
used when building (or testing) your packages, not other packages that
depend on it.
2014-07-03 07:30:11 -07:00
Yehuda Katz ea3cb31cec Meta-packages 2014-06-30 18:36:27 -07:00
Alex Crichton 71e4252a90 Don't infinitely recurse on cyclic path deps
Instead, keep a table of what we've visited and halt recursion whenever we
re-visit a package.

Closes #77
2014-06-30 13:18:14 -07:00
bors aa8986ffc4 auto merge of #87 : alexcrichton/cargo/toml-warnings, r=wycats
Closes #27
2014-06-30 20:00:09 +00:00
Huon Wilson c0865e85e3 Check for the existence of Cargo.toml when reading packages.
Fixes #82.
2014-06-30 10:42:08 +10:00
Alex Crichton a2aa2bf938 Warn about unused TOML keys
Closes #27
2014-06-28 15:18:44 -07:00
Alex Crichton 0ccb2fa2e2 Use a custom rm_rf to paper over windows git funkiness 2014-06-28 12:28:36 -07:00
Arcterus 856f37091c Error out on ssh dependencies (fixes #55) 2014-06-26 21:41:06 -07:00
bors c919f2f646 auto merge of #70 : alexcrichton/cargo/buildbot, r=wycats
* The installation script was modified to recognize when its running on windows,
  as well as tweaking how it downloads and installs snapshots. The goal here was
  to make the script runnable on buildbot for mac/linux/windows with 32/64 bit
  options on mac/linux.

* The installation script now install rustc to `rustc/bin` in the local
  directory to have parallel builds on buildbot.

* The tests now store all their temporary state locally in the build directory
  to enable parallel builds on buildbot.

* A shell test is ignored which assumed the presence of a TTY output.
2014-06-27 03:36:24 +00:00
Alex Crichton ad19a31d9b Prepare for buildbot automation
* The installation script was modified to recognize when its running on windows,
  as well as tweaking how it downloads and installs snapshots. The goal here was
  to make the script runnable on buildbot for mac/linux/windows with 32/64 bit
  options on mac/linux.

* The installation script now install rustc to `rustc/bin` in the local
  directory to have parallel builds on buildbot.

* The tests now store all their temporary state locally in the build directory
  to enable parallel builds on buildbot.

* A shell test is ignored which assumed the presence of a TTY output.
2014-06-26 20:25:30 -07:00
Tim Carey-Smith 13eb123213 Add cargo test 2014-06-26 16:47:27 -07:00
Alex Crichton 8d5acdfc67 Don't recompile nested deps too frequently
When compiling a package with a nested dependency, any modification to the outer
package would trigger a recompilation of the inner package. This commit alters
the fingerprint() method to take a PackageId to query about the location of a
package and only lookup the files relevant to that package.

The dependency structure of a PathSource is now everything rooted at the
original Cargo.toml minus all subdirectories which contain a Cargo.toml
2014-06-25 15:21:43 -07:00
Alex Crichton c3ec9999cb Ignore \r in output matching
Windows occasionally has \r\n while everywhere else has \n. Instead of worrying
about the difference, just replace all instances of \r with nothing and rely on
matching against \n.
2014-06-25 11:15:04 -07:00
Alex Crichton 80a81334f6 Fix lots of windows tests
* Add a convenience method bin() for generating the name of a binary. On windows
  this remembers to append `.exe`.

* Stop executing relative paths to binaries and relying on PATH. This is
  suffering from rust-lang/rust#15149 and failing to spawn processes on windows.
  Additionally, this allows the tests to work with a pre-installed cargo becuase
  the freshly built executables are precisely specified.

* A new function, escape_path(), was added for tests. When generated source
  files with paths, this function needs to be called to properly escape the
  \-character that appears in windows path names. Without this function we would
  be generating invalid TOML and rust.
2014-06-25 11:15:04 -07:00
Alex Crichton 06d19011db Fix rm_rf on windows
Apparently git checkouts have objects in the database with permissions 444 which
need to be changed to something with a write permission before removal.
2014-06-25 11:12:56 -07:00
Alex Crichton 200398ef8f Disable terminal tests on windows
The windows terminal does not use terminfo and is much different, so these tests
will fail on windows or actually write to the console.
2014-06-25 11:12:56 -07:00
Huon Wilson 9514dafd0e Handle misformatted versions with a nicer error message. 2014-06-25 18:05:51 +10:00
Yehuda Katz c08f8f3026 Add support for branch/tag/rev options 2014-06-24 15:23:14 -07:00
Alex Crichton 352efa73b5 Work around \-characters on Windows for now 2014-06-23 22:42:10 -07:00
Yehuda Katz eb6b0d6281 Rename cargo-compile to cargo-build 2014-06-23 19:09:12 -07:00
Yehuda Katz 5919fa0dfc Only force update git if -u is passed
This will become moot once we have a lockfile, because we'll be able to
check whether the last rev we used is still available and skip fetching.
2014-06-23 18:54:13 -07:00
Yehuda Katz 860ca08ad2 Allow absent git version 2014-06-23 17:38:50 -07:00
Yehuda Katz 86b2a2a432 Support [package] or [project]
The plan is to free up [project] for simpler config plus output flags
like -O that don't make sense in packages.
2014-06-23 16:57:27 -07:00
Alex Crichton d4265ef2a0 Move from rust-toml to toml-rs
This commit should greatly improve all error messages related to decoding
Cargo.toml.
2014-06-23 11:38:53 -07:00
Alex Crichton 8901563c0b Fix a red test 2014-06-23 09:44:00 -07:00
Yehuda Katz 19bea0ad0c Thread the shell through more of the system 2014-06-21 22:22:56 -07:00
Yehuda Katz 687035657d Terminal colors 2014-06-21 18:53:07 -07:00
Alex Crichton e05b4dc838 Don't rebuild dependencies if they haven't changed
This commit adds support for recognizing "fingerprints" of upstream
dependencies. When a dependency's fingerprint change, it must be rebuilt.
Currently the fingerprint unconditionally includes the version of the compiler
you're using as well as a specialized version depending on the type of source
you're compiling from:

  - git sources return their fingerprint as the current SHA. This will
    disregard any local changes.
  - path sources return their fingerprint as the maximum mtime of any file found
    at the location. This is a little too coarse and may rebuild packages too
    often (due to sub-packages), but this should get the job done for now.

When executing `cargo compile`, dependencies are not rebuilt if their
fingerprint remained constant.
2014-06-19 21:55:37 -07:00
Alex Crichton bc1dea82c8 Invoke rustc only once for multiple crate types 2014-06-19 19:44:45 -07:00
Alex Crichton 64ff29ff86 Update to rust style guidelines
* 80 char line limit highly recommended
* /// and //! for doc comments
2014-06-19 17:02:21 -07:00
Alex Crichton a9d8d2c62a Run tests in parallel
Give each test is own root inside of the shared root to ensure that the tests
are still isolated from one another.
2014-06-19 11:52:51 -07:00
Alex Crichton fbfa8bdeca Make CARGO_BIN_PATH optional for tests
This allows easier use of running tests by hand.
2014-06-19 11:52:51 -07:00
Alex Crichton 3433a01eba Allow custom precompile commands
This commit enables support for custom precompilation commands to be triggered
before a package builds via rustc. The current interface is to have
`build = "foo"` in the `[project]` section of Cargo.toml and cargo will just
execute the exact command given.
2014-06-19 11:52:51 -07:00
Yehuda Katz 8c72add4f5 Squelch warnings and minor cleanup 2014-06-19 01:21:24 -07:00
Yehuda Katz 3e09f70259 Initial pass at boxed errors
The next step is to clean up the error handling in general so that
failure cases produce good errors.
2014-06-19 00:57:12 -07:00
Yehuda Katz + Carl Lerche bcf9028749 Support nested paths in git and path sources 2014-06-17 17:40:22 -07:00
Yehuda Katz + Carl Lerche 9224a5ae61 Paths nested in paths 2014-06-17 17:05:29 -07:00
Carl Lerche + Yehuda Katz 512ec4b794 Fix tests 2014-06-13 14:19:06 -07:00
Carl Lerche + Yehuda Katz 35e21c7600 Smoke test for git support 2014-06-12 15:51:16 -07:00
Yehuda Katz + Carl Lerche 51c9cf0f87 Sources are now an array 2014-06-11 15:59:18 -07:00
Yehuda Katz + Carl Lerche c57fef459a Add namespace to PackageId 2014-06-11 14:51:13 -07:00
Yehuda Katz + Carl Lerche 1124727c96 Update to Rust master and eliminate warnings 2014-06-10 12:32:23 -07:00
Yehuda Katz + Carl Lerche 92602f6db0 Add support for detailed manifest dependencies
This commit supports the following format:

```toml
[dependencies.hamcrest]

version = "1.0"
git = "http://github.com/carllerche/hamcrest-rust"
```
2014-06-09 17:51:53 -07:00
Yehuda Katz + Carl Lerche 9a1c63ea17 Track master for tests 2014-06-09 13:08:09 -07:00
Yehuda Katz 41b6f52681 Tests passing again 2014-05-29 14:31:09 -07:00
Yehuda Katz e42203f7f6 Up to date with master 2014-05-29 14:06:43 -07:00
Yehuda Katz edbe491003 Up to date with master 2014-05-29 13:57:31 -07:00
Carl Lerche a06fd2e7fa Compile all deps into the root projects target dir 2014-05-28 17:31:23 -07:00
Yehuda Katz d5a7bc33d2 Improve shell and add tests 2014-05-27 18:53:37 -07:00
Yehuda Katz 574829e9f7 Initial pass at a Shell 2014-05-27 18:53:37 -07:00
Carl Lerche 7e6433feda Track rust master 2014-05-27 16:14:34 -07:00
Yehuda Katz 21322f07b4 Wrote more integration tests for cargo compile
At the moment, the rustc exec for the root project inherits the stdout
and stderr FDs (so that warnings and errors flow through), but
output from dependencies is only emitted if the compilation fails to
avoid warning noise from dependencies.
2014-05-12 17:33:13 -07:00
Yehuda Katz b8621c5042 More tests for error cases in compile
Also some refactoring of the error structure. More cleanup work around
human-readable and CLI errors is still required.
2014-05-09 16:57:13 -07:00
Yehuda Katz 7983a5fd16 Clean up process DSL in tests 2014-05-08 17:50:58 -07:00
Yehuda Katz 48dc081419 Get nested dependencies working 2014-05-08 16:50:53 -07:00
Yehuda Katz 23d78ddfb0 Support any bytes container 2014-05-08 16:50:52 -07:00
Yehuda Katz 682d4e94c8 Get compile test passing 2014-05-08 13:33:04 -07:00
Carl Lerche bafa5f2b5a Track Rust master changes 2014-05-08 13:10:08 -07:00
Carl Lerche 1ce7641593 Core struct refactor 2014-05-05 21:54:49 -07:00
Carl Lerche 8842b02cfd Cleanup ProcessBuilder, work towards getting tests passing 2014-05-05 16:28:01 -07:00
Yehuda Katz 85e4dccef2 Everything's compiling again 2014-04-29 11:05:01 -07:00
Carl Lerche f4d6d02135 Beginnings of a dependency resolver 2014-04-11 15:11:10 -07:00
Carl Lerche db92e67c87 Track rust master 2014-04-09 13:28:10 -07:00
Carl Lerche 79fe64158c Implement process hamcrest matcher 2014-04-02 16:34:19 -07:00
Carl Lerche 6899567bc3 Update tests against Rust master 2014-04-02 13:22:45 -07:00
Carl Lerche aec45be721 Cleanup integration test 2014-03-20 15:17:19 -07:00
Carl Lerche d1ec90b3d8 Initial stab at integration tests
At the same time, we started adding a generic error handling concept to
Cargo.

The idea is that every Result gets converted to a CargoError, which
includes all the information that Cargo needs to print out a friendly
human error message and exit gracefully.
2014-03-20 12:12:47 -07:00
Carlhuda 227d4e83ef Initial commit 2014-03-04 15:22:44 -08:00