Skip to content

Commit

Permalink
Auto merge of #7623 - ehuss:doc-target-json-dep, r=alexcrichton
Browse files Browse the repository at this point in the history
Update documentation for custom target dependencies.

Closes #7613.

The old documentation was wrong, and hasn't worked for some time. It needs to be the file stem (see issue for discussion).

I also added a test, since I couldn't find any.  It was remarkably awkward to add the test without build-std, so I just added it to a build-std test.
  • Loading branch information
bors committed Nov 22, 2019
2 parents 579174c + 285dc31 commit b50ef2f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/doc/src/reference/specifying-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,20 +483,16 @@ winhttp = "0.4.0"
openssl = "1.0.1"
```

If you’re using a custom target specification, quote the full path and file
name:
If you’re using a custom target specification (such as `--target
foo/bar.json`), use the base filename without the `.json` extension:

```toml
[target."x86_64/windows.json".dependencies]
[target.bar.dependencies]
winhttp = "0.4.0"

[target."i686/linux.json".dependencies]
[target.my-special-i686-platform.dependencies]
openssl = "1.0.1"
native = { path = "native/i686" }

[target."x86_64/linux.json".dependencies]
openssl = "1.0.1"
native = { path = "native/x86_64" }
```

### Development dependencies
Expand Down
19 changes: 18 additions & 1 deletion tests/build-std/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,24 @@ fn basic() {
#[cargo_test(build_std)]
fn cross_custom() {
let p = project()
.file("src/lib.rs", "#![no_std] pub fn f() {}")
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[target.custom-target.dependencies]
dep = { path = "dep" }
"#,
)
.file(
"src/lib.rs",
"#![no_std] pub fn f() -> u32 { dep::answer() }",
)
.file("dep/Cargo.toml", &basic_manifest("dep", "0.1.0"))
.file("dep/src/lib.rs", "#![no_std] pub fn answer() -> u32 { 42 }")
.file(
"custom-target.json",
r#"
Expand Down

0 comments on commit b50ef2f

Please sign in to comment.