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
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
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 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