Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative path for extension #3224

Merged
merged 1 commit into from
Aug 27, 2024
Merged
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
15 changes: 6 additions & 9 deletions crates/libs/bindgen/src/rust/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@ use super::*;
/// This function generates an `include!(...)` that points into the `src/includes` directory for
/// the `windows` and `windows-sys` crates. This makes it easy to inject code into WinMD namespaces.
#[allow(dead_code)]
fn include_ext(relative_path: &str) -> TokenStream {
fn include_ext(namespace: &str, relative_path: &str) -> TokenStream {
let mut path = "../".repeat(namespace.split('.').count());
path.push_str("includes/");
path.push_str(relative_path);
quote! {
core::include!(
core::concat!(
core::env!("CARGO_MANIFEST_DIR"),
"/src/includes/",
#relative_path
)
);
core::include!(#path);
}
}

/// Generates extension code for a specific namespace
pub fn gen_mod(_writer: &Writer, namespace: &str) -> TokenStream {
match namespace {
"Windows.Win32.UI.WindowsAndMessaging" => {
include_ext("Win32/UI/WindowsAndMessaging/WindowLong.rs")
include_ext(namespace, "Win32/UI/WindowsAndMessaging/WindowLong.rs")
}

_ => quote!(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3757,4 +3757,4 @@ pub type SENDASYNCPROC = Option<unsafe extern "system" fn(param0: super::super::
pub type TIMERPROC = Option<unsafe extern "system" fn(param0: super::super::Foundation::HWND, param1: u32, param2: usize, param3: u32)>;
pub type WNDENUMPROC = Option<unsafe extern "system" fn(param0: super::super::Foundation::HWND, param1: super::super::Foundation::LPARAM) -> super::super::Foundation::BOOL>;
pub type WNDPROC = Option<unsafe extern "system" fn(param0: super::super::Foundation::HWND, param1: u32, param2: super::super::Foundation::WPARAM, param3: super::super::Foundation::LPARAM) -> super::super::Foundation::LRESULT>;
core::include!(core::concat!(core::env!("CARGO_MANIFEST_DIR"), "/src/includes/", "Win32/UI/WindowsAndMessaging/WindowLong.rs"));
core::include!("../../../../includes/Win32/UI/WindowsAndMessaging/WindowLong.rs");
Original file line number Diff line number Diff line change
Expand Up @@ -9456,4 +9456,4 @@ pub type SENDASYNCPROC = Option<unsafe extern "system" fn(param0: super::super::
pub type TIMERPROC = Option<unsafe extern "system" fn(param0: super::super::Foundation::HWND, param1: u32, param2: usize, param3: u32)>;
pub type WNDENUMPROC = Option<unsafe extern "system" fn(param0: super::super::Foundation::HWND, param1: super::super::Foundation::LPARAM) -> super::super::Foundation::BOOL>;
pub type WNDPROC = Option<unsafe extern "system" fn(param0: super::super::Foundation::HWND, param1: u32, param2: super::super::Foundation::WPARAM, param3: super::super::Foundation::LPARAM) -> super::super::Foundation::LRESULT>;
core::include!(core::concat!(core::env!("CARGO_MANIFEST_DIR"), "/src/includes/", "Win32/UI/WindowsAndMessaging/WindowLong.rs"));
core::include!("../../../../includes/Win32/UI/WindowsAndMessaging/WindowLong.rs");