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

Put methods behind feature flags #328

Merged
merged 30 commits into from
Jan 12, 2023
Merged

Conversation

madsmtm
Copy link
Owner

@madsmtm madsmtm commented Jan 9, 2023

Fixes #311.

A few manual fixes are still necessary to handle structs and typedefs that use class types, and the user has to specify e.g. ["Foundation", "Foundation_NSString"] instead of just ["Foundation_NSString"], but it should be workable.

@madsmtm madsmtm added the A-framework Affects the framework crates and the translator for them label Jan 9, 2023
@silvanshade
Copy link
Contributor

Awesome, thanks for starting on this!

@silvanshade
Copy link
Contributor

I made some additions in a local branch at https://github.com/silvanshade/objc2/tree/icrate-behind-feature-flags. It's able to automatically emit the features to the icrate/Cargo.toml (see the comment at the end of the file) although it's apparently missing some cases, e.g.:

feature `AppKit_NSScrubberItemView` includes `AppKit_NSScrubberArrangedView` which is neither a dependency nor another feature

In any case, may not be the best way to do things but feel free to use any of that if it's useful.

@madsmtm madsmtm force-pushed the icrate-behind-feature-flags branch from 4e367b7 to d614bd4 Compare January 10, 2023 16:29
@madsmtm
Copy link
Owner Author

madsmtm commented Jan 10, 2023

Thanks, I started from what you had and have gotten feature emission to work now (not currently updated in-branch).

@madsmtm madsmtm force-pushed the icrate-behind-feature-flags branch from d614bd4 to 0274b5f Compare January 10, 2023 22:43
@madsmtm madsmtm force-pushed the icrate-behind-feature-flags branch from e01685b to 2d0e590 Compare January 11, 2023 19:00
@madsmtm
Copy link
Owner Author

madsmtm commented Jan 11, 2023

So wrt. compilation-time improvements (approximate numbers):

Label --features=Foundation currently --features=Foundation now --features=Foundation_all now
debug check ~21s ~4s ~20s
debug build ~31s ~5s ~33s
release build ~30s ~4s ~26s

Tested with:

CMD=cargo +nightly build -picrate --features Foundation # or `check` or `build --release`
$CMD
cargo clean -picrate
$CMD

Which tells me that this is a definite improvement (and not even a regression when enabling many features), and it is definitely good enough for me to actually start using it in winit!

@madsmtm madsmtm added the enhancement New feature or request label Jan 11, 2023
@madsmtm madsmtm force-pushed the icrate-behind-feature-flags branch from a12addf to bea5c51 Compare January 11, 2023 20:20
@madsmtm madsmtm force-pushed the icrate-behind-feature-flags branch from 3609945 to fd61fe6 Compare January 11, 2023 20:47
@madsmtm madsmtm force-pushed the icrate-behind-feature-flags branch from 46b3e90 to ec2406c Compare January 11, 2023 22:15
@madsmtm madsmtm force-pushed the icrate-behind-feature-flags branch from 6153632 to 933b09c Compare January 11, 2023 23:51
@madsmtm madsmtm marked this pull request as ready for review January 12, 2023 02:49
@madsmtm madsmtm merged commit d6867b7 into master Jan 12, 2023
@madsmtm madsmtm deleted the icrate-behind-feature-flags branch January 12, 2023 05:09
@madsmtm madsmtm added this to the icrate v0.1.0 milestone Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve compilation time of icrate
2 participants