Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Idea] On-demand code generation #68

Open
Boddlnagg opened this issue Mar 1, 2019 · 0 comments
Open

[Idea] On-demand code generation #68

Boddlnagg opened this issue Mar 1, 2019 · 0 comments

Comments

@Boddlnagg
Copy link
Collaborator

Boddlnagg commented Mar 1, 2019

I had an idea that might alleviate the pain of this crate's compile times (#26): Once we have a code generator in Rust (#50) – which would probably be quite fast (the current one written in C# is already quite fast) – we could run the code generator via procedural macro and that procedural macro could take use statements of WinRT types/modules as input. We would then generate only those pieces of the APIs that are needed for the used functionality (and required dependencies).

Users of winrt-rust would then usually have one module/file in their project with a content like this:

winrt! {
   use windows::foundation::{Uri, PropertyValue};
   use windows::devices::enumeration::DeviceInformation;
   use windows::devices::midi::*; // `*` could be allowed
}

... and that module becomes the "root" module for their personal stripped-down version of the generated projection sources. Which would probably compile by orders of magnitude faster.

This implies that the projections are always generated with whatever version of the metadata assemblies the user has installed. However, there's even a nice side-effect: We could add another annotation in the macro with which the user specifies the metadata assembly from which the code generator will read all the definitions. So one could integrate custom WinRT types, or request a specific version, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant