Skip to content

Commit

Permalink
Use relative path for extension (#3224)
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Aug 27, 2024
1 parent 316d544 commit badf366
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
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");

0 comments on commit badf366

Please sign in to comment.