Skip to content

Commit

Permalink
Add static and dynamic features for issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
kenba committed Nov 16, 2024
1 parent 0306b69 commit 920c3ae
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ edition = "2021"
build = "build.rs"

[features]
static = []
dynamic = []

CL_VERSION_1_1 = []
CL_VERSION_1_2 = []
CL_VERSION_2_0 = []
Expand Down Expand Up @@ -64,9 +67,6 @@ cl_loader_info = []
cl_pocl_content_size = []
cl_loader_layers = []

# Default features:
default = ["CL_VERSION_1_1", "CL_VERSION_1_2"]

[dependencies]
libc = "0.2"

Expand Down
2 changes: 2 additions & 0 deletions src/cl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#![allow(non_camel_case_types, non_upper_case_globals)]

use super::cl_platform::{cl_int, cl_uchar, cl_uint, cl_ulong};
#[allow(unused_imports)]
use libc::{c_char, c_uchar, c_void, intptr_t, size_t};

pub type cl_platform_id = *mut c_void;
Expand Down Expand Up @@ -916,6 +917,7 @@ pub const fn make_version(major: cl_version, minor: cl_version, patch: cl_versio

#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
#[cfg(feature = "static")]
extern "system" {
// Platform API
pub fn clGetPlatformIDs(
Expand Down
20 changes: 11 additions & 9 deletions src/cl_dx9_media_sharing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ pub type clGetSupportedDX9MediaSurfaceFormatsINTEL_fn = clGetSupportedDX9MediaSu

#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
#[cfg(feature = "cl_intel_dx9_media_sharing")]
extern "system" {

#[cfg(feature = "cl_intel_dx9_media_sharing")]
pub fn clGetDeviceIDsFromDX9INTEL(
platform: cl_platform_id,
dx9_device_source: cl_dx9_device_source_intel,
Expand All @@ -237,7 +237,6 @@ extern "system" {
num_devices: *mut cl_uint,
) -> cl_int;

#[cfg(feature = "cl_intel_dx9_media_sharing")]
pub fn clCreateFromDX9MediaSurfaceINTEL(
context: cl_context,
flags: cl_mem_flags,
Expand All @@ -247,7 +246,6 @@ extern "system" {
errcode_ret: *mut cl_int,
) -> cl_mem;

#[cfg(feature = "cl_intel_dx9_media_sharing")]
pub fn clEnqueueAcquireDX9ObjectsINTEL(
command_queue: cl_command_queue,
num_objects: cl_uint,
Expand All @@ -257,7 +255,6 @@ extern "system" {
event: *mut cl_event,
) -> cl_int;

#[cfg(feature = "cl_intel_dx9_media_sharing")]
pub fn clEnqueueReleaseDX9ObjectsINTEL(
command_queue: cl_command_queue,
num_objects: cl_uint,
Expand All @@ -266,13 +263,18 @@ extern "system" {
event_wait_list: *const cl_event,
event: *mut cl_event,
) -> cl_int;
}

// cl_intel_sharing_format_query_dx9

// cl_intel_sharing_format_query_dx9
#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
#[cfg(any(
feature = "cl_khr_dx9_media_sharing",
feature = "cl_intel_dx9_media_sharing"
))]
extern "system" {

#[cfg(any(
feature = "cl_khr_dx9_media_sharing",
feature = "cl_intel_dx9_media_sharing"
))]
pub fn clGetSupportedDX9MediaSurfaceFormatsINTEL(
context: cl_context,
flags: cl_mem_flags,
Expand Down
1 change: 1 addition & 0 deletions src/cl_egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub type clCreateEventFromEGLSyncKHR_fn = clCreateEventFromEGLSyncKHR_t;

#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
#[cfg(feature = "static")]
extern "system" {

pub fn clCreateFromEGLImageKHR(
Expand Down
1 change: 1 addition & 0 deletions src/cl_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ pub type clLogMessagesToStderrAPPLE_fn = clLogMessagesToStderrAPPLE_t;

#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
#[cfg(feature = "static")]
extern "system" {

/* Memory object destruction
Expand Down
2 changes: 2 additions & 0 deletions src/cl_gl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ pub type clGetSupportedGLTextureFormatsINTEL_fn = clGetSupportedGLTextureFormats

#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
#[cfg(feature = "static")]
extern "system" {

pub fn clCreateFromGLBuffer(
Expand Down Expand Up @@ -313,6 +314,7 @@ pub const CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR: cl_uint = 0x200D;

#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
#[cfg(feature = "static")]
extern "system" {

pub fn clGetGLContextInfoKHR(
Expand Down

0 comments on commit 920c3ae

Please sign in to comment.