-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Gate web-sys
APIs on activated features
#790
Conversation
FYI: lots of CI failures |
Currently the compile times of `web-sys` are unfortunately prohibitive, increasing the barrier to using it. This commit updates the crate to instead have all APIs gated by a set of Cargo features which affect what bindings are generated at compile time (and which are then compiled by rustc). It's significantly faster to activate only a handful of features vs all thousand of them! A magical env var is added to print the list of all features that should be generated, and then necessary logic is added to ferry features from the build script to the webidl crate which then uses that as a filter to remove items after parsing. Currently parsing is pretty speedy so we'll unconditionally parse all WebIDL files, but this may change in the future! For now this will make the `web-sys` crate a bit less ergonomic to use as lots of features will need to be specified, but it should make it much more approachable in terms of first-user experience with compile times.
7f2acff
to
97bd967
Compare
Ok I think CI is green, AppVeyor seems to have terminated but doesn't explain why... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful!
# the features must all be manually activated. | ||
[features] | ||
AbortController = [] | ||
AbortSignal = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeeeeeaaaaaaah!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh also: this comment about features should probably go into the README and/or src/lib.rs too
// Iteratively prune all entries from the AST which reference undefined | ||
// fields. Each pass may remove definitions of types and so we need to | ||
// reexecute this pass to see if we need to keep removing types until we | ||
// reach a steady state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One might describe the pruning as a monotonic function, and iterating to a fixed point with this monotonic function as a "monotone framework"... ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎓
None => return, | ||
}; | ||
let mut required = BTreeSet::new(); | ||
item.imported_type_references(&mut |f| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super happy that this ended up being generally useful!
Currently the compile times of
web-sys
are unfortunately prohibitive,increasing the barrier to using it. This commit updates the crate to instead
have all APIs gated by a set of Cargo features which affect what bindings are
generated at compile time (and which are then compiled by rustc). It's
significantly faster to activate only a handful of features vs all thousand of
them!
A magical env var is added to print the list of all features that should be
generated, and then necessary logic is added to ferry features from the build
script to the webidl crate which then uses that as a filter to remove items
after parsing. Currently parsing is pretty speedy so we'll unconditionally parse
all WebIDL files, but this may change in the future!
For now this will make the
web-sys
crate a bit less ergonomic to use as lotsof features will need to be specified, but it should make it much more
approachable in terms of first-user experience with compile times.