Expand description
Outputs from the build script, in the form of cargo:
printed lines.
Does not print a leading newline. Thus, if you ever write to stdout and don’t lock until a trailing newline, these instructions will likely fail.
Functions
The rerun-if-changed
instruction tells Cargo to re-run the build script
if the file at the given path has changed. Currently, Cargo only uses the
filesystem last-modified “mtime” timestamp to determine if the file has
changed. It compares against an internal cached timestamp of when the build
script last ran.
The rerun-if-env-changed
instruction tells Cargo to re-run the build
script if the value of an environment variable of the given name has
changed.
The rustc-cdylib-link-arg
instruction tells Cargo to pass the
-C link-arg=FLAG
option
to the compiler, but only when building a cdylib library target. Its usage
is highly platform specific. It is useful to set the shared library version
or the runtime-path.
The rustc-cfg
instruction tells Cargo to pass the given value to the
--cfg
flag
to the compiler. This may be used for compile-time detection of features to
enable conditional compilation.
The rustc-env
instruction tells Cargo to set the given environment
variable when compiling the package. The value can be then retrieved by the
env! macro
in the compiled crate. This is useful for embedding
additional metadata in crate’s code, such as the hash of git HEAD or the
unique identifier of a continuous integration server.
The rustc-flags
instruction tells Cargo to pass the given space-separated
flags to the compiler. This only allows the -l
and -L
flags, and is
equivalent to using rustc-link-lib
and rustc-link-search
.
The rustc-link-arg instruction tells Cargo to pass the
-C link-arg=FLAG
option
to the compiler, but only when building supported targets (benchmarks,
binaries, cdylib crates, examples, and tests). Its usage is highly platform
specific. It is useful to set the shared library version or linker script.
The rustc-link-arg-bin
instruction tells Cargo to pass the
-C link-arg=FLAG
option
to the compiler, but only when building the binary target with name BIN
.
Its usage is highly platform specific. It is useful to set a linker script
or other linker options.
The rustc-link-arg-bins
instruction tells Cargo to pass the
-C link-arg=FLAG
option
to the compiler, but only when building a binary target. Its usage is
highly platform specific. It is useful to set a linker script or other
linker options.
The rustc-link-lib
instruction tells Cargo to link the given library
using the compiler’s -l
flag. This is typically used to link a native
library using [FFI
].
The rustc-link-search
instruction tells Cargo to pass the -L flag
to
the compiler to add a directory to the library search path.
The warning
instruction tells Cargo to display a warning after the build
script has finished running. Warnings are only shown for path dependencies
(that is, those you’re working on locally), so for example warnings printed
out in crates.io crates are not emitted by default. The -vv
“very verbose”
flag may be used to have Cargo display warnings for all crates.