-
Notifications
You must be signed in to change notification settings - Fork 39
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
Implement runtime availability checking #661
Conversation
21bbd88
to
6e50923
Compare
Noting my reasoning behind the name/syntax:
|
So, I tested using the So instead, |
6bfa34c
to
e8eab1e
Compare
Thanks for the review before @BlackHoleFox, really useful to get some feedback - if you feel like giving it another review, then feel free to do so now, I think I'm done with everything now. I will try to upstream this implementation to the standard library later (perhaps under |
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.
cant really speak for the macro implementation details since I'm bad at them, but this looks nice and the usability of the macro seems fine 👀
I will try to upstream this implementation to the standard library later
std
would probably want the CoreFoundation
approach like libcompiler-rt has since it avoids needing to link and load the entirely of libobjc
when only writing normal Rust apps. iirc you just recently removed that linkage from std
too. but that doesn't matter for this since its literally an objective-c crate :)
e8eab1e
to
35653b4
Compare
Thanks for the review though!
Yeah, unsure exactly which approach would be best there, since the only part that's really needed in |
This includes internal methods for looking up the OS version at runtime, and for looking up the deployment target at compile time.
Use atomics directly instead of the heavy `OnceLock`.
35653b4
to
4485634
Compare
Add macro for runtime availability checking, with static assertions against the deployment target that allows eliding the runtime checks when unnecessary.
Part of #266.
Usage:
Runtime lookup implementation tested on:
aarch64-apple-darwin
aarch64-apple-ios-macabi
x86_64-apple-ios-macabi
aarch64-apple-ios-sim
x86_64-apple-darwin
i686-apple-darwin
x86_64-apple-ios
armv7-apple-ios
TODO:
sysctl
.os_version!(macos = 15.0, ..)
version!(macos = 15.0, ..)
os_available!(macos = 15.0, ..)
available!(macos(15.0), ..)
available!(macos 15.0, ..)
available!(macOS = 15.0, ..)
available!(macos = 15.0, *)
available!(macos = 15.0, _)
Use macro in examples.No current examples where it makes sense.available!(macos = 15.0)
on e.g. iOS is desirable, or if we just want to returnfalse
here?