diff --git a/cocoa-foundation/Cargo.toml b/cocoa-foundation/Cargo.toml index e247c752..81ac4e6f 100644 --- a/cocoa-foundation/Cargo.toml +++ b/cocoa-foundation/Cargo.toml @@ -18,3 +18,9 @@ libc = "0.2" core-foundation = { path = "../core-foundation", version = "0.9" } core-graphics-types = { path = "../core-graphics-types", version = "0.1" } objc = "0.2.3" + +[features] +default = ["link"] +# Disable to manually link. Enabled by default. +link = ["core-foundation/link", "core-graphics-types/link"] + diff --git a/cocoa-foundation/src/foundation.rs b/cocoa-foundation/src/foundation.rs index 60eaa4fd..c3661f07 100644 --- a/cocoa-foundation/src/foundation.rs +++ b/cocoa-foundation/src/foundation.rs @@ -132,7 +132,7 @@ mod macos { NSRectMaxYEdge, } - #[link(name = "Foundation", kind = "framework")] + #[cfg_attr(feature = "link", link(name = "Foundation", kind = "framework"))] extern "C" { fn NSInsetRect(rect: NSRect, x: CGFloat, y: CGFloat) -> NSRect; } @@ -167,7 +167,7 @@ impl NSRange { } } -#[link(name = "Foundation", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "Foundation", kind = "framework"))] extern "C" { pub static NSDefaultRunLoopMode: id; } diff --git a/cocoa/Cargo.toml b/cocoa/Cargo.toml index 96b0f424..b4eede60 100644 --- a/cocoa/Cargo.toml +++ b/cocoa/Cargo.toml @@ -20,3 +20,8 @@ core-foundation = { path = "../core-foundation", version = "0.9" } core-graphics = { path = "../core-graphics", version = "0.23" } foreign-types = "0.5" objc = "0.2.3" + +[features] +default = ["link"] +# Disable to manually link. Enabled by default. +link = ["core-foundation/link", "cocoa-foundation/link", "core-graphics/link"] diff --git a/cocoa/src/appkit.rs b/cocoa/src/appkit.rs index 7fe1f0b3..bddfd385 100644 --- a/cocoa/src/appkit.rs +++ b/cocoa/src/appkit.rs @@ -31,7 +31,7 @@ pub type CGLContextObj = *mut c_void; pub type GLint = i32; -#[link(name = "AppKit", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "AppKit", kind = "framework"))] extern "C" { pub static NSAppKitVersionNumber: f64; @@ -3836,7 +3836,7 @@ impl NSImage for id { } } -#[link(name = "AppKit", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "AppKit", kind = "framework"))] extern "C" { // Image hints (NSString* const) pub static NSImageHintCTM: id; diff --git a/cocoa/src/quartzcore.rs b/cocoa/src/quartzcore.rs index 5f4c6da2..dfa2918a 100644 --- a/cocoa/src/quartzcore.rs +++ b/cocoa/src/quartzcore.rs @@ -1572,7 +1572,7 @@ impl CATransform3D { } } -#[link(name = "QuartzCore", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "QuartzCore", kind = "framework"))] extern "C" { static kCARendererColorSpace: CFStringRef; static kCARendererMetalCommandQueue: CFStringRef; diff --git a/core-foundation-sys/Cargo.toml b/core-foundation-sys/Cargo.toml index bdf4e1f0..b1c13804 100644 --- a/core-foundation-sys/Cargo.toml +++ b/core-foundation-sys/Cargo.toml @@ -10,8 +10,11 @@ license = "MIT OR Apache-2.0" [dependencies] [features] +default = ["link"] mac_os_10_7_support = [] # backwards compatibility mac_os_10_8_features = [] # enables new features +# Disable to manually link. Enabled by default. +link = [] [package.metadata.docs.rs] all-features = true diff --git a/core-foundation-sys/src/lib.rs b/core-foundation-sys/src/lib.rs index edd6dd0f..948ce807 100644 --- a/core-foundation-sys/src/lib.rs +++ b/core-foundation-sys/src/lib.rs @@ -22,7 +22,10 @@ // We don't use `target_vendor` since that is going to be deprecated: // https://github.com/rust-lang/lang-team/issues/102 #[cfg_attr( - any(target_os = "macos", target_os = "ios", target_os = "tvos"), + all( + any(target_os = "macos", target_os = "ios", target_os = "tvos"), + feature = "link" + ), link(name = "CoreFoundation", kind = "framework") )] extern "C" {} diff --git a/core-foundation/Cargo.toml b/core-foundation/Cargo.toml index c895f990..ffd58905 100644 --- a/core-foundation/Cargo.toml +++ b/core-foundation/Cargo.toml @@ -19,10 +19,15 @@ chrono = { version = "0.4", optional = true } uuid = { version = "0.5", optional = true } [features] +default = ["link"] + mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"] # backwards compatibility mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"] # enables new features with-chrono = ["chrono"] with-uuid = ["uuid"] +# Disable to manually link. Enabled by default. +link = ["core-foundation-sys/link"] + [package.metadata.docs.rs] all-features = true diff --git a/core-graphics-types/Cargo.toml b/core-graphics-types/Cargo.toml index ce4598a0..2f84200b 100644 --- a/core-graphics-types/Cargo.toml +++ b/core-graphics-types/Cargo.toml @@ -12,5 +12,10 @@ bitflags = "1.0" core-foundation = { path = "../core-foundation", version = "0.9" } libc = "0.2" +[features] +default = ["link"] +# Disable to manually link. Enabled by default. +link = ["core-foundation/link"] + [package.metadata.docs.rs] default-target = "x86_64-apple-darwin" diff --git a/core-graphics-types/src/geometry.rs b/core-graphics-types/src/geometry.rs index 7d37bd7b..356df1b3 100644 --- a/core-graphics-types/src/geometry.rs +++ b/core-graphics-types/src/geometry.rs @@ -166,7 +166,7 @@ mod ffi { use core_foundation::dictionary::CFDictionaryRef; use geometry::{CGAffineTransform, CGPoint, CGRect, CGSize}; - #[link(name = "CoreGraphics", kind = "framework")] + #[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { pub fn CGRectInset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect; pub fn CGRectMakeWithDictionaryRepresentation( diff --git a/core-graphics/Cargo.toml b/core-graphics/Cargo.toml index 9933000c..784db248 100644 --- a/core-graphics/Cargo.toml +++ b/core-graphics/Cargo.toml @@ -8,9 +8,11 @@ authors = ["The Servo Project Developers"] license = "MIT OR Apache-2.0" [features] -default = [] +default = ["link"] elcapitan = [] highsierra = [] +# Disable to manually link. Enabled by default. +link = ["core-foundation/link", "core-graphics-types/link"] [dependencies] bitflags = "1.0" diff --git a/core-graphics/src/access.rs b/core-graphics/src/access.rs index 4e852c85..eee19e3d 100644 --- a/core-graphics/src/access.rs +++ b/core-graphics/src/access.rs @@ -18,7 +18,7 @@ impl ScreenCaptureAccess { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { // Screen Capture Access fn CGRequestScreenCaptureAccess() -> boolean_t; diff --git a/core-graphics/src/color.rs b/core-graphics/src/color.rs index 67913826..b91a4de2 100644 --- a/core-graphics/src/color.rs +++ b/core-graphics/src/color.rs @@ -28,7 +28,7 @@ impl CGColor { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { fn CGColorCreateGenericRGB( red: CGFloat, diff --git a/core-graphics/src/color_space.rs b/core-graphics/src/color_space.rs index 90ee77b0..fc2f70be 100644 --- a/core-graphics/src/color_space.rs +++ b/core-graphics/src/color_space.rs @@ -53,7 +53,7 @@ impl CGColorSpace { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { /// The Display P3 color space, created by Apple. pub static kCGColorSpaceDisplayP3: CFStringRef; diff --git a/core-graphics/src/context.rs b/core-graphics/src/context.rs index c8cd8d3a..2671e8f3 100644 --- a/core-graphics/src/context.rs +++ b/core-graphics/src/context.rs @@ -615,7 +615,7 @@ fn create_bitmap_context_test() { assert_eq!(255, data.bytes()[3]); } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { fn CGContextRetain(c: ::sys::CGContextRef) -> ::sys::CGContextRef; fn CGContextRelease(c: ::sys::CGContextRef); diff --git a/core-graphics/src/data_provider.rs b/core-graphics/src/data_provider.rs index 044575ea..9b3572bc 100644 --- a/core-graphics/src/data_provider.rs +++ b/core-graphics/src/data_provider.rs @@ -153,7 +153,7 @@ fn test_data_provider() { assert!(dropped.load(SeqCst)) } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { fn CGDataProviderCopyData(provider: ::sys::CGDataProviderRef) -> CFDataRef; //fn CGDataProviderCreateDirect diff --git a/core-graphics/src/display.rs b/core-graphics/src/display.rs index 5d02c3af..87db937a 100644 --- a/core-graphics/src/display.rs +++ b/core-graphics/src/display.rs @@ -640,7 +640,7 @@ impl CGDisplayMode { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { pub static CGRectNull: CGRect; pub static CGRectInfinite: CGRect; diff --git a/core-graphics/src/event.rs b/core-graphics/src/event.rs index b160c0c5..44915c73 100644 --- a/core-graphics/src/event.rs +++ b/core-graphics/src/event.rs @@ -673,7 +673,7 @@ impl CGEvent { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { /// Return the type identifier for the opaque type `CGEventRef'. fn CGEventGetTypeID() -> CFTypeID; diff --git a/core-graphics/src/event_source.rs b/core-graphics/src/event_source.rs index b12a68dd..43522c66 100644 --- a/core-graphics/src/event_source.rs +++ b/core-graphics/src/event_source.rs @@ -36,7 +36,7 @@ impl CGEventSource { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { /// Return the type identifier for the opaque type `CGEventSourceRef'. fn CGEventSourceGetTypeID() -> CFTypeID; diff --git a/core-graphics/src/font.rs b/core-graphics/src/font.rs index 888e19ce..e00626a1 100644 --- a/core-graphics/src/font.rs +++ b/core-graphics/src/font.rs @@ -138,7 +138,7 @@ impl CGFont { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { // TODO: basically nothing has bindings (even commented-out) besides what we use. fn CGFontCreateWithDataProvider(provider: ::sys::CGDataProviderRef) -> ::sys::CGFontRef; diff --git a/core-graphics/src/gradient.rs b/core-graphics/src/gradient.rs index b06c31c1..5c241df0 100644 --- a/core-graphics/src/gradient.rs +++ b/core-graphics/src/gradient.rs @@ -72,7 +72,7 @@ impl CGGradient { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { fn CGGradientCreateWithColorComponents( color_space: ::sys::CGColorSpaceRef, diff --git a/core-graphics/src/image.rs b/core-graphics/src/image.rs index e702e781..0433065b 100644 --- a/core-graphics/src/image.rs +++ b/core-graphics/src/image.rs @@ -125,7 +125,7 @@ impl CGImageRef { } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { fn CGImageGetTypeID() -> CFTypeID; fn CGImageGetWidth(image: ::sys::CGImageRef) -> size_t; diff --git a/core-graphics/src/path.rs b/core-graphics/src/path.rs index 4aad2212..cf612e16 100644 --- a/core-graphics/src/path.rs +++ b/core-graphics/src/path.rs @@ -125,7 +125,7 @@ impl CGPathElement { type CGPathApplierFunction = unsafe extern "C" fn(info: *mut c_void, element: *const CGPathElement); -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { fn CGPathCreateWithRect(rect: CGRect, transform: *const CGAffineTransform) -> ::sys::CGPathRef; fn CGPathApply(path: ::sys::CGPathRef, info: *mut c_void, function: CGPathApplierFunction); diff --git a/core-graphics/src/private.rs b/core-graphics/src/private.rs index e324c1ab..6da3d48e 100644 --- a/core-graphics/src/private.rs +++ b/core-graphics/src/private.rs @@ -96,7 +96,7 @@ mod ffi { pub type CGSRegionRef = *mut CGSRegionObject; pub type OSStatus = i32; - #[link(name = "CoreGraphics", kind = "framework")] + #[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { pub fn CGSRegionRelease(region: CGSRegionRef); pub fn CGSNewRegionWithRect(rect: *const CGRect, outRegion: *mut CGSRegionRef) -> CGError; diff --git a/core-graphics/src/window.rs b/core-graphics/src/window.rs index 97f08d30..866ebd27 100644 --- a/core-graphics/src/window.rs +++ b/core-graphics/src/window.rs @@ -125,7 +125,7 @@ pub fn create_image_from_array( } } -#[link(name = "CoreGraphics", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreGraphics", kind = "framework"))] extern "C" { pub static kCGWindowNumber: CFStringRef; pub static kCGWindowStoreType: CFStringRef; diff --git a/core-text/Cargo.toml b/core-text/Cargo.toml index 0e6c2524..329a06eb 100644 --- a/core-text/Cargo.toml +++ b/core-text/Cargo.toml @@ -11,10 +11,12 @@ all-features = true default-target = "x86_64-apple-darwin" [features] -default = ["mountainlion"] +default = ["mountainlion", "link"] # For OS X 10.7 compat, exclude this feature. It will exclude some things from # the exposed APIs in the crate. mountainlion = [] +# Disable to manually link. Enabled by default. +link = ["core-foundation/link", "core-graphics/link"] [dependencies] foreign-types = "0.5" diff --git a/core-text/src/font.rs b/core-text/src/font.rs index 0d303a63..a39652d3 100644 --- a/core-text/src/font.rs +++ b/core-text/src/font.rs @@ -594,7 +594,7 @@ pub fn cascade_list_for_languages( } } -#[link(name = "CoreText", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))] extern "C" { /* * CTFont.h diff --git a/core-text/src/frame.rs b/core-text/src/frame.rs index 03fcee90..eebaaa1d 100644 --- a/core-text/src/frame.rs +++ b/core-text/src/frame.rs @@ -84,7 +84,7 @@ impl CTFrame { } } -#[link(name = "CoreText", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))] extern "C" { fn CTFrameGetTypeID() -> CFTypeID; fn CTFrameGetLines(frame: CTFrameRef) -> CFArrayRef; diff --git a/core-text/src/framesetter.rs b/core-text/src/framesetter.rs index dacb540b..abdd3eb3 100644 --- a/core-text/src/framesetter.rs +++ b/core-text/src/framesetter.rs @@ -74,7 +74,7 @@ impl CTFramesetter { } } -#[link(name = "CoreText", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))] extern "C" { fn CTFramesetterGetTypeID() -> CFTypeID; fn CTFramesetterCreateWithAttributedString(string: CFAttributedStringRef) -> CTFramesetterRef; diff --git a/core-text/src/line.rs b/core-text/src/line.rs index b2645aaf..db429796 100644 --- a/core-text/src/line.rs +++ b/core-text/src/line.rs @@ -91,7 +91,7 @@ impl CTLine { } } -#[link(name = "CoreText", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))] extern "C" { fn CTLineGetTypeID() -> CFTypeID; fn CTLineGetGlyphRuns(line: CTLineRef) -> CFArrayRef; diff --git a/core-text/src/run.rs b/core-text/src/run.rs index f84fb46c..3f1c76a8 100644 --- a/core-text/src/run.rs +++ b/core-text/src/run.rs @@ -145,7 +145,7 @@ fn create_runs() { } } -#[link(name = "CoreText", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "CoreText", kind = "framework"))] extern "C" { fn CTRunGetTypeID() -> CFTypeID; fn CTRunGetAttributes(run: CTRunRef) -> CFDictionaryRef; diff --git a/io-surface/Cargo.toml b/io-surface/Cargo.toml index a3b86844..449f278e 100644 --- a/io-surface/Cargo.toml +++ b/io-surface/Cargo.toml @@ -16,3 +16,8 @@ core-foundation = { path = "../core-foundation", version = "0.9" } core-foundation-sys = { path = "../core-foundation-sys", version = "0.8" } cgl = "0.3" leaky-cow = "0.1.1" + +[features] +default = ["link"] +# Disable to manually link. Enabled by default. +link = ["core-foundation/link", "core-foundation-sys/link"] diff --git a/io-surface/src/lib.rs b/io-surface/src/lib.rs index a530e2b5..184655be 100644 --- a/io-surface/src/lib.rs +++ b/io-surface/src/lib.rs @@ -166,7 +166,7 @@ impl IOSurface { } } -#[link(name = "IOSurface", kind = "framework")] +#[cfg_attr(feature = "link", link(name = "IOSurface", kind = "framework"))] extern "C" { pub static kIOSurfaceAllocSize: CFStringRef; pub static kIOSurfaceWidth: CFStringRef;