From d32bc9ea234940f528cf93b62d9c1cbc612255c8 Mon Sep 17 00:00:00 2001 From: Kornel Date: Tue, 8 Aug 2017 14:30:53 +0100 Subject: [PATCH 1/2] 10.7/10.8 compatibility features --- README.md | 6 ++++++ core-foundation-sys/Cargo.toml | 4 ++++ core-foundation/Cargo.toml | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/README.md b/README.md index ce0909a..d36ff53 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # core-foundation-rs [![Build Status](https://travis-ci.org/servo/core-foundation-rs.svg?branch=master)](https://travis-ci.org/servo/core-foundation-rs) + +## Compatibility + +By default it targets macOS 10.7. + +To enable features added in macOS 10.8, set Cargo feature `mac_os_10_8_features`. To have both 10.8 features and 10.7 compatibility, also set `mac_os_10_7_support`. Setting both requires weak linkage, which is is a nighty-only feature as of Rust 1.19. diff --git a/core-foundation-sys/Cargo.toml b/core-foundation-sys/Cargo.toml index f1dd3e3..5a02fc4 100644 --- a/core-foundation-sys/Cargo.toml +++ b/core-foundation-sys/Cargo.toml @@ -10,3 +10,7 @@ build = "build.rs" [dependencies] libc = "0.2" + +[features] +mac_os_10_7_support = [] # backwards compatibility +mac_os_10_8_features = [] # enables new features diff --git a/core-foundation/Cargo.toml b/core-foundation/Cargo.toml index e338b16..0bbf669 100644 --- a/core-foundation/Cargo.toml +++ b/core-foundation/Cargo.toml @@ -13,3 +13,7 @@ version = "0.4.2" [dependencies] libc = "0.2" + +[features] +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 From ba3e78cd3e84d204047b54b21576060dbcbd2a44 Mon Sep 17 00:00:00 2001 From: Kornel Date: Tue, 8 Aug 2017 14:31:08 +0100 Subject: [PATCH 2/2] Add 10.8-only constant --- core-foundation-sys/src/lib.rs | 2 ++ core-foundation-sys/src/url.rs | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core-foundation-sys/src/lib.rs b/core-foundation-sys/src/lib.rs index b39da97..96c0b1e 100644 --- a/core-foundation-sys/src/lib.rs +++ b/core-foundation-sys/src/lib.rs @@ -8,6 +8,8 @@ // except according to those terms. #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, improper_ctypes)] +#![cfg_attr(all(feature="mac_os_10_7_support", feature="mac_os_10_8_features"), feature(linkage))] // back-compat requires weak linkage + extern crate libc; pub mod array; diff --git a/core-foundation-sys/src/url.rs b/core-foundation-sys/src/url.rs index c0f8282..a9049f8 100644 --- a/core-foundation-sys/src/url.rs +++ b/core-foundation-sys/src/url.rs @@ -72,10 +72,13 @@ extern { pub static kCFURLParentDirectoryURLKey: CFStringRef; pub static kCFURLPreferredIOBlockSizeKey: CFStringRef; pub static kCFURLTypeIdentifierKey: CFStringRef; - // static kCFURLVolumeIdentifierKey: CFStringRef; - // static kCFURLVolumeURLKey: CFStringRef; - // static kCFURLIsExcludedFromBackupKey: CFStringRef; - // static kCFURLFileResourceTypeKey: CFStringRef; + pub static kCFURLVolumeIdentifierKey: CFStringRef; + pub static kCFURLVolumeURLKey: CFStringRef; + + #[cfg(feature="mac_os_10_8_features")] + #[cfg_attr(feature = "mac_os_10_7_support", linkage = "extern_weak")] + pub static kCFURLIsExcludedFromBackupKey: CFStringRef; + pub static kCFURLFileResourceTypeKey: CFStringRef; /* Creating a CFURL */ pub fn CFURLCopyAbsoluteURL(anURL: CFURLRef) -> CFURLRef; @@ -151,3 +154,9 @@ extern { //fn CFURLStartAccessingSecurityScopedResource //fn CFURLStopAccessingSecurityScopedResource } + +#[test] +#[cfg(feature="mac_os_10_8_features")] +fn can_see_excluded_from_backup_key() { + let _ = unsafe { kCFURLIsExcludedFromBackupKey }; +}