Skip to content

Commit c4f4ad2

Browse files
authored
feat: add link feature (#608)
adjust docs Update cocoa/Cargo.toml Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com> fmt
1 parent fbde503 commit c4f4ad2

File tree

33 files changed

+78
-41
lines changed

33 files changed

+78
-41
lines changed

cocoa-foundation/Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ default-target = "x86_64-apple-darwin"
1515
block = "0.1"
1616
bitflags = "1.0"
1717
libc = "0.2"
18-
core-foundation = { path = "../core-foundation", version = "0.9" }
19-
core-graphics-types = { path = "../core-graphics-types", version = "0.1" }
18+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
19+
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.1" }
2020
objc = "0.2.3"
21+
22+
[features]
23+
default = ["link"]
24+
# Disable to manually link. Enabled by default.
25+
link = ["core-foundation/link", "core-graphics-types/link"]
26+

cocoa-foundation/src/foundation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ mod macos {
132132
NSRectMaxYEdge,
133133
}
134134

135-
#[link(name = "Foundation", kind = "framework")]
135+
#[cfg_attr(feature = "link", link(name = "Foundation", kind = "framework"))]
136136
extern "C" {
137137
fn NSInsetRect(rect: NSRect, x: CGFloat, y: CGFloat) -> NSRect;
138138
}
@@ -167,7 +167,7 @@ impl NSRange {
167167
}
168168
}
169169

170-
#[link(name = "Foundation", kind = "framework")]
170+
#[cfg_attr(feature = "link", link(name = "Foundation", kind = "framework"))]
171171
extern "C" {
172172
pub static NSDefaultRunLoopMode: id;
173173
}

cocoa/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ default-target = "x86_64-apple-darwin"
1515
block = "0.1"
1616
bitflags = "1.0"
1717
libc = "0.2"
18-
cocoa-foundation = { path = "../cocoa-foundation", version = "0.1" }
19-
core-foundation = { path = "../core-foundation", version = "0.9" }
20-
core-graphics = { path = "../core-graphics", version = "0.23" }
18+
cocoa-foundation = { default-features = false, path = "../cocoa-foundation", version = "0.1" }
19+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
20+
core-graphics = { default-features = false, path = "../core-graphics", version = "0.23" }
2121
foreign-types = "0.5"
2222
objc = "0.2.3"
23+
24+
[features]
25+
default = ["link"]
26+
# Disable to manually link. Enabled by default.
27+
link = ["core-foundation/link", "cocoa-foundation/link", "core-graphics/link"]

cocoa/src/appkit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub type CGLContextObj = *mut c_void;
3131

3232
pub type GLint = i32;
3333

34-
#[link(name = "AppKit", kind = "framework")]
34+
#[cfg_attr(feature = "link", link(name = "AppKit", kind = "framework"))]
3535
extern "C" {
3636
pub static NSAppKitVersionNumber: f64;
3737

@@ -3836,7 +3836,7 @@ impl NSImage for id {
38363836
}
38373837
}
38383838

3839-
#[link(name = "AppKit", kind = "framework")]
3839+
#[cfg_attr(feature = "link", link(name = "AppKit", kind = "framework"))]
38403840
extern "C" {
38413841
// Image hints (NSString* const)
38423842
pub static NSImageHintCTM: id;

cocoa/src/quartzcore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ impl CATransform3D {
15721572
}
15731573
}
15741574

1575-
#[link(name = "QuartzCore", kind = "framework")]
1575+
#[cfg_attr(feature = "link", link(name = "QuartzCore", kind = "framework"))]
15761576
extern "C" {
15771577
static kCARendererColorSpace: CFStringRef;
15781578
static kCARendererMetalCommandQueue: CFStringRef;

core-foundation-sys/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ license = "MIT OR Apache-2.0"
1010
[dependencies]
1111

1212
[features]
13+
default = ["link"]
1314
mac_os_10_7_support = [] # backwards compatibility
1415
mac_os_10_8_features = [] # enables new features
16+
# Disable to manually link. Enabled by default.
17+
link = []
1518

1619
[package.metadata.docs.rs]
1720
all-features = true

core-foundation-sys/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
// We don't use `target_vendor` since that is going to be deprecated:
2323
// https://github.com/rust-lang/lang-team/issues/102
2424
#[cfg_attr(
25-
any(target_os = "macos", target_os = "ios", target_os = "tvos"),
25+
all(
26+
any(target_os = "macos", target_os = "ios", target_os = "tvos"),
27+
feature = "link"
28+
),
2629
link(name = "CoreFoundation", kind = "framework")
2730
)]
2831
extern "C" {}

core-foundation/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ keywords = ["macos", "framework", "objc"]
1111

1212
[dependencies.core-foundation-sys]
1313
path = "../core-foundation-sys"
14+
default-features = false
1415
version = "0.8.5"
1516

1617
[dependencies]
@@ -19,10 +20,15 @@ chrono = { version = "0.4", optional = true }
1920
uuid = { version = "0.5", optional = true }
2021

2122
[features]
23+
default = ["link"]
24+
2225
mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"] # backwards compatibility
2326
mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"] # enables new features
2427
with-chrono = ["chrono"]
2528
with-uuid = ["uuid"]
29+
# Disable to manually link. Enabled by default.
30+
link = ["core-foundation-sys/link"]
31+
2632

2733
[package.metadata.docs.rs]
2834
all-features = true

core-graphics-types/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ license = "MIT OR Apache-2.0"
99

1010
[dependencies]
1111
bitflags = "1.0"
12-
core-foundation = { path = "../core-foundation", version = "0.9" }
12+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
1313
libc = "0.2"
1414

15+
[features]
16+
default = ["link"]
17+
# Disable to manually link. Enabled by default.
18+
link = ["core-foundation/link"]
19+
1520
[package.metadata.docs.rs]
1621
default-target = "x86_64-apple-darwin"

core-graphics-types/src/geometry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ mod ffi {
166166
use core_foundation::dictionary::CFDictionaryRef;
167167
use geometry::{CGAffineTransform, CGPoint, CGRect, CGSize};
168168

169-
#[link(name = "CoreGraphics", kind = "framework")]
169+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
170170
extern "C" {
171171
pub fn CGRectInset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect;
172172
pub fn CGRectMakeWithDictionaryRepresentation(

0 commit comments

Comments
 (0)