diff --git a/crates/libs/core/src/imp/mod.rs b/crates/libs/core/src/imp/mod.rs index badd497bd5..81cad6441a 100644 --- a/crates/libs/core/src/imp/mod.rs +++ b/crates/libs/core/src/imp/mod.rs @@ -1,21 +1,16 @@ -mod bindings; +#[cfg(windows)] +include!("windows.rs"); + mod can_into; mod com_bindings; -mod factory_cache; -mod generic_factory; mod ref_count; mod sha1; -mod waiter; mod weak_ref_count; -pub use bindings::*; pub use can_into::*; pub use com_bindings::*; -pub use factory_cache::*; -pub use generic_factory::*; pub use ref_count::*; pub use sha1::*; -pub use waiter::*; pub use weak_ref_count::*; #[doc(hidden)] diff --git a/crates/libs/core/src/imp/windows.rs b/crates/libs/core/src/imp/windows.rs new file mode 100644 index 0000000000..e1a55ceb4d --- /dev/null +++ b/crates/libs/core/src/imp/windows.rs @@ -0,0 +1,11 @@ +mod factory_cache; +pub use factory_cache::*; + +mod generic_factory; +pub use generic_factory::*; + +mod waiter; +pub use waiter::*; + +mod bindings; +pub use bindings::*; diff --git a/crates/libs/core/src/lib.rs b/crates/libs/core/src/lib.rs index 5ac18db1b5..ae2e35f2cd 100644 --- a/crates/libs/core/src/lib.rs +++ b/crates/libs/core/src/lib.rs @@ -10,9 +10,11 @@ Learn more about Rust for Windows here: () -> Result { - imp::factory::() -} diff --git a/crates/libs/core/src/windows.rs b/crates/libs/core/src/windows.rs new file mode 100644 index 0000000000..9b2bc0938e --- /dev/null +++ b/crates/libs/core/src/windows.rs @@ -0,0 +1,22 @@ +mod agile_reference; +pub use agile_reference::*; + +mod array; +pub use array::*; + +#[cfg(feature = "std")] +mod event; +#[cfg(feature = "std")] +pub use event::*; + +mod handles; +pub use handles::*; + +mod variant; +pub use variant::*; + +/// Attempts to load the factory object for the given WinRT class. +/// This can be used to access COM interfaces implemented on a Windows Runtime class factory. +pub fn factory() -> Result { + imp::factory::() +} diff --git a/crates/libs/cppwinrt/src/lib.rs b/crates/libs/cppwinrt/src/lib.rs index 1819774a38..655ccc2ca3 100644 --- a/crates/libs/cppwinrt/src/lib.rs +++ b/crates/libs/cppwinrt/src/lib.rs @@ -2,6 +2,8 @@ Learn more about Rust for Windows here: */ +#![cfg(windows)] + const VERSION: &str = "2.0.240405.15"; /// Calls the C++/WinRT compiler with the given arguments. diff --git a/crates/libs/registry/src/lib.rs b/crates/libs/registry/src/lib.rs index 5c647e224a..607d77a6fe 100644 --- a/crates/libs/registry/src/lib.rs +++ b/crates/libs/registry/src/lib.rs @@ -2,6 +2,7 @@ Learn more about Rust for Windows here: */ +#![cfg(windows)] #![no_std] #[macro_use] diff --git a/crates/libs/version/src/lib.rs b/crates/libs/version/src/lib.rs index 23ba99ee09..3209fc1d72 100644 --- a/crates/libs/version/src/lib.rs +++ b/crates/libs/version/src/lib.rs @@ -2,6 +2,7 @@ Learn more about Rust for Windows here: */ +#![cfg(windows)] #![cfg_attr(not(test), no_std)] mod bindings;