Skip to content

Commit eef4b30

Browse files
committed
docs(build-rs): Split out short descriptions
1 parent e5ce5e5 commit eef4b30

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

crates/build-rs/src/input.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ pub fn cargo() -> PathBuf {
9797
}
9898

9999
/// The directory containing the manifest for the package being built (the package
100-
/// containing the build script). Also note that this is the value of the current
100+
/// containing the build script).
101+
///
102+
/// Also note that this is the value of the current
101103
/// working directory of the build script when it starts.
102104
#[track_caller]
103105
pub fn cargo_manifest_dir() -> PathBuf {
104106
get_path("CARGO_MANIFEST_DIR")
105107
}
106108

107109
/// Contains parameters needed for Cargo’s [jobserver] implementation to parallelize
108-
/// subprocesses. Rustc or cargo invocations from build.rs can already read
110+
/// subprocesses.
111+
///
112+
/// Rustc or cargo invocations from build.rs can already read
109113
/// `CARGO_MAKEFLAGS`, but GNU Make requires the flags to be specified either
110114
/// directly as arguments, or through the `MAKEFLAGS` environment variable.
111115
/// Currently Cargo doesn’t set the `MAKEFLAGS` variable, but it’s free for build
@@ -129,7 +133,9 @@ pub fn cargo_feature(name: &str) -> bool {
129133
}
130134

131135
/// For each [configuration option] of the package being built, this will contain
132-
/// the value of the configuration. This includes values built-in to the compiler
136+
/// the value of the configuration.
137+
///
138+
/// This includes values built-in to the compiler
133139
/// (which can be seen with `rustc --print=cfg`) and values set by build scripts
134140
/// and extra flags passed to rustc (such as those defined in `RUSTFLAGS`).
135141
///
@@ -374,6 +380,7 @@ mod cfg {
374380
}
375381

376382
/// The folder in which all output and intermediate artifacts should be placed.
383+
///
377384
/// This folder is inside the build directory for the package being built, and
378385
/// it is unique for the package in question.
379386
#[track_caller]
@@ -396,7 +403,9 @@ pub fn host() -> String {
396403
get_str("HOST")
397404
}
398405

399-
/// The parallelism specified as the top-level parallelism. This can be useful to
406+
/// The parallelism specified as the top-level parallelism.
407+
///
408+
/// This can be useful to
400409
/// pass a `-j` parameter to a system like `make`. Note that care should be taken
401410
/// when interpreting this value. For historical purposes this is still provided
402411
/// but Cargo, for example, does not need to run `make -j`, and instead can set the
@@ -421,7 +430,9 @@ pub fn debug() -> String {
421430
get_str("DEBUG")
422431
}
423432

424-
/// `release` for release builds, `debug` for other builds. This is determined based
433+
/// `release` for release builds, `debug` for other builds.
434+
///
435+
/// This is determined based
425436
/// on if the [profile] inherits from the [`dev`] or [`release`] profile. Using this
426437
/// function is not recommended. Using other functions like [`opt_level`] provides
427438
/// a more correct view of the actual settings being used.

crates/build-rs/src/output.rs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ fn emit(directive: &str, value: impl Display) {
2121
}
2222

2323
/// The `rerun-if-changed` instruction tells Cargo to re-run the build script if the
24-
/// file at the given path has changed. Currently, Cargo only uses the filesystem
24+
/// file at the given path has changed.
25+
///
26+
/// Currently, Cargo only uses the filesystem
2527
/// last-modified “mtime” timestamp to determine if the file has changed. It
2628
/// compares against an internal cached timestamp of when the build script last ran.
2729
///
@@ -70,6 +72,7 @@ pub fn rerun_if_env_changed(key: impl AsRef<OsStr>) {
7072
/// The `rustc-link-arg` instruction tells Cargo to pass the
7173
/// [`-C link-arg=FLAG` option][link-arg] to the compiler, but only when building
7274
/// supported targets (benchmarks, binaries, cdylib crates, examples, and tests).
75+
///
7376
/// Its usage is highly platform specific. It is useful to set the shared library
7477
/// version or linker script.
7578
///
@@ -84,7 +87,9 @@ pub fn rustc_link_arg(flag: &str) {
8487

8588
/// The `rustc-link-arg-bin` instruction tells Cargo to pass the
8689
/// [`-C link-arg=FLAG` option][link-arg] to the compiler, but only when building
87-
/// the binary target with name `BIN`. Its usage is highly platform specific. It
90+
/// the binary target with name `BIN`. Its usage is highly platform specific.
91+
///
92+
/// It
8893
/// is useful to set a linker script or other linker options.
8994
///
9095
/// [link-arg]: https://doc.rust-lang.org/rustc/codegen-options/index.html#link-arg
@@ -101,7 +106,9 @@ pub fn rustc_link_arg_bin(bin: &str, flag: &str) {
101106

102107
/// The `rustc-link-arg-bins` instruction tells Cargo to pass the
103108
/// [`-C link-arg=FLAG` option][link-arg] to the compiler, but only when building
104-
/// the binary target. Its usage is highly platform specific. It is useful to set
109+
/// the binary target.
110+
///
111+
/// Its usage is highly platform specific. It is useful to set
105112
/// a linker script or other linker options.
106113
///
107114
/// [link-arg]: https://doc.rust-lang.org/rustc/codegen-options/index.html#link-arg
@@ -147,7 +154,9 @@ pub fn rustc_link_arg_benches(flag: &str) {
147154
}
148155

149156
/// The `rustc-link-lib` instruction tells Cargo to link the given library using
150-
/// the compiler’s [`-l` flag][-l]. This is typically used to link a native library
157+
/// the compiler’s [`-l` flag][-l].
158+
///
159+
/// This is typically used to link a native library
151160
/// using [FFI].
152161
///
153162
/// The `LIB` string is passed directly to rustc, so it supports any syntax that
@@ -229,7 +238,9 @@ pub fn rustc_link_search_kind(kind: &str, path: impl AsRef<Path>) {
229238
}
230239

231240
/// The `rustc-flags` instruction tells Cargo to pass the given space-separated
232-
/// flags to the compiler. This only allows the `-l` and `-L` flags, and is
241+
/// flags to the compiler.
242+
///
243+
/// This only allows the `-l` and `-L` flags, and is
233244
/// equivalent to using [`rustc_link_lib`] and [`rustc_link_search`].
234245
#[track_caller]
235246
pub fn rustc_flags(flags: &str) {
@@ -240,7 +251,9 @@ pub fn rustc_flags(flags: &str) {
240251
}
241252

242253
/// The `rustc-cfg` instruction tells Cargo to pass the given value to the
243-
/// [`--cfg` flag][cfg] to the compiler. This may be used for compile-time
254+
/// [`--cfg` flag][cfg] to the compiler.
255+
///
256+
/// This may be used for compile-time
244257
/// detection of features to enable conditional compilation.
245258
///
246259
/// Note that this does not affect Cargo’s dependency resolution. This cannot
@@ -264,7 +277,9 @@ pub fn rustc_cfg(key: &str) {
264277
emit("rustc-cfg", key);
265278
}
266279

267-
/// Like [`rustc_cfg`], but with the value specified separately. To replace the
280+
/// Like [`rustc_cfg`], but with the value specified separately.
281+
///
282+
/// To replace the
268283
/// less convenient `rustc_cfg(r#"my_component="foo""#)`, you can instead use
269284
/// `rustc_cfg_value("my_component", "foo")`.
270285
#[track_caller]
@@ -342,7 +357,9 @@ pub fn rustc_check_cfg_values(key: &str, values: &[&str]) {
342357
}
343358

344359
/// The `rustc-env` instruction tells Cargo to set the given environment variable
345-
/// when compiling the package. The value can be then retrieved by the
360+
/// when compiling the package.
361+
///
362+
/// The value can be then retrieved by the
346363
/// [`env!` macro][env!] in the compiled crate. This is useful for embedding
347364
/// additional metadata in crate’s code, such as the hash of git HEAD or the
348365
/// unique identifier of a continuous integration server.
@@ -363,7 +380,9 @@ pub fn rustc_env(key: &str, value: &str) {
363380

364381
/// The `rustc-cdylib-link-arg` instruction tells Cargo to pass the
365382
/// [`-C link-arg=FLAG` option][link-arg] to the compiler, but only when building
366-
/// a `cdylib` library target. Its usage is highly platform specific. It is useful
383+
/// a `cdylib` library target.
384+
///
385+
/// Its usage is highly platform specific. It is useful
367386
/// to set the shared library version or the runtime-path.
368387
///
369388
/// [link-arg]: https://doc.rust-lang.org/rustc/codegen-options/index.html#link-arg
@@ -376,7 +395,9 @@ pub fn rustc_cdylib_link_arg(flag: &str) {
376395
}
377396

378397
/// The `warning` instruction tells Cargo to display a warning after the build
379-
/// script has finished running. Warnings are only shown for path dependencies
398+
/// script has finished running.
399+
///
400+
/// Warnings are only shown for path dependencies
380401
/// (that is, those you’re working on locally), so for example warnings printed
381402
/// out in [crates.io] crates are not emitted by default. The `-vv` “very verbose”
382403
/// flag may be used to have Cargo display warnings for all crates.

0 commit comments

Comments
 (0)