Skip to content

Commit

Permalink
Clarify support for non-Windows targets (#3135)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Jun 28, 2024
1 parent e9b91b4 commit 66f1850
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 28 deletions.
2 changes: 1 addition & 1 deletion crates/libs/core/src/imp/factory_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ where
F: FnMut(crate::PCSTR) -> crate::Result<R>,
{
let suffix = b".dll\0";
let mut library = vec![0; path.len() + suffix.len()];
let mut library = alloc::vec![0; path.len() + suffix.len()];
while let Some(pos) = path.rfind('.') {
path = &path[..pos];
library.truncate(path.len() + suffix.len());
Expand Down
11 changes: 3 additions & 8 deletions crates/libs/core/src/imp/mod.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
11 changes: 11 additions & 0 deletions crates/libs/core/src/imp/windows.rs
Original file line number Diff line number Diff line change
@@ -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::*;
22 changes: 3 additions & 19 deletions crates/libs/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@ Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs
)]
#![cfg_attr(all(not(feature = "std")), no_std)]

#[cfg(windows)]
include!("windows.rs");

extern crate self as windows_core;

#[macro_use]
extern crate alloc;

use alloc::boxed::Box;

#[doc(hidden)]
pub mod imp;

mod agile_reference;
mod array;
mod as_impl;
mod com_object;
#[cfg(feature = "std")]
mod event;
mod guid;
mod handles;
mod inspectable;
mod interface;
mod out_param;
Expand All @@ -40,17 +37,11 @@ mod runtime_type;
mod scoped_interface;
mod r#type;
mod unknown;
mod variant;
mod weak;

pub use agile_reference::*;
pub use array::*;
pub use as_impl::*;
pub use com_object::*;
#[cfg(feature = "std")]
pub use event::*;
pub use guid::*;
pub use handles::*;
pub use inspectable::*;
pub use interface::*;
pub use out_param::*;
Expand All @@ -63,15 +54,8 @@ pub use runtime_name::*;
pub use runtime_type::*;
pub use scoped_interface::*;
pub use unknown::*;
pub use variant::*;
pub use weak::*;
pub use windows_implement::implement;
pub use windows_interface::interface;
pub use windows_result::*;
pub use windows_strings::*;

/// 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<C: RuntimeName, I: Interface>() -> Result<I> {
imp::factory::<C, I>()
}
22 changes: 22 additions & 0 deletions crates/libs/core/src/windows.rs
Original file line number Diff line number Diff line change
@@ -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<C: RuntimeName, I: Interface>() -> Result<I> {
imp::factory::<C, I>()
}
2 changes: 2 additions & 0 deletions crates/libs/cppwinrt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs>
*/

#![cfg(windows)]

const VERSION: &str = "2.0.240405.15";

/// Calls the C++/WinRT compiler with the given arguments.
Expand Down
1 change: 1 addition & 0 deletions crates/libs/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs>
*/

#![cfg(windows)]
#![no_std]

#[macro_use]
Expand Down
1 change: 1 addition & 0 deletions crates/libs/version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs>
*/

#![cfg(windows)]
#![cfg_attr(not(test), no_std)]

mod bindings;
Expand Down

0 comments on commit 66f1850

Please sign in to comment.