@@ -75,7 +75,7 @@ are interpreted by Cargo and must be of the form `key=value`.
75
75
76
76
Example output:
77
77
78
- ```
78
+ ``` notrust
79
79
cargo:rustc-flags=-l foo:static -L /path/to/foo
80
80
cargo:root=/path/to/foo
81
81
cargo:libdir=/path/to/foo/lib
@@ -205,7 +205,7 @@ build = "build.rs"
205
205
Here we can se we've got a build script specified which we'll use to generate
206
206
some code. Let's see what's inside the build script:
207
207
208
- ```
208
+ ``` rust,no_run
209
209
// build.rs
210
210
211
211
use std::os;
@@ -235,7 +235,7 @@ There's a couple of points of note here:
235
235
236
236
Next, let's peek at the library itself:
237
237
238
- ```
238
+ ``` rust,ignore
239
239
// src/main.rs
240
240
241
241
include!(concat!(env!("OUT_DIR"), "/hello.rs"))
@@ -290,7 +290,7 @@ build = "build.rs"
290
290
For now we're not going to use any build dependencies, so let's take a look at
291
291
the build script now:
292
292
293
- ``` rust
293
+ ``` rust,no_run
294
294
// build.rs
295
295
296
296
use std::io::Command;
@@ -301,18 +301,12 @@ fn main() {
301
301
302
302
// note that there are a number of downsides to this approach, the comments
303
303
// below detail how to improve the portability of these commands.
304
- Command :: new (" gcc" ). arg (" src/hello.c" )
305
- . arg (" -c" )
306
- . arg (" -o" )
304
+ Command::new("gcc").args(&["src/hello.c", "-c", "-o"])
307
305
.arg(format!("{}/hello.o", out_dir))
308
- . status ()
309
- . unwrap ();
310
- Command :: new (" ar" ). arg (" crus" )
311
- . arg (" libhello.a" )
312
- . arg (" hello.o" )
313
- . cwd (& out_dir )
314
- . status ()
315
- . unwrap ();
306
+ .status().unwrap();
307
+ Command::new("ar").args(&["crus", "libhello.a", "hello.o"])
308
+ .cwd(&Path::new(&out_dir))
309
+ .status().unwrap();
316
310
317
311
println!("cargo:rustc-flags=-L {} -l hello:static", out_dir);
318
312
}
@@ -337,7 +331,7 @@ Not to fear, though, this is where a `build-dependencies` entry would help! The
337
331
Cargo ecosystem has a number of packages to make this sort of task much easier,
338
332
portable, and standardized. For example, the build script could be written as:
339
333
340
- ``` rust
334
+ ``` rust,ignore
341
335
// build.rs
342
336
343
337
// Bring in a dependency on an externally maintained `cc` package which manages
@@ -378,7 +372,7 @@ void hello() {
378
372
}
379
373
```
380
374
381
- ``` rust
375
+ ``` rust,ignore
382
376
// src/main.rs
383
377
384
378
// Note the lack of the `#[link]` attribute. We're delegating the responsibility
0 commit comments