Skip to content

Commit

Permalink
feat: add link feature
Browse files Browse the repository at this point in the history
adjust docs

Update cocoa/Cargo.toml

Co-authored-by: Divy Srivastava <[email protected]>

fmt
  • Loading branch information
crowlKats committed Oct 10, 2023
1 parent fbde503 commit cba6666
Show file tree
Hide file tree
Showing 33 changed files with 65 additions and 29 deletions.
6 changes: 6 additions & 0 deletions cocoa-foundation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

4 changes: 2 additions & 2 deletions cocoa-foundation/src/foundation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions cocoa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions cocoa/src/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cocoa/src/quartzcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions core-foundation-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion core-foundation-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {}
Expand Down
5 changes: 5 additions & 0 deletions core-foundation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions core-graphics-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion core-graphics-types/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion core-graphics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/color_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/data_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/event_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion core-text/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core-text/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core-text/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-text/src/framesetter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-text/src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-text/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions io-surface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion io-surface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cba6666

Please sign in to comment.