Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions crates/libs/link/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#[cfg(all(windows, target_arch = "x86"))]
#[macro_export]
macro_rules! link {
// Avoid future-compat lint if bindings are still using the old "cdecl" form of the bindings.
($library:literal "cdecl" $($link_name:literal)? fn $($function:tt)*) => (
$crate::link!($library "C" $($link_name)? fn $($function)*);
);
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated")]
extern $abi {
Expand All @@ -18,9 +22,13 @@ macro_rules! link {
#[cfg(all(windows, not(target_arch = "x86")))]
#[macro_export]
macro_rules! link {
// Avoid future-compat lint if bindings are still using the old "cdecl" form of the bindings.
($library:literal "cdecl" $($link_name:literal)? fn $($function:tt)*) => (
$crate::link!($library "C" $($link_name)? fn $($function)*);
);
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")]
extern "C" {
extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
Expand All @@ -31,8 +39,12 @@ macro_rules! link {
#[cfg(not(windows))]
#[macro_export]
macro_rules! link {
// Avoid future-compat lint if bindings are still using the old "cdecl" form of the bindings.
($library:literal "cdecl" $($link_name:literal)? fn $($function:tt)*) => (
$crate::link!($library "C" $($link_name)? fn $($function)*);
);
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
extern "C" {
extern $abi {
pub fn $($function)*;
}
)
Expand Down
35 changes: 19 additions & 16 deletions crates/libs/targets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#[cfg(all(windows_raw_dylib, target_arch = "x86"))]
#[macro_export]
macro_rules! link {
// Avoid future-compat lint if bindings are still using the old "cdecl" form of the bindings.
($library:literal "cdecl" $($link_name:literal)? fn $($function:tt)*) => (
$crate::link!($library "C" $($link_name)? fn $($function)*);
);
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated")]
extern $abi {
Expand All @@ -18,21 +22,12 @@ macro_rules! link {
#[cfg(all(windows_raw_dylib, not(target_arch = "x86")))]
#[macro_export]
macro_rules! link {
// Avoid future-compat lint if bindings are still using the old "cdecl" form of the bindings.
($library:literal "cdecl" $($link_name:literal)? fn $($function:tt)*) => (
$crate::link!($library "C" $($link_name)? fn $($function)*);
);
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")]
extern "C" {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
)
}

/// Defines an external function to import.
#[cfg(all(windows, not(windows_raw_dylib), target_arch = "x86"))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = "windows.0.53.0")]
extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
Expand All @@ -41,12 +36,16 @@ macro_rules! link {
}

/// Defines an external function to import.
#[cfg(all(windows, not(windows_raw_dylib), not(target_arch = "x86")))]
#[cfg(all(windows, not(windows_raw_dylib)))]
#[macro_export]
macro_rules! link {
// Avoid future-compat lint if bindings are still using the old "cdecl" form of the bindings.
($library:literal "cdecl" $($link_name:literal)? fn $($function:tt)*) => (
$crate::link!($library "C" $($link_name)? fn $($function)*);
);
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = "windows.0.53.0")]
extern "C" {
extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
Expand All @@ -57,8 +56,12 @@ macro_rules! link {
#[cfg(all(not(windows), not(windows_raw_dylib)))]
#[macro_export]
macro_rules! link {
// Avoid future-compat lint if bindings are still using the old "cdecl" form of the bindings.
($library:literal "cdecl" $($link_name:literal)? fn $($function:tt)*) => (
$crate::link!($library "C" $($link_name)? fn $($function)*);
);
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
extern "C" {
extern $abi {
pub fn $($function)*;
}
)
Expand Down