Skip to content

Commit e4f5c60

Browse files
authored
Merge pull request #89 from madsmtm/docs-rs
Fix docs.rs setup
2 parents 792db09 + b62b51a commit e4f5c60

File tree

8 files changed

+65
-2
lines changed

8 files changed

+65
-2
lines changed

block-sys/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ objfw = []
4848

4949
[dependencies]
5050
objc-sys = { path = "../objc-sys", version = "0.1.0", optional = true }
51+
52+
[package.metadata.docs.rs]
53+
default-target = "x86_64-apple-darwin"

block2/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ license = "MIT"
2121
# Loose dependency, because objc2-encode is not expected to change much more
2222
objc2-encode = { path = "../objc2-encode", version = "^2.0.0-beta.0" }
2323
block-sys = { path = "../block-sys", version = "0.0.1" }
24+
25+
[package.metadata.docs.rs]
26+
default-target = "x86_64-apple-darwin"

objc-sys/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,20 @@ winobjc = ["gnustep-1-8"]
4646

4747
# TODO
4848
objfw = []
49+
50+
[package.metadata.docs.rs]
51+
default-target = "x86_64-apple-darwin"
52+
53+
targets = [
54+
# MacOS
55+
"x86_64-apple-darwin",
56+
"i686-apple-darwin",
57+
# iOS
58+
"aarch64-apple-ios",
59+
"x86_64-apple-ios",
60+
# GNUStep
61+
"x86_64-unknown-linux-gnu",
62+
"i686-unknown-linux-gnu",
63+
]
64+
65+
cargo-args = ["-Z", "build-std"]

objc-sys/build.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,16 @@ fn main() {
117117
unimplemented!()
118118
}
119119
(false, false, false) => {
120-
panic!("Must specify the desired runtime (using features) on non-apple platforms.")
120+
// Choose sensible defaults when generating docs
121+
if std::env::var("DOCS_RS").is_ok() {
122+
if target_os == "windows" {
123+
WinObjC
124+
} else {
125+
GNUStep(1, 7)
126+
}
127+
} else {
128+
panic!("Must specify the desired runtime (using features) on non-apple platforms.")
129+
}
121130
}
122131
_ => {
123132
panic!("Invalid feature combination; only one runtime may be selected!")
@@ -173,7 +182,8 @@ fn main() {
173182
(MacOS(_), _) => "macosx",
174183
(IOS(_), _) => "ios",
175184
(WatchOS(_), _) => "watchos",
176-
(TvOS(_), _) => "ios", // ??
185+
// tvOS doesn't have it's own -fobjc-runtime string
186+
(TvOS(_), _) => "ios",
177187
};
178188
match runtime {
179189
MacOS(version) | IOS(version) | WatchOS(version) | TvOS(version) => {

objc2-encode/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ readme = "README.md"
1717
repository = "https://github.com/madsmtm/objc2"
1818
documentation = "https://docs.rs/objc2-encode/"
1919
license = "MIT"
20+
21+
[package.metadata.docs.rs]
22+
default-target = "x86_64-apple-darwin"

objc2-foundation/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ block = ["block2"]
2828
block2 = { path = "../block2", version = "=0.2.0-alpha.1", optional = true }
2929
objc2 = { path = "../objc2", version = "=0.3.0-alpha.4" }
3030
objc-sys = { path = "../objc-sys", version = "0.1.0" }
31+
32+
[package.metadata.docs.rs]
33+
default-target = "x86_64-apple-darwin"

objc2/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,22 @@ objc2-encode = { path = "../objc2-encode", version = "^2.0.0-beta.0" }
3535

3636
[build-dependencies]
3737
cc = { version = "1", optional = true }
38+
39+
[package.metadata.docs.rs]
40+
default-target = "x86_64-apple-darwin"
41+
42+
features = ["exception"]
43+
44+
targets = [
45+
# MacOS
46+
"x86_64-apple-darwin",
47+
"i686-apple-darwin",
48+
# iOS
49+
"aarch64-apple-ios",
50+
"x86_64-apple-ios",
51+
# GNUStep
52+
"x86_64-unknown-linux-gnu",
53+
"i686-unknown-linux-gnu",
54+
]
55+
56+
cargo-args = ["-Z", "build-std"]

objc2/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ fn main() {
99

1010
#[cfg(feature = "exception")]
1111
{
12+
if std::env::var("DOCS_RS").is_ok() {
13+
// docs.rs doesn't have clang, so skip building this. The
14+
// documentation will still work since it doesn't need to link.
15+
return;
16+
}
1217
println!("cargo:rerun-if-changed=extern/exception.m");
1318

1419
let mut builder = cc::Build::new();

0 commit comments

Comments
 (0)