Skip to content

Commit 50d9aa4

Browse files
authored
More comprehensive workaround for linker issue (#467)
1 parent e28897d commit 50d9aa4

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

crates/gen/src/function.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ impl Function {
3131
TokenStream::new()
3232
};
3333

34-
// TODO: need to generate libs until Rust supports dynamic linking against DLLs.
35-
// This is actually the DLL name.
3634
let mut link = self.signature.method.impl_map().unwrap().scope().name();
37-
if link == "ext-ms-win-core-iuri-l1-1-0" {
38-
link = "urlmon";
39-
} else if link.starts_with("api-ms-win-core") {
35+
36+
// TODO: workaround for https://github.com/microsoft/windows-rs/issues/463
37+
if link.contains("-ms-win-") || link == "D3DCOMPILER_47" {
4038
link = "onecoreuap";
4139
}
4240

crates/tests/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,13 @@ fn main() {
6363
windows::win32::windows_programming::{
6464
CloseHandle
6565
},
66-
windows::win32::com::{IUri, CreateUri},
66+
windows::win32::com::CreateUri,
6767
windows::win32::structured_storage::{CreateStreamOnHGlobal, STREAM_SEEK},
6868
windows::win32::upnp::UIAnimationTransitionLibrary,
6969
windows::win32::ldap::ldapsearch,
7070
windows::win32::upnp::UIAnimationManager,
71+
windows::win32::game_mode::HasExpandedResources,
72+
windows::win32::debug::MiniDumpWriteDump,
73+
windows::win32::direct3d11::D3DDisassemble11Trace,
7174
);
7275
}

crates/tests/tests/win32.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
use windows::Abi;
22

33
use tests::{
4+
windows::win32::com::CreateUri,
5+
windows::win32::debug::{MiniDumpWriteDump, MINIDUMP_TYPE},
6+
windows::win32::direct3d11::D3DDisassemble11Trace,
47
windows::win32::direct3d12::D3D12_DEFAULT_BLEND_FACTOR_ALPHA,
58
windows::win32::direct3d_hlsl::D3DCOMPILER_DLL,
69
windows::win32::display_devices::RECT,
710
windows::win32::dxgi::{
811
CreateDXGIFactory1, IDXGIFactory7, DXGI_ADAPTER_FLAG, DXGI_FORMAT, DXGI_MODE_DESC,
912
DXGI_MODE_SCALING, DXGI_MODE_SCANLINE_ORDER, DXGI_RATIONAL,
1013
},
14+
windows::win32::game_mode::HasExpandedResources,
1115
windows::win32::ldap::ldapsearch,
1216
windows::win32::security::ACCESS_MODE,
1317
windows::win32::structured_storage::{CreateStreamOnHGlobal, STREAM_SEEK},
@@ -246,6 +250,45 @@ fn com_inheritance() {
246250
}
247251
}
248252

253+
// Tests for https://github.com/microsoft/windows-rs/issues/463
254+
#[test]
255+
fn onecore_imports() -> windows::Result<()> {
256+
unsafe {
257+
let mut has_expanded_resources = 0;
258+
HasExpandedResources(&mut has_expanded_resources).ok()?;
259+
260+
let mut uri = None;
261+
let uri = CreateUri(
262+
windows::HString::from("http://kennykerr.ca")
263+
.as_wide()
264+
.as_ptr(),
265+
0,
266+
0,
267+
&mut uri,
268+
)
269+
.and_some(uri)?;
270+
271+
let mut port = 0;
272+
uri.GetPort(&mut port).ok()?;
273+
assert!(port == 80);
274+
275+
let result = MiniDumpWriteDump(
276+
HANDLE(0),
277+
0,
278+
HANDLE(0),
279+
MINIDUMP_TYPE::MiniDumpNormal,
280+
std::ptr::null_mut(),
281+
std::ptr::null_mut(),
282+
std::ptr::null_mut(),
283+
);
284+
assert!(result.is_err());
285+
286+
assert!(D3DDisassemble11Trace(std::ptr::null_mut(), 0, None, 0, 0, 0, &mut None).is_err());
287+
288+
Ok(())
289+
}
290+
}
291+
249292
// TODO: light up BSTR as windows::BString
250293

251294
// #[test]

0 commit comments

Comments
 (0)