contextfree / winrt-rust

Use and (eventually) make Windows Runtime APIs with Rust
Apache License 2.0
142 stars 10 forks source link

Add Cargo feature flags to select Assemblies #19

Closed Boddlnagg closed 7 years ago

Boddlnagg commented 7 years ago

Add a feature flag for each WinRT winmd file, like

"windows.applicationmodel" = []
"windows.data" = []
"windows.devices" = []
"windows.gaming" = []
"windows.globalization" = []
"windows.graphics" = []
"windows.management" = []
"windows.media" = []
"windows.networking" = []
"windows.perception" = []
"windows.security" = []
"windows.services" = []
"windows.storage" = []
"windows.system" = []
"windows.ui" = []
"windows.ui.xaml" = ["windows.ui"]
"windows.web" = []

Then, conditionally compile modules only if the containing assembly is selected and strip out (i.e. conditionally disable) any methods that depend on type definitions from other assemblies. To keep the right VTables, we need to replace disabled methods with dummy methods, because VTable slots depend entirely on the order of declarations.

Boddlnagg commented 7 years ago

Windows.Foundation is intentionally missing from the list above, because it should be unconditionally enabled, since basically everything else depends on it and it is quite small.