Skip to content

Commit 66f1850

Browse files
authored
Clarify support for non-Windows targets (#3135)
1 parent e9b91b4 commit 66f1850

File tree

8 files changed

+44
-28
lines changed

8 files changed

+44
-28
lines changed

crates/libs/core/src/imp/factory_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ where
127127
F: FnMut(crate::PCSTR) -> crate::Result<R>,
128128
{
129129
let suffix = b".dll\0";
130-
let mut library = vec![0; path.len() + suffix.len()];
130+
let mut library = alloc::vec![0; path.len() + suffix.len()];
131131
while let Some(pos) = path.rfind('.') {
132132
path = &path[..pos];
133133
library.truncate(path.len() + suffix.len());

crates/libs/core/src/imp/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
mod bindings;
1+
#[cfg(windows)]
2+
include!("windows.rs");
3+
24
mod can_into;
35
mod com_bindings;
4-
mod factory_cache;
5-
mod generic_factory;
66
mod ref_count;
77
mod sha1;
8-
mod waiter;
98
mod weak_ref_count;
109

11-
pub use bindings::*;
1210
pub use can_into::*;
1311
pub use com_bindings::*;
14-
pub use factory_cache::*;
15-
pub use generic_factory::*;
1612
pub use ref_count::*;
1713
pub use sha1::*;
18-
pub use waiter::*;
1914
pub use weak_ref_count::*;
2015

2116
#[doc(hidden)]

crates/libs/core/src/imp/windows.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
mod factory_cache;
2+
pub use factory_cache::*;
3+
4+
mod generic_factory;
5+
pub use generic_factory::*;
6+
7+
mod waiter;
8+
pub use waiter::*;
9+
10+
mod bindings;
11+
pub use bindings::*;

crates/libs/core/src/lib.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,21 @@ Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs
1010
)]
1111
#![cfg_attr(all(not(feature = "std")), no_std)]
1212

13+
#[cfg(windows)]
14+
include!("windows.rs");
15+
1316
extern crate self as windows_core;
1417

15-
#[macro_use]
1618
extern crate alloc;
1719

1820
use alloc::boxed::Box;
1921

2022
#[doc(hidden)]
2123
pub mod imp;
2224

23-
mod agile_reference;
24-
mod array;
2525
mod as_impl;
2626
mod com_object;
27-
#[cfg(feature = "std")]
28-
mod event;
2927
mod guid;
30-
mod handles;
3128
mod inspectable;
3229
mod interface;
3330
mod out_param;
@@ -40,17 +37,11 @@ mod runtime_type;
4037
mod scoped_interface;
4138
mod r#type;
4239
mod unknown;
43-
mod variant;
4440
mod weak;
4541

46-
pub use agile_reference::*;
47-
pub use array::*;
4842
pub use as_impl::*;
4943
pub use com_object::*;
50-
#[cfg(feature = "std")]
51-
pub use event::*;
5244
pub use guid::*;
53-
pub use handles::*;
5445
pub use inspectable::*;
5546
pub use interface::*;
5647
pub use out_param::*;
@@ -63,15 +54,8 @@ pub use runtime_name::*;
6354
pub use runtime_type::*;
6455
pub use scoped_interface::*;
6556
pub use unknown::*;
66-
pub use variant::*;
6757
pub use weak::*;
6858
pub use windows_implement::implement;
6959
pub use windows_interface::interface;
7060
pub use windows_result::*;
7161
pub use windows_strings::*;
72-
73-
/// Attempts to load the factory object for the given WinRT class.
74-
/// This can be used to access COM interfaces implemented on a Windows Runtime class factory.
75-
pub fn factory<C: RuntimeName, I: Interface>() -> Result<I> {
76-
imp::factory::<C, I>()
77-
}

crates/libs/core/src/windows.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
mod agile_reference;
2+
pub use agile_reference::*;
3+
4+
mod array;
5+
pub use array::*;
6+
7+
#[cfg(feature = "std")]
8+
mod event;
9+
#[cfg(feature = "std")]
10+
pub use event::*;
11+
12+
mod handles;
13+
pub use handles::*;
14+
15+
mod variant;
16+
pub use variant::*;
17+
18+
/// Attempts to load the factory object for the given WinRT class.
19+
/// This can be used to access COM interfaces implemented on a Windows Runtime class factory.
20+
pub fn factory<C: RuntimeName, I: Interface>() -> Result<I> {
21+
imp::factory::<C, I>()
22+
}

crates/libs/cppwinrt/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs>
33
*/
44

5+
#![cfg(windows)]
6+
57
const VERSION: &str = "2.0.240405.15";
68

79
/// Calls the C++/WinRT compiler with the given arguments.

crates/libs/registry/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs>
33
*/
44

5+
#![cfg(windows)]
56
#![no_std]
67

78
#[macro_use]

crates/libs/version/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs>
33
*/
44

5+
#![cfg(windows)]
56
#![cfg_attr(not(test), no_std)]
67

78
mod bindings;

0 commit comments

Comments
 (0)