Skip to content

Commit 6d1758d

Browse files
committed
auto merge of #894 : alexcrichton/cargo/issue-888, r=brson
2 parents d14394b + a181779 commit 6d1758d

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/doc/build-script.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ are interpreted by Cargo and must be of the form `key=value`.
7575

7676
Example output:
7777

78-
```
78+
```notrust
7979
cargo:rustc-flags=-l foo:static -L /path/to/foo
8080
cargo:root=/path/to/foo
8181
cargo:libdir=/path/to/foo/lib
@@ -205,7 +205,7 @@ build = "build.rs"
205205
Here we can se we've got a build script specified which we'll use to generate
206206
some code. Let's see what's inside the build script:
207207

208-
```
208+
```rust,no_run
209209
// build.rs
210210
211211
use std::os;
@@ -235,7 +235,7 @@ There's a couple of points of note here:
235235

236236
Next, let's peek at the library itself:
237237

238-
```
238+
```rust,ignore
239239
// src/main.rs
240240
241241
include!(concat!(env!("OUT_DIR"), "/hello.rs"))
@@ -290,7 +290,7 @@ build = "build.rs"
290290
For now we're not going to use any build dependencies, so let's take a look at
291291
the build script now:
292292

293-
```rust
293+
```rust,no_run
294294
// build.rs
295295
296296
use std::io::Command;
@@ -301,18 +301,12 @@ fn main() {
301301
302302
// note that there are a number of downsides to this approach, the comments
303303
// 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"])
307305
.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();
316310
317311
println!("cargo:rustc-flags=-L {} -l hello:static", out_dir);
318312
}
@@ -337,7 +331,7 @@ Not to fear, though, this is where a `build-dependencies` entry would help! The
337331
Cargo ecosystem has a number of packages to make this sort of task much easier,
338332
portable, and standardized. For example, the build script could be written as:
339333

340-
```rust
334+
```rust,ignore
341335
// build.rs
342336
343337
// Bring in a dependency on an externally maintained `cc` package which manages
@@ -378,7 +372,7 @@ void hello() {
378372
}
379373
```
380374

381-
```rust
375+
```rust,ignore
382376
// src/main.rs
383377
384378
// Note the lack of the `#[link]` attribute. We're delegating the responsibility

0 commit comments

Comments
 (0)