Skip to content

Commit b8a54e5

Browse files
committed
Specify the "links" key in objc_sys
Makes it possible for downstream users to customize the linking to libobjc, see https://doc.rust-lang.org/cargo/reference/build-scripts.html#overriding-build-scripts
1 parent 9028470 commit b8a54e5

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

objc_sys/Cargo.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "objc_sys"
3-
version = "0.0.0"
3+
version = "0.0.0" # Remember to update html_root_url in lib.rs
44
authors = ["Mads Marquart <[email protected]>"]
55
edition = "2018"
66

@@ -13,3 +13,14 @@ categories = [
1313
repository = "https://github.com/madsmtm/objc"
1414
documentation = "https://docs.rs/objc_sys/"
1515
license = "MIT"
16+
17+
exclude = [
18+
# Used to help developers track changes by running bindgen against
19+
# different revisions of Apple's open source `objc4`.
20+
"helper-scripts/*",
21+
]
22+
23+
# Downstream users can customize the linking to libobjc!
24+
# See https://doc.rust-lang.org/cargo/reference/build-scripts.html#overriding-build-scripts
25+
links = "objc"
26+
build = "build.rs"

objc_sys/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn main() {
2+
println!("cargo:rerun-if-changed=build.rs");
3+
println!("cargo:rustc-link-lib=dylib=objc");
4+
5+
// TODO: Should we vendor GNUStep's libobjc2 on non-apple targets?
6+
// Check std::env::env::var("CARGO_CFG_TARGET_VENDOR").unwrap()
7+
// Cargo.toml:
8+
// [target.'cfg(not(target_vendor = "apple"))'.build-dependencies]
9+
// cc = "1.0"
10+
}

objc_sys/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
//! Protocol / objc_protocol is no longer a type alias of objc_object, for
66
//! better type safety. Their internal representation is the same, so the
77
//! functionality is just a cast away.
8+
//!
9+
//! Deprecated functions are not included since they could be removed at any
10+
//! macOS release, and then our code would break.
811
912
// TODO: Replace `extern "C"` with `extern "C-unwind"`.
1013

1114
#![no_std]
1215
#![allow(non_camel_case_types)]
1316
#![allow(non_upper_case_globals)]
14-
// Update in Cargo.toml as well.
15-
#![doc(html_root_url = "https://docs.rs/objc_sys/1.1.0")]
17+
#![doc(html_root_url = "https://docs.rs/objc_sys/0.0.0")]
1618

19+
// TODO: Remove this and add "no-std" category to Cargo.toml
1720
extern crate std;
1821

1922
use core::cell::UnsafeCell;
@@ -52,6 +55,3 @@ pub use various::*;
5255
///
5356
/// TODO: Replace this with `extern type` to also mark it as unsized.
5457
type OpaqueData = PhantomData<(UnsafeCell<*const ()>, PhantomPinned)>;
55-
56-
#[link(name = "objc", kind = "dylib")]
57-
extern "C" {}

0 commit comments

Comments
 (0)