Skip to content

Commit 93bf2a3

Browse files
committed
Auto merge of #4916 - tari:doc-recovery, r=alexcrichton
Recover doc changes lost in #4904 Fixes #4906.
2 parents daa20af + f235d7b commit 93bf2a3

File tree

8 files changed

+93
-20
lines changed

8 files changed

+93
-20
lines changed

src/doc/src/guide/build-cache.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Build cache
2+
3+
Cargo shares build artifacts among all the packages of a single workspace.
4+
Today, Cargo does not share build results across different workspaces, but
5+
a similar result can be achieved by using a third party tool, [sccache].
6+
7+
To setup `sccache`, install it with `cargo install sccache` and set
8+
`RUSTC_WRAPPER` environmental variable to `sccache` before invoking Cargo.
9+
If you use bash, it makes sense to add `export RUSTC_WRAPPER=sccache` to
10+
`.bashrc`. Refer to sccache documentation for more details.
11+
12+
[sccache]: https://github.com/mozilla/sccache
13+
14+

src/doc/src/guide/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ develop Rust projects.
1111
* [Cargo.toml vs Cargo.lock](guide/cargo-toml-vs-cargo-lock.html)
1212
* [Tests](guide/tests.html)
1313
* [Continuous Integration](guide/continuous-integration.html)
14+
* [Build Cache](guide/build-cache.html)

src/doc/src/reference/build-scripts.md

+17-9
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ the source directory of the build script’s package.
4747

4848
All the lines printed to stdout by a build script are written to a file like
4949
`target/debug/build/<pkg>/output` (the precise location may depend on your
50-
configuration). Any line that starts with `cargo:` is interpreted directly by
51-
Cargo. This line must be of the form `cargo:key=value`, like the examples below:
50+
configuration). If you would like to see such output directly in your terminal,
51+
invoke cargo as 'very verbose' with the `-vv` flag. Note that if neither the
52+
build script nor project source files are modified, subsequent calls to
53+
cargo with `-vv` will **not** print output to the terminal because a
54+
new build is not executed. Run `cargo clean` before each cargo invocation
55+
if you want to ensure that output is always displayed on your terminal.
56+
Any line that starts with `cargo:` is interpreted directly by Cargo.
57+
This line must be of the form `cargo:key=value`, like the examples below:
5258

5359
```shell
5460
# specially recognized by Cargo
@@ -371,24 +377,26 @@ portable, and standardized. For example, the build script could be written as:
371377
```rust,ignore
372378
// build.rs
373379
374-
// Bring in a dependency on an externally maintained `gcc` package which manages
380+
// Bring in a dependency on an externally maintained `cc` package which manages
375381
// invoking the C compiler.
376-
extern crate gcc;
382+
extern crate cc;
377383
378384
fn main() {
379-
gcc::compile_library("libhello.a", &["src/hello.c"]);
385+
cc::Build::new()
386+
.file("src/hello.c")
387+
.compile("hello");
380388
}
381389
```
382390

383-
Add a build time dependency on the `gcc` crate with the following addition to
391+
Add a build time dependency on the `cc` crate with the following addition to
384392
your `Cargo.toml`:
385393

386394
```toml
387395
[build-dependencies]
388-
gcc = "0.3"
396+
gcc = "1.0"
389397
```
390398

391-
The [`gcc` crate](https://crates.io/crates/gcc) abstracts a range of build
399+
The [`cc` crate](https://crates.io/crates/cc) abstracts a range of build
392400
script requirements for C code:
393401

394402
* It invokes the appropriate compiler (MSVC for windows, `gcc` for MinGW, `cc`
@@ -397,7 +405,7 @@ script requirements for C code:
397405
the compiler being used.
398406
* Other environment variables, such as `OPT_LEVEL`, `DEBUG`, etc., are all
399407
handled automatically.
400-
* The stdout output and `OUT_DIR` locations are also handled by the `gcc`
408+
* The stdout output and `OUT_DIR` locations are also handled by the `cc`
401409
library.
402410

403411
Here we can start to see some of the major benefits of farming as much

src/doc/src/reference/config.md

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ runner = ".."
7676
# custom flags to pass to all compiler invocations that target $triple
7777
# this value overrides build.rustflags when both are present
7878
rustflags = ["..", ".."]
79+
# Whether or not to enable incremental compilation
80+
incremental = true
7981

8082
[target.'cfg(...)']
8183
# Similar for the $triple configuration, but using the `cfg` syntax.

src/doc/src/reference/environment-variables.md

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ system:
2828
* `RUSTFLAGS` - A space-separated list of custom flags to pass to all compiler
2929
invocations that Cargo performs. In contrast with `cargo rustc`, this is
3030
useful for passing a flag to *all* compiler instances.
31+
* `CARGO_INCREMENTAL` - If this is set to 1 then Cargo will force incremental
32+
compilation to be enabled for the current compilation, and when set to 0 it
33+
will force disabling it. If this env var isn't present then cargo's defaults
34+
will otherwise be used.
3135

3236
Note that Cargo will also read environment variables for `.cargo/config`
3337
configuration values, as described in [that documentation][config-env]

src/doc/src/reference/manifest.md

+48-10
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ license-file = "..."
199199

200200
# Appveyor: `repository` is required. `branch` is optional; default is `master`
201201
# `service` is optional; valid values are `github` (default), `bitbucket`, and
202-
# `gitlab`.
202+
# `gitlab`; `id` is optional; you can specify the appveyor project id if you
203+
# want to use that instead. `project_name` is optional; use when the repository
204+
# name differs from the appveyor project name.
203205
appveyor = { repository = "...", branch = "master", service = "github" }
204206

205207
# Circle CI: `repository` is required. `branch` is optional; default is `master`
@@ -299,6 +301,7 @@ codegen-units = 1 # if > 1 enables parallel code generation which improves
299301
# compile times, but prevents some optimizations.
300302
# Passes `-C codegen-units`. Ignored when `lto = true`.
301303
panic = 'unwind' # panic strategy (`-C panic=...`), can also be 'abort'
304+
incremental = true # whether or not incremental compilation is enabled
302305

303306
# The release profile, used for `cargo build --release`.
304307
[profile.release]
@@ -309,6 +312,7 @@ lto = false
309312
debug-assertions = false
310313
codegen-units = 1
311314
panic = 'unwind'
315+
incremental = false
312316

313317
# The testing profile, used for `cargo test`.
314318
[profile.test]
@@ -319,6 +323,7 @@ lto = false
319323
debug-assertions = true
320324
codegen-units = 1
321325
panic = 'unwind'
326+
incremental = true
322327

323328
# The benchmarking profile, used for `cargo bench` and `cargo test --release`.
324329
[profile.bench]
@@ -329,6 +334,7 @@ lto = false
329334
debug-assertions = false
330335
codegen-units = 1
331336
panic = 'unwind'
337+
incremental = false
332338

333339
# The documentation profile, used for `cargo doc`.
334340
[profile.doc]
@@ -339,6 +345,7 @@ lto = false
339345
debug-assertions = true
340346
codegen-units = 1
341347
panic = 'unwind'
348+
incremental = true
342349
```
343350

344351
### The `[features]` section
@@ -475,10 +482,12 @@ as:
475482
```toml
476483
[workspace]
477484

478-
# Optional key, inferred if not present
485+
# Optional key, inferred from path dependencies if not present.
486+
# Additional non-path dependencies that should be included must be given here.
487+
# In particular, for a virtual manifest, all members have to be listed.
479488
members = ["path/to/member1", "path/to/member2", "path/to/member3/*"]
480489

481-
# Optional key, empty if not present
490+
# Optional key, empty if not present.
482491
exclude = ["path1", "path/to/dir2"]
483492
```
484493

@@ -528,10 +537,23 @@ crate will be treated as a normal package, as well as a workspace. If the
528537
`package` table is not present in a workspace manifest, it is called a *virtual
529538
manifest*.
530539

531-
When working with *virtual manifests*, package-related cargo commands, like
532-
`cargo build`, won't be available anymore. But, most of such commands support
533-
the `--all` option, will execute the command for all the non-virtual manifest in
534-
the workspace.
540+
#### Package selection
541+
542+
In a workspace, package-related cargo commands like `cargo build` apply to
543+
packages selected by `-p` / `--package` or `--all` command-line parameters.
544+
When neither is specified, the optional `default-members` configuration is used:
545+
546+
```toml
547+
[workspace]
548+
members = ["path/to/member1", "path/to/member2", "path/to/member3/*"]
549+
default-members = ["path/to/member2", "path/to/member3/foo"]
550+
```
551+
552+
When specified, `default-members` must expand to a subset of `members`.
553+
554+
When `default-members` is not specified, the default is the root manifest
555+
if it is a package, or every member manifest (as if `--all` were specified
556+
on the command-line) for virtual workspaces.
535557

536558
#TODO: move this to a more appropriate place
537559
### The project layout
@@ -550,7 +572,8 @@ each file you want to build.
550572

551573
Your project can optionally contain folders named `examples`, `tests`, and
552574
`benches`, which Cargo will treat as containing examples,
553-
integration tests, and benchmarks respectively.
575+
integration tests, and benchmarks respectively. Analogous to `bin` targets, they
576+
may be composed of single files or directories with a `main.rs` file.
554577

555578
```shell
556579
▾ src/ # directory containing source files
@@ -562,10 +585,16 @@ integration tests, and benchmarks respectively.
562585
main.rs
563586
▾ examples/ # (optional) examples
564587
*.rs
588+
*/ # (optional) directories containing multi-file examples
589+
main.rs
565590
▾ tests/ # (optional) integration tests
566591
*.rs
592+
*/ # (optional) directories containing multi-file tests
593+
main.rs
567594
▾ benches/ # (optional) benchmarks
568595
*.rs
596+
*/ # (optional) directories containing multi-file benchmarks
597+
main.rs
569598
```
570599

571600
To structure your code after you've created the files and folders for your
@@ -723,19 +752,28 @@ other copies. The syntax is similar to the `[dependencies]` section:
723752
[patch.crates-io]
724753
foo = { git = 'https://github.com/example/foo' }
725754
bar = { path = 'my/local/bar' }
755+
756+
[dependencies.baz]
757+
git = 'https://github.com/example/baz'
758+
759+
[patch.'https://github.com/example/baz']
760+
baz = { git = 'https://github.com/example/patched-baz', branch = 'my-branch' }
726761
```
727762

728763
The `[patch]` table is made of dependency-like sub-tables. Each key after
729764
`[patch]` is a URL of the source that's being patched, or `crates-io` if
730765
you're modifying the https://crates.io registry. In the example above
731766
`crates-io` could be replaced with a git URL such as
732-
`https://github.com/rust-lang-nursery/log`.
767+
`https://github.com/rust-lang-nursery/log`; the second `[patch]`
768+
section in the example uses this to specify a source called `baz`.
733769

734770
Each entry in these tables is a normal dependency specification, the same as
735771
found in the `[dependencies]` section of the manifest. The dependencies listed
736772
in the `[patch]` section are resolved and used to patch the source at the
737773
URL specified. The above manifest snippet patches the `crates-io` source (e.g.
738-
crates.io itself) with the `foo` crate and `bar` crate.
774+
crates.io itself) with the `foo` crate and `bar` crate. It also
775+
patches the `https://github.com/example/baz` source with a `my-branch` that
776+
comes from elsewhere.
739777

740778
Sources can be patched with versions of crates that do not exist, and they can
741779
also be patched with versions of crates that already exist. If a source is

src/doc/src/reference/publishing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ accidentally package up that 2GB video asset, or large data files used for code
5252
generation, integration tests, or benchmarking. There is currently a 10MB
5353
upload size limit on `*.crate` files. So, if the size of `tests` and `benches`
5454
directories and their dependencies are up to a couple of MBs, you can keep them
55-
in your package; otherwsie, better to exclude them.
55+
in your package; otherwise, better to exclude them.
5656

5757
Cargo will automatically ignore files ignored by your version control system
5858
when packaging, but if you want to specify an extra set of files to ignore you

src/doc/src/reference/source-replacement.md

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ like so:
2020
[source.my-awesome-source]
2121
directory = "vendor"
2222

23+
# Git sources can optionally specify a branch/tag/rev as well
24+
git = "https://example.com/path/to/repo"
25+
# branch = "master"
26+
# tag = "v1.0.1"
27+
# rev = "313f44e8"
28+
2329
# The crates.io default source for crates is available under the name
2430
# "crates-io", and here we use the `replace-with` key to indicate that it's
2531
# replaced with our source above.

0 commit comments

Comments
 (0)