Skip to content

Commit

Permalink
feat: link feature (#271)
Browse files Browse the repository at this point in the history
* feat: link feature

* fix
  • Loading branch information
crowlKats authored Jun 9, 2023
1 parent ab2b87a commit a6a0446
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ exclude = ["guide/**/*", "examples/texture/**/*", "tests/**/*", "Cargo.lock", "t
default-target = "x86_64-apple-darwin"

[features]
default = []
default = ["link"]
private = []
mps = []
link = []

[dependencies]
core-graphics-types = "0.1"
Expand Down
6 changes: 3 additions & 3 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ pub struct MTLAccelerationStructureSizes {
pub refit_scratch_buffer_size: NSUInteger,
}

#[link(name = "Metal", kind = "framework")]
#[cfg_attr(feature = "link", link(name = "Metal", kind = "framework"))]
extern "C" {
fn MTLCreateSystemDefaultDevice() -> *mut MTLDevice;
#[cfg(not(target_os = "ios"))]
Expand All @@ -1473,11 +1473,11 @@ pub type dispatch_queue_t = *mut Object;
type dispatch_block_t = *const Block<(), ()>;

#[cfg_attr(
any(target_os = "macos", target_os = "ios"),
all(feature = "link", any(target_os = "macos", target_os = "ios")),
link(name = "System", kind = "dylib")
)]
#[cfg_attr(
not(any(target_os = "macos", target_os = "ios")),
all(feature = "link", not(any(target_os = "macos", target_os = "ios"))),
link(name = "dispatch", kind = "dylib")
)]
#[allow(improper_ctypes)]
Expand Down
2 changes: 1 addition & 1 deletion src/mps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::*;

use objc::runtime::{BOOL, YES};

#[link(name = "MetalPerformanceShaders", kind = "framework")]
#[cfg_attr(feature = "link", link(name = "MetalPerformanceShaders", kind = "framework"))]
extern "C" {
fn MPSSupportsMTLDevice(device: *const std::ffi::c_void) -> BOOL;
}
Expand Down

0 comments on commit a6a0446

Please sign in to comment.