@@ -34,7 +34,7 @@ The sections below describe how build scripts work, and the [examples
34
34
chapter] ( build-script-examples.md ) shows a variety of examples on how to write
35
35
scripts.
36
36
37
- > Note: The [ ` package.build ` manifest key] ( manifest.md#package -build ) can be
37
+ > Note: The [ ` package.build ` manifest key] ( manifest.md#the -build-field ) can be
38
38
> used to change the name of the build script, or disable it entirely.
39
39
40
40
### Life Cycle of a Build Script
@@ -132,8 +132,7 @@ one detailed below.
132
132
scripts.
133
133
134
134
135
- <a id =" rustc-link-arg " ></a >
136
- #### ` cargo:rustc-link-arg=FLAG `
135
+ #### ` cargo:rustc-link-arg=FLAG ` {#rustc-link-arg}
137
136
138
137
The ` rustc-link-arg ` instruction tells Cargo to pass the [ ` -C link-arg=FLAG `
139
138
option] [ link-arg ] to the compiler, but only when building supported targets
@@ -143,26 +142,23 @@ linker script.
143
142
144
143
[ link-arg ] : ../../rustc/codegen-options/index.md#link-arg
145
144
146
- <a id =" rustc-link-arg-bin " ></a >
147
- #### ` cargo:rustc-link-arg-bin=BIN=FLAG `
145
+ #### ` cargo:rustc-link-arg-bin=BIN=FLAG ` {#rustc-link-arg-bin}
148
146
149
147
The ` rustc-link-arg-bin ` instruction tells Cargo to pass the [ `-C
150
148
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building
151
149
the binary target with name ` BIN ` . Its usage is highly platform specific. It is useful
152
150
to set a linker script or other linker options.
153
151
154
152
155
- <a id =" rustc-link-arg-bins " ></a >
156
- #### ` cargo:rustc-link-arg-bins=FLAG `
153
+ #### ` cargo:rustc-link-arg-bins=FLAG ` {#rustc-link-arg-bins}
157
154
158
155
The ` rustc-link-arg-bins ` instruction tells Cargo to pass the [ `-C
159
156
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building a
160
157
binary target. Its usage is highly platform specific. It is useful
161
158
to set a linker script or other linker options.
162
159
163
160
164
- <a id =" rustc-link-lib " ></a >
165
- #### ` cargo:rustc-link-lib=LIB `
161
+ #### ` cargo:rustc-link-lib=LIB ` {#rustc-link-lib}
166
162
167
163
The ` rustc-link-lib ` instruction tells Cargo to link the given library using
168
164
the compiler's [ ` -l ` flag] [ option-link ] . This is typically used to link a
@@ -187,30 +183,26 @@ The optional `KIND` may be one of `dylib`, `static`, or `framework`. See the
187
183
[ FFI ] : ../../nomicon/ffi.md
188
184
189
185
190
- <a id =" rustc-link-arg-tests " ></a >
191
- #### ` cargo:rustc-link-arg-tests=FLAG `
186
+ #### ` cargo:rustc-link-arg-tests=FLAG ` {#rustc-link-arg-tests}
192
187
193
188
The ` rustc-link-arg-tests ` instruction tells Cargo to pass the [ `-C
194
189
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building a
195
190
tests target.
196
191
197
192
198
- <a id =" rustc-link-arg-examples " ></a >
199
- #### ` cargo:rustc-link-arg-examples=FLAG `
193
+ #### ` cargo:rustc-link-arg-examples=FLAG ` {#rustc-link-arg-examples}
200
194
201
195
The ` rustc-link-arg-examples ` instruction tells Cargo to pass the [ `-C
202
196
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building an examples
203
197
target.
204
198
205
- <a id =" rustc-link-arg-benches " ></a >
206
- #### ` cargo:rustc-link-arg-benches=FLAG `
199
+ #### ` cargo:rustc-link-arg-benches=FLAG ` {#rustc-link-arg-benches}
207
200
208
201
The ` rustc-link-arg-benches ` instruction tells Cargo to pass the [ `-C
209
202
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building a benchmark
210
203
target.
211
204
212
- <a id =" rustc-link-search " ></a >
213
- #### ` cargo:rustc-link-search=[KIND=]PATH `
205
+ #### ` cargo:rustc-link-search=[KIND=]PATH ` {#rustc-link-search}
214
206
215
207
The ` rustc-link-search ` instruction tells Cargo to pass the [ ` -L `
216
208
flag] [ option-search ] to the compiler to add a directory to the library search
@@ -228,16 +220,14 @@ is fine).
228
220
229
221
[ option-search ] : ../../rustc/command-line-arguments.md#option-l-search-path
230
222
231
- <a id =" rustc-flags " ></a >
232
- #### ` cargo:rustc-flags=FLAGS `
223
+ #### ` cargo:rustc-flags=FLAGS ` {#rustc-flags}
233
224
234
225
The ` rustc-flags ` instruction tells Cargo to pass the given space-separated
235
226
flags to the compiler. This only allows the ` -l ` and ` -L ` flags, and is
236
227
equivalent to using [ ` rustc-link-lib ` ] ( #rustc-link-lib ) and
237
228
[ ` rustc-link-search ` ] ( #rustc-link-search ) .
238
229
239
- <a id =" rustc-cfg " ></a >
240
- #### ` cargo:rustc-cfg=KEY[="VALUE"] `
230
+ #### ` cargo:rustc-cfg=KEY[="VALUE"] ` {#rustc-cfg}
241
231
242
232
The ` rustc-cfg ` instruction tells Cargo to pass the given value to the
243
233
[ ` --cfg ` flag] [ option-cfg ] to the compiler. This may be used for compile-time
@@ -258,8 +248,7 @@ identifier, the value should be a string.
258
248
[ conditional compilation ] : ../../reference/conditional-compilation.md
259
249
[ option-cfg ] : ../../rustc/command-line-arguments.md#option-cfg
260
250
261
- <a id =" rustc-env " ></a >
262
- #### ` cargo:rustc-env=VAR=VALUE `
251
+ #### ` cargo:rustc-env=VAR=VALUE ` {#rustc-env}
263
252
264
253
The ` rustc-env ` instruction tells Cargo to set the given environment variable
265
254
when compiling the package. The value can be then retrieved by the [ ` env! `
@@ -279,17 +268,15 @@ Cargo][env-cargo].
279
268
[ env-macro ] : ../../std/macro.env.html
280
269
[ env-cargo ] : environment-variables.md#environment-variables-cargo-sets-for-crates
281
270
282
- <a id =" rustc-cdylib-link-arg " ></a >
283
- #### ` cargo:rustc-cdylib-link-arg=FLAG `
271
+ #### ` cargo:rustc-cdylib-link-arg=FLAG ` {#rustc-cdylib-link-arg}
284
272
285
273
The ` rustc-cdylib-link-arg ` instruction tells Cargo to pass the [ `-C
286
274
link-arg=FLAG` option] [ link-arg ] to the compiler, but only when building a
287
275
` cdylib ` library target. Its usage is highly platform specific. It is useful
288
276
to set the shared library version or the runtime-path.
289
277
290
278
291
- <a id =" cargo-warning " ></a >
292
- #### ` cargo:warning=MESSAGE `
279
+ #### ` cargo:warning=MESSAGE ` {#cargo-warning}
293
280
294
281
The ` warning ` instruction tells Cargo to display a warning after the build
295
282
script has finished running. Warnings are only shown for ` path ` dependencies
@@ -334,8 +321,7 @@ FAQ](../faq.md#why-is-cargo-rebuilding-my-code).
334
321
335
322
[ `exclude` and `include` fields ] : manifest.md#the-exclude-and-include-fields
336
323
337
- <a id =" rerun-if-changed " ></a >
338
- #### ` cargo:rerun-if-changed=PATH `
324
+ #### ` cargo:rerun-if-changed=PATH ` {#rerun-if-changed}
339
325
340
326
The ` rerun-if-changed ` instruction tells Cargo to re-run the build script if
341
327
the file at the given path has changed. Currently, Cargo only uses the
@@ -354,8 +340,7 @@ automatically handles whether or not the script itself needs to be recompiled,
354
340
and of course the script will be re-run after it has been recompiled.
355
341
Otherwise, specifying ` build.rs ` is redundant and unnecessary.
356
342
357
- <a id =" rerun-if-env-changed " ></a >
358
- #### ` cargo:rerun-if-env-changed=NAME `
343
+ #### ` cargo:rerun-if-env-changed=NAME ` {#rerun-if-env-changed}
359
344
360
345
The ` rerun-if-env-changed ` instruction tells Cargo to re-run the build script
361
346
if the value of an environment variable of the given name has changed.
0 commit comments