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

Split icrate into one crate per framework #592

Merged
merged 1 commit into from
Apr 17, 2024
Merged

Split icrate into one crate per framework #592

merged 1 commit into from
Apr 17, 2024

Conversation

madsmtm
Copy link
Owner

@madsmtm madsmtm commented Mar 19, 2024

Fixes #537.
Fixes #558.
Fixes #482.
Required for #408.

This should also improve compile times a bit, as Cargo can parallelize it much more, and it doesn't suffer from long download times.

The submodule path has been changed, in case git doesn't really show it you can view madsmtm/objc2-generated@cf34428 for the changed commit.

I'm fairly sure that the way we've chosen to do features won't turn into a breaking change, at the very least, #import <WebKit/WebView.h> makes the same, if not more types available to Objective-C, so it really shouldn't.

TODO:

  • Rename features to not contain the framework name Will do this in a follow-up PR.
  • Remove all mentions of icrate
  • Run full CI
  • Set up something to release these crates Will do this in a follow-up PR.

@madsmtm madsmtm added enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Mar 19, 2024
@madsmtm madsmtm force-pushed the split-icrate branch 4 times, most recently from 1108f8a to ff6a3e8 Compare March 19, 2024 23:43
@madsmtm madsmtm force-pushed the split-icrate branch 3 times, most recently from 9c65311 to d91dab1 Compare April 10, 2024 21:49
@MediaEnhanced
Copy link

I tried this branch out with a very basic NSApplication, one NSWindow, slightly custom NSEvent, example and could only get it to compile (and run) after performing the following find and replaces over the generated files:
use crate::AppKit::*; -> use crate::*;
use crate::CoreData::*; -> use objc2_core_data::*;
use crate::Foundation::*; -> use objc2_foundation::*;
use crate::common::*; -> use objc2_helpers::*;

Not sure if that part in the "header-translator" has to be updated as this branch is WIP or if I setup something incorrectly. I also needed to remove the function feature restrictions for certain cross-framework restricted functions such as: NSWindow::initWithContentRect_styleMask_backing_defer
and others even though my Cargo.toml had the following:

objc2 = { path = "src/icrate/crates/objc2" }
objc2-foundation = { path = "src/icrate/framework-crates/objc2-foundation", features = [
"Foundation_NSString",
"Foundation_NSGeometry",
"Foundation_NSNotification",
"Foundation_NSObject",
"Foundation_NSDate",
"Foundation_NSThread",
"Foundation_NSRunLoop",
"Foundation_NSObjCRuntime",
] }
objc2-app-kit = { path = "src/icrate/framework-crates/objc2-app-kit", features = [
"AppKit_NSApplication",
"AppKit_NSRunningApplication",
"AppKit_NSGraphics",
"AppKit_NSGraphicsContext",
"AppKit_NSEvent",
"AppKit_NSWindow",
"AppKit_NSResponder",
] }

This branch did seem to build faster on my 2010 iMac compared to the master branch!

@madsmtm
Copy link
Owner Author

madsmtm commented Apr 11, 2024

The development here has been... quite haphazard. Will try to get it into a better state soon!

But I suspect that the issue you've been hitting is that git doesn't really like changing the path of a submodule, so you have to somehow tell it to re-initialize it - which I did manually by moving some directories, but there probably is a proper way of doing it.

Additionally:
- Add helper module `objc2::__framework_prelude` with common imports.
- Make `block2` an optional dependency.
- Make most framework crates except `objc2-foundation` optional.
- Move framework changelog to `objc2::topics::about_generated::changelog`.
- Add full list of crates in `objc2::topics::about_generated::list`.
- Document cargo features in `objc2::topics::about_generated::cargo_features`.
@madsmtm madsmtm merged commit 38e8a86 into master Apr 17, 2024
19 checks passed
@madsmtm madsmtm deleted the split-icrate branch April 17, 2024 01:39
@madsmtm madsmtm mentioned this pull request Apr 17, 2024
8 tasks
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
2 participants