@@ -15,7 +15,7 @@ that script and execute it just before building the package.
15
15
// Example custom build script.
16
16
fn main() {
17
17
// Tell Cargo that if the given file changes, to rerun this build script.
18
- println!("cargo:rerun-if-changed=src/hello.c");
18
+ println!("cargo::metadata= rerun-if-changed=src/hello.c");
19
19
// Use the `cc` crate to build a C file and statically link it.
20
20
cc::Build::new()
21
21
.file("src/hello.c")
@@ -42,7 +42,7 @@ scripts.
42
42
Just before a package is built, Cargo will compile a build script into an
43
43
executable (if it has not already been built). It will then run the script,
44
44
which may perform any number of tasks. The script may communicate with Cargo
45
- by printing specially formatted commands prefixed with ` cargo: ` to stdout.
45
+ by printing specially formatted commands prefixed with ` cargo::metadata= ` to stdout.
46
46
47
47
The build script will be rebuilt if any of its source files or dependencies
48
48
change.
@@ -74,16 +74,16 @@ directory specified in the [`OUT_DIR` environment variable][build-env]. Scripts
74
74
should not modify any files outside of that directory.
75
75
76
76
Build scripts communicate with Cargo by printing to stdout. Cargo will
77
- interpret each line that starts with ` cargo: ` as an instruction that will
77
+ interpret each line that starts with ` cargo::metadata= ` as an instruction that will
78
78
influence compilation of the package. All other lines are ignored.
79
79
80
- > Note: The order of ` cargo: ` instructions printed by the build script * may*
80
+ > Note: The order of ` cargo::metadata= ` instructions printed by the build script * may*
81
81
> affect the order of arguments that ` cargo ` passes to ` rustc ` . In turn, the
82
82
> order of arguments passed to ` rustc ` may affect the order of arguments passed
83
83
> to the linker. Therefore, you will want to pay attention to the order of the
84
84
> build script's instructions. For example, if object ` foo ` needs to link against
85
85
> library ` bar ` , you may want to make sure that library ` bar ` 's
86
- > [ ` cargo:rustc-link-lib ` ] ( #rustc-link-lib ) instruction appears * after*
86
+ > [ ` cargo::metadata= rustc-link-lib ` ] ( #rustc-link-lib ) instruction appears * after*
87
87
> instructions to link object ` foo ` .
88
88
89
89
The output of the script is hidden from the terminal during normal
@@ -99,41 +99,41 @@ configuration). The stderr output is also saved in that same directory.
99
99
The following is a summary of the instructions that Cargo recognizes, with each
100
100
one detailed below.
101
101
102
- * [ ` cargo:rerun-if-changed=PATH ` ] ( #rerun-if-changed ) --- Tells Cargo when to
102
+ * [ ` cargo::metadata= rerun-if-changed=PATH ` ] ( #rerun-if-changed ) --- Tells Cargo when to
103
103
re-run the script.
104
- * [ ` cargo:rerun-if-env-changed=VAR ` ] ( #rerun-if-env-changed ) --- Tells Cargo when
104
+ * [ ` cargo::metadata= rerun-if-env-changed=VAR ` ] ( #rerun-if-env-changed ) --- Tells Cargo when
105
105
to re-run the script.
106
- * [ ` cargo:rustc-link-arg=FLAG ` ] ( #rustc-link-arg ) --- Passes custom flags to a
106
+ * [ ` cargo::metadata= rustc-link-arg=FLAG ` ] ( #rustc-link-arg ) --- Passes custom flags to a
107
107
linker for benchmarks, binaries, ` cdylib ` crates, examples, and tests.
108
- * [ ` cargo:rustc-link-arg-bin=BIN=FLAG ` ] ( #rustc-link-arg-bin ) --- Passes custom
108
+ * [ ` cargo::metadata= rustc-link-arg-bin=BIN=FLAG ` ] ( #rustc-link-arg-bin ) --- Passes custom
109
109
flags to a linker for the binary ` BIN ` .
110
- * [ ` cargo:rustc-link-arg-bins=FLAG ` ] ( #rustc-link-arg-bins ) --- Passes custom
110
+ * [ ` cargo::metadata= rustc-link-arg-bins=FLAG ` ] ( #rustc-link-arg-bins ) --- Passes custom
111
111
flags to a linker for binaries.
112
- * [ ` cargo:rustc-link-arg-tests=FLAG ` ] ( #rustc-link-arg-tests ) --- Passes custom
112
+ * [ ` cargo::metadata= rustc-link-arg-tests=FLAG ` ] ( #rustc-link-arg-tests ) --- Passes custom
113
113
flags to a linker for tests.
114
- * [ ` cargo:rustc-link-arg-examples=FLAG ` ] ( #rustc-link-arg-examples ) --- Passes custom
114
+ * [ ` cargo::metadata= rustc-link-arg-examples=FLAG ` ] ( #rustc-link-arg-examples ) --- Passes custom
115
115
flags to a linker for examples.
116
- * [ ` cargo:rustc-link-arg-benches=FLAG ` ] ( #rustc-link-arg-benches ) --- Passes custom
116
+ * [ ` cargo::metadata= rustc-link-arg-benches=FLAG ` ] ( #rustc-link-arg-benches ) --- Passes custom
117
117
flags to a linker for benchmarks.
118
- * [ ` cargo:rustc-link-lib=LIB ` ] ( #rustc-link-lib ) --- Adds a library to
118
+ * [ ` cargo::metadata= rustc-link-lib=LIB ` ] ( #rustc-link-lib ) --- Adds a library to
119
119
link.
120
- * [ ` cargo:rustc-link-search=[KIND=]PATH ` ] ( #rustc-link-search ) --- Adds to the
120
+ * [ ` cargo::metadata= rustc-link-search=[KIND=]PATH ` ] ( #rustc-link-search ) --- Adds to the
121
121
library search path.
122
- * [ ` cargo:rustc-flags=FLAGS ` ] ( #rustc-flags ) --- Passes certain flags to the
122
+ * [ ` cargo::metadata= rustc-flags=FLAGS ` ] ( #rustc-flags ) --- Passes certain flags to the
123
123
compiler.
124
- * [ ` cargo:rustc-cfg=KEY[="VALUE"] ` ] ( #rustc-cfg ) --- Enables compile-time ` cfg `
124
+ * [ ` cargo::metadata= rustc-cfg=KEY[="VALUE"] ` ] ( #rustc-cfg ) --- Enables compile-time ` cfg `
125
125
settings.
126
- * [ ` cargo:rustc-env=VAR=VALUE ` ] ( #rustc-env ) --- Sets an environment variable.
127
- * [ ` cargo:rustc-cdylib-link-arg=FLAG ` ] ( #rustc-cdylib-link-arg ) --- Passes custom
126
+ * [ ` cargo::metadata= rustc-env=VAR=VALUE ` ] ( #rustc-env ) --- Sets an environment variable.
127
+ * [ ` cargo::metadata= rustc-cdylib-link-arg=FLAG ` ] ( #rustc-cdylib-link-arg ) --- Passes custom
128
128
flags to a linker for cdylib crates.
129
- * [ ` cargo:warning=MESSAGE ` ] ( #cargo-warning ) --- Displays a warning on the
129
+ * [ ` cargo::metadata= warning=MESSAGE ` ] ( #cargo-warning ) --- Displays a warning on the
130
130
terminal.
131
- * [ ` cargo:KEY=VALUE ` ] ( #the-links-manifest-key ) --- Metadata, used by ` links `
131
+ * [ ` cargo::metadata= KEY=VALUE ` ] ( #the-links-manifest-key ) --- Metadata, used by ` links `
132
132
scripts.
133
133
134
134
135
135
<a id =" rustc-link-arg " ></a >
136
- #### ` cargo:rustc-link-arg=FLAG `
136
+ #### ` cargo::metadata= rustc-link-arg=FLAG `
137
137
138
138
The ` rustc-link-arg ` instruction tells Cargo to pass the [ ` -C link-arg=FLAG `
139
139
option] [ link-arg ] to the compiler, but only when building supported targets
@@ -144,7 +144,7 @@ linker script.
144
144
[ link-arg ] : ../../rustc/codegen-options/index.md#link-arg
145
145
146
146
<a id =" rustc-link-arg-bin " ></a >
147
- #### ` cargo:rustc-link-arg-bin=BIN=FLAG `
147
+ #### ` cargo::metadata= rustc-link-arg-bin=BIN=FLAG `
148
148
149
149
The ` rustc-link-arg-bin ` instruction tells Cargo to pass the [ `-C
150
150
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building
@@ -153,7 +153,7 @@ to set a linker script or other linker options.
153
153
154
154
155
155
<a id =" rustc-link-arg-bins " ></a >
156
- #### ` cargo:rustc-link-arg-bins=FLAG `
156
+ #### ` cargo::metadata= rustc-link-arg-bins=FLAG `
157
157
158
158
The ` rustc-link-arg-bins ` instruction tells Cargo to pass the [ `-C
159
159
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building a
@@ -162,7 +162,7 @@ to set a linker script or other linker options.
162
162
163
163
164
164
<a id =" rustc-link-lib " ></a >
165
- #### ` cargo:rustc-link-lib=LIB `
165
+ #### ` cargo::metadata= rustc-link-lib=LIB `
166
166
167
167
The ` rustc-link-lib ` instruction tells Cargo to link the given library using
168
168
the compiler's [ ` -l ` flag] [ option-link ] . This is typically used to link a
@@ -188,29 +188,29 @@ The optional `KIND` may be one of `dylib`, `static`, or `framework`. See the
188
188
189
189
190
190
<a id =" rustc-link-arg-tests " ></a >
191
- #### ` cargo:rustc-link-arg-tests=FLAG `
191
+ #### ` cargo::metadata= rustc-link-arg-tests=FLAG `
192
192
193
193
The ` rustc-link-arg-tests ` instruction tells Cargo to pass the [ `-C
194
194
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building a
195
195
tests target.
196
196
197
197
198
198
<a id =" rustc-link-arg-examples " ></a >
199
- #### ` cargo:rustc-link-arg-examples=FLAG `
199
+ #### ` cargo::metadata= rustc-link-arg-examples=FLAG `
200
200
201
201
The ` rustc-link-arg-examples ` instruction tells Cargo to pass the [ `-C
202
202
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building an examples
203
203
target.
204
204
205
205
<a id =" rustc-link-arg-benches " ></a >
206
- #### ` cargo:rustc-link-arg-benches=FLAG `
206
+ #### ` cargo::metadata= rustc-link-arg-benches=FLAG `
207
207
208
208
The ` rustc-link-arg-benches ` instruction tells Cargo to pass the [ `-C
209
209
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building a benchmark
210
210
target.
211
211
212
212
<a id =" rustc-link-search " ></a >
213
- #### ` cargo:rustc-link-search=[KIND=]PATH `
213
+ #### ` cargo::metadata= rustc-link-search=[KIND=]PATH `
214
214
215
215
The ` rustc-link-search ` instruction tells Cargo to pass the [ ` -L `
216
216
flag] [ option-search ] to the compiler to add a directory to the library search
@@ -229,15 +229,15 @@ is fine).
229
229
[ option-search ] : ../../rustc/command-line-arguments.md#option-l-search-path
230
230
231
231
<a id =" rustc-flags " ></a >
232
- #### ` cargo:rustc-flags=FLAGS `
232
+ #### ` cargo::metadata= rustc-flags=FLAGS `
233
233
234
234
The ` rustc-flags ` instruction tells Cargo to pass the given space-separated
235
235
flags to the compiler. This only allows the ` -l ` and ` -L ` flags, and is
236
236
equivalent to using [ ` rustc-link-lib ` ] ( #rustc-link-lib ) and
237
237
[ ` rustc-link-search ` ] ( #rustc-link-search ) .
238
238
239
239
<a id =" rustc-cfg " ></a >
240
- #### ` cargo:rustc-cfg=KEY[="VALUE"] `
240
+ #### ` cargo::metadata= rustc-cfg=KEY[="VALUE"] `
241
241
242
242
The ` rustc-cfg ` instruction tells Cargo to pass the given value to the
243
243
[ ` --cfg ` flag] [ option-cfg ] to the compiler. This may be used for compile-time
@@ -249,17 +249,17 @@ used to enable an optional dependency, or enable other Cargo features.
249
249
Be aware that [ Cargo features] use the form ` feature="foo" ` . ` cfg ` values
250
250
passed with this flag are not restricted to that form, and may provide just a
251
251
single identifier, or any arbitrary key/value pair. For example, emitting
252
- ` cargo:rustc-cfg=abc ` will then allow code to use ` #[cfg(abc)] ` (note the lack
252
+ ` cargo::metadata= rustc-cfg=abc ` will then allow code to use ` #[cfg(abc)] ` (note the lack
253
253
of ` feature= ` ). Or an arbitrary key/value pair may be used with an ` = ` symbol
254
- like ` cargo:rustc-cfg=my_component="foo" ` . The key should be a Rust
254
+ like ` cargo::metadata= rustc-cfg=my_component="foo" ` . The key should be a Rust
255
255
identifier, the value should be a string.
256
256
257
257
[ cargo features ] : features.md
258
258
[ conditional compilation ] : ../../reference/conditional-compilation.md
259
259
[ option-cfg ] : ../../rustc/command-line-arguments.md#option-cfg
260
260
261
261
<a id =" rustc-env " ></a >
262
- #### ` cargo:rustc-env=VAR=VALUE `
262
+ #### ` cargo::metadata= rustc-env=VAR=VALUE `
263
263
264
264
The ` rustc-env ` instruction tells Cargo to set the given environment variable
265
265
when compiling the package. The value can be then retrieved by the [ ` env! `
@@ -280,7 +280,7 @@ Cargo][env-cargo].
280
280
[ env-cargo ] : environment-variables.md#environment-variables-cargo-sets-for-crates
281
281
282
282
<a id =" rustc-cdylib-link-arg " ></a >
283
- #### ` cargo:rustc-cdylib-link-arg=FLAG `
283
+ #### ` cargo::metadata= rustc-cdylib-link-arg=FLAG `
284
284
285
285
The ` rustc-cdylib-link-arg ` instruction tells Cargo to pass the [ `-C
286
286
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building a
@@ -289,7 +289,7 @@ to set the shared library version or the runtime-path.
289
289
290
290
291
291
<a id =" cargo-warning " ></a >
292
- #### ` cargo:warning=MESSAGE `
292
+ #### ` cargo::metadata= warning=MESSAGE `
293
293
294
294
The ` warning ` instruction tells Cargo to display a warning after the build
295
295
script has finished running. Warnings are only shown for ` path ` dependencies
@@ -335,7 +335,7 @@ FAQ](../faq.md#why-is-cargo-rebuilding-my-code).
335
335
[ `exclude` and `include` fields ] : manifest.md#the-exclude-and-include-fields
336
336
337
337
<a id =" rerun-if-changed " ></a >
338
- #### ` cargo:rerun-if-changed=PATH `
338
+ #### ` cargo::metadata= rerun-if-changed=PATH `
339
339
340
340
The ` rerun-if-changed ` instruction tells Cargo to re-run the build script if
341
341
the file at the given path has changed. Currently, Cargo only uses the
@@ -347,15 +347,15 @@ If the path points to a directory, it will scan the entire directory for
347
347
any modifications.
348
348
349
349
If the build script inherently does not need to re-run under any circumstance,
350
- then emitting ` cargo:rerun-if-changed=build.rs ` is a simple way to prevent it
350
+ then emitting ` cargo::metadata= rerun-if-changed=build.rs ` is a simple way to prevent it
351
351
from being re-run (otherwise, the default if no ` rerun-if ` instructions are
352
352
emitted is to scan the entire package directory for changes). Cargo
353
353
automatically handles whether or not the script itself needs to be recompiled,
354
354
and of course the script will be re-run after it has been recompiled.
355
355
Otherwise, specifying ` build.rs ` is redundant and unnecessary.
356
356
357
357
<a id =" rerun-if-env-changed " ></a >
358
- #### ` cargo:rerun-if-env-changed=NAME `
358
+ #### ` cargo::metadata= rerun-if-env-changed=NAME `
359
359
360
360
The ` rerun-if-env-changed ` instruction tells Cargo to re-run the build script
361
361
if the value of an environment variable of the given name has changed.
0 commit comments