Skip to content

Commit b50ef2f

Browse files
committed
Auto merge of #7623 - ehuss:doc-target-json-dep, r=alexcrichton
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.
2 parents 579174c + 285dc31 commit b50ef2f

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/doc/src/reference/specifying-dependencies.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,20 +483,16 @@ winhttp = "0.4.0"
483483
openssl = "1.0.1"
484484
```
485485

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

489489
```toml
490-
[target."x86_64/windows.json".dependencies]
490+
[target.bar.dependencies]
491491
winhttp = "0.4.0"
492492

493-
[target."i686/linux.json".dependencies]
493+
[target.my-special-i686-platform.dependencies]
494494
openssl = "1.0.1"
495495
native = { path = "native/i686" }
496-
497-
[target."x86_64/linux.json".dependencies]
498-
openssl = "1.0.1"
499-
native = { path = "native/x86_64" }
500496
```
501497

502498
### Development dependencies

tests/build-std/main.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,24 @@ fn basic() {
114114
#[cargo_test(build_std)]
115115
fn cross_custom() {
116116
let p = project()
117-
.file("src/lib.rs", "#![no_std] pub fn f() {}")
117+
.file(
118+
"Cargo.toml",
119+
r#"
120+
[package]
121+
name = "foo"
122+
version = "0.1.0"
123+
edition = "2018"
124+
125+
[target.custom-target.dependencies]
126+
dep = { path = "dep" }
127+
"#,
128+
)
129+
.file(
130+
"src/lib.rs",
131+
"#![no_std] pub fn f() -> u32 { dep::answer() }",
132+
)
133+
.file("dep/Cargo.toml", &basic_manifest("dep", "0.1.0"))
134+
.file("dep/src/lib.rs", "#![no_std] pub fn answer() -> u32 { 42 }")
118135
.file(
119136
"custom-target.json",
120137
r#"

0 commit comments

Comments
 (0)