Skip to content

Commit cba6666

Browse files
committed
feat: add link feature
adjust docs Update cocoa/Cargo.toml Co-authored-by: Divy Srivastava <[email protected]> fmt
1 parent fbde503 commit cba6666

33 files changed

+65
-29
lines changed

cocoa-foundation/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ libc = "0.2"
1818
core-foundation = { path = "../core-foundation", version = "0.9" }
1919
core-graphics-types = { 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

+2-2
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

+5
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ core-foundation = { path = "../core-foundation", version = "0.9" }
2020
core-graphics = { 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

+2-2
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

+1-1
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

+3
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

+4-1
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

+5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ chrono = { version = "0.4", optional = true }
1919
uuid = { version = "0.5", optional = true }
2020

2121
[features]
22+
default = ["link"]
23+
2224
mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"] # backwards compatibility
2325
mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"] # enables new features
2426
with-chrono = ["chrono"]
2527
with-uuid = ["uuid"]
28+
# Disable to manually link. Enabled by default.
29+
link = ["core-foundation-sys/link"]
30+
2631

2732
[package.metadata.docs.rs]
2833
all-features = true

core-graphics-types/Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ bitflags = "1.0"
1212
core-foundation = { 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

+1-1
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(

core-graphics/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ authors = ["The Servo Project Developers"]
88
license = "MIT OR Apache-2.0"
99

1010
[features]
11-
default = []
11+
default = ["link"]
1212
elcapitan = []
1313
highsierra = []
14+
# Disable to manually link. Enabled by default.
15+
link = ["core-foundation/link", "core-graphics-types/link"]
1416

1517
[dependencies]
1618
bitflags = "1.0"

core-graphics/src/access.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl ScreenCaptureAccess {
1818
}
1919
}
2020

21-
#[link(name = "CoreGraphics", kind = "framework")]
21+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
2222
extern "C" {
2323
// Screen Capture Access
2424
fn CGRequestScreenCaptureAccess() -> boolean_t;

core-graphics/src/color.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl CGColor {
2828
}
2929
}
3030

31-
#[link(name = "CoreGraphics", kind = "framework")]
31+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
3232
extern "C" {
3333
fn CGColorCreateGenericRGB(
3434
red: CGFloat,

core-graphics/src/color_space.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl CGColorSpace {
5353
}
5454
}
5555

56-
#[link(name = "CoreGraphics", kind = "framework")]
56+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
5757
extern "C" {
5858
/// The Display P3 color space, created by Apple.
5959
pub static kCGColorSpaceDisplayP3: CFStringRef;

core-graphics/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ fn create_bitmap_context_test() {
615615
assert_eq!(255, data.bytes()[3]);
616616
}
617617

618-
#[link(name = "CoreGraphics", kind = "framework")]
618+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
619619
extern "C" {
620620
fn CGContextRetain(c: ::sys::CGContextRef) -> ::sys::CGContextRef;
621621
fn CGContextRelease(c: ::sys::CGContextRef);

core-graphics/src/data_provider.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn test_data_provider() {
153153
assert!(dropped.load(SeqCst))
154154
}
155155

156-
#[link(name = "CoreGraphics", kind = "framework")]
156+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
157157
extern "C" {
158158
fn CGDataProviderCopyData(provider: ::sys::CGDataProviderRef) -> CFDataRef;
159159
//fn CGDataProviderCreateDirect

core-graphics/src/display.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ impl CGDisplayMode {
640640
}
641641
}
642642

643-
#[link(name = "CoreGraphics", kind = "framework")]
643+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
644644
extern "C" {
645645
pub static CGRectNull: CGRect;
646646
pub static CGRectInfinite: CGRect;

core-graphics/src/event.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl CGEvent {
673673
}
674674
}
675675

676-
#[link(name = "CoreGraphics", kind = "framework")]
676+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
677677
extern "C" {
678678
/// Return the type identifier for the opaque type `CGEventRef'.
679679
fn CGEventGetTypeID() -> CFTypeID;

core-graphics/src/event_source.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl CGEventSource {
3636
}
3737
}
3838

39-
#[link(name = "CoreGraphics", kind = "framework")]
39+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
4040
extern "C" {
4141
/// Return the type identifier for the opaque type `CGEventSourceRef'.
4242
fn CGEventSourceGetTypeID() -> CFTypeID;

core-graphics/src/font.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl CGFont {
138138
}
139139
}
140140

141-
#[link(name = "CoreGraphics", kind = "framework")]
141+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
142142
extern "C" {
143143
// TODO: basically nothing has bindings (even commented-out) besides what we use.
144144
fn CGFontCreateWithDataProvider(provider: ::sys::CGDataProviderRef) -> ::sys::CGFontRef;

core-graphics/src/gradient.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl CGGradient {
7272
}
7373
}
7474

75-
#[link(name = "CoreGraphics", kind = "framework")]
75+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
7676
extern "C" {
7777
fn CGGradientCreateWithColorComponents(
7878
color_space: ::sys::CGColorSpaceRef,

core-graphics/src/image.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl CGImageRef {
125125
}
126126
}
127127

128-
#[link(name = "CoreGraphics", kind = "framework")]
128+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
129129
extern "C" {
130130
fn CGImageGetTypeID() -> CFTypeID;
131131
fn CGImageGetWidth(image: ::sys::CGImageRef) -> size_t;

core-graphics/src/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl CGPathElement {
125125

126126
type CGPathApplierFunction = unsafe extern "C" fn(info: *mut c_void, element: *const CGPathElement);
127127

128-
#[link(name = "CoreGraphics", kind = "framework")]
128+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
129129
extern "C" {
130130
fn CGPathCreateWithRect(rect: CGRect, transform: *const CGAffineTransform) -> ::sys::CGPathRef;
131131
fn CGPathApply(path: ::sys::CGPathRef, info: *mut c_void, function: CGPathApplierFunction);

core-graphics/src/private.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ mod ffi {
9696
pub type CGSRegionRef = *mut CGSRegionObject;
9797
pub type OSStatus = i32;
9898

99-
#[link(name = "CoreGraphics", kind = "framework")]
99+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
100100
extern "C" {
101101
pub fn CGSRegionRelease(region: CGSRegionRef);
102102
pub fn CGSNewRegionWithRect(rect: *const CGRect, outRegion: *mut CGSRegionRef) -> CGError;

core-graphics/src/window.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub fn create_image_from_array(
125125
}
126126
}
127127

128-
#[link(name = "CoreGraphics", kind = "framework")]
128+
#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))]
129129
extern "C" {
130130
pub static kCGWindowNumber: CFStringRef;
131131
pub static kCGWindowStoreType: CFStringRef;

core-text/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ all-features = true
1111
default-target = "x86_64-apple-darwin"
1212

1313
[features]
14-
default = ["mountainlion"]
14+
default = ["mountainlion", "link"]
1515
# For OS X 10.7 compat, exclude this feature. It will exclude some things from
1616
# the exposed APIs in the crate.
1717
mountainlion = []
18+
# Disable to manually link. Enabled by default.
19+
link = ["core-foundation/link", "core-graphics/link"]
1820

1921
[dependencies]
2022
foreign-types = "0.5"

core-text/src/font.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ pub fn cascade_list_for_languages(
594594
}
595595
}
596596

597-
#[link(name = "CoreText", kind = "framework")]
597+
#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))]
598598
extern "C" {
599599
/*
600600
* CTFont.h

core-text/src/frame.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl CTFrame {
8484
}
8585
}
8686

87-
#[link(name = "CoreText", kind = "framework")]
87+
#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))]
8888
extern "C" {
8989
fn CTFrameGetTypeID() -> CFTypeID;
9090
fn CTFrameGetLines(frame: CTFrameRef) -> CFArrayRef;

core-text/src/framesetter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl CTFramesetter {
7474
}
7575
}
7676

77-
#[link(name = "CoreText", kind = "framework")]
77+
#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))]
7878
extern "C" {
7979
fn CTFramesetterGetTypeID() -> CFTypeID;
8080
fn CTFramesetterCreateWithAttributedString(string: CFAttributedStringRef) -> CTFramesetterRef;

core-text/src/line.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl CTLine {
9191
}
9292
}
9393

94-
#[link(name = "CoreText", kind = "framework")]
94+
#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))]
9595
extern "C" {
9696
fn CTLineGetTypeID() -> CFTypeID;
9797
fn CTLineGetGlyphRuns(line: CTLineRef) -> CFArrayRef;

core-text/src/run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn create_runs() {
145145
}
146146
}
147147

148-
#[link(name = "CoreText", kind = "framework")]
148+
#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))]
149149
extern "C" {
150150
fn CTRunGetTypeID() -> CFTypeID;
151151
fn CTRunGetAttributes(run: CTRunRef) -> CFDictionaryRef;

io-surface/Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ core-foundation = { path = "../core-foundation", version = "0.9" }
1616
core-foundation-sys = { path = "../core-foundation-sys", version = "0.8" }
1717
cgl = "0.3"
1818
leaky-cow = "0.1.1"
19+
20+
[features]
21+
default = ["link"]
22+
# Disable to manually link. Enabled by default.
23+
link = ["core-foundation/link", "core-foundation-sys/link"]

io-surface/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl IOSurface {
166166
}
167167
}
168168

169-
#[link(name = "IOSurface", kind = "framework")]
169+
#[cfg_attr(feature = "link", link(name = "IOSurface", kind = "framework"))]
170170
extern "C" {
171171
pub static kIOSurfaceAllocSize: CFStringRef;
172172
pub static kIOSurfaceWidth: CFStringRef;

0 commit comments

Comments
 (0)