-
-
Notifications
You must be signed in to change notification settings - Fork 650
add Apple predefined version to cover OSX, iOS, TVOS, WatchOS and Vis… #21471
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#21471" |
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.
You will need to update druntime/test/importc_compare/src/importc_compare.d
which does
version (OSX)
version = Apple;
version (iOS)
version = Apple;
version (TVOS)
version = Apple;
version (WatchOS)
version = Apple;
which will now fail because it tries to define a redefined version.
Please also open a corresponding Spec PR to add the version.
Please also update the verion predefined tests compiler/test/fail_compilation/reserved_version.d
and compiler/test/fail_compilation/reserved_version_switch.d
for this predefined version.
I propose adding 2 new version definitions: iOS derived platforms have their own set of (higher level) APIs which are incompatible with the desktop and visionOS APIs. (Eg. AppKit vs UIKit) |
implemented requested changes
@LunaTheFoxgirl Thank you for your suggestions! |
For the redefinition error, you might say assigning a predefined version is a no-op. So if you're on Windows and do |
@@ -196,7 +196,8 @@ void addPredefinedGlobalIdentifiers(const ref Target tgt) | |||
} | |||
case OS.OSX: | |||
{ | |||
predef("OSX"); | |||
predef("OSX"); // macOS | |||
predef("Apple"); // macOS is one of Apple's operating systems | |||
// For legacy compatibility | |||
predef("darwin"); |
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.
interesting that this is there, yeah i do kinda recall the old days of D when it used this instead of OSX or whatever, but i forgot all about it.
it'll be less useful in druntime and more useful in graphical apps; the low level stuff is mostly the same; where it differs is in the APIs for stuff like opening a window, drawing widgets, opening file selection dialogs, etc. libraries targeting iOS derivatives as well as macOS right now have to do the same as druntime with the Darwin thing; just with a subset of Apple platforms that target their mobile APIs. Eg. If you want to draw with Metal onto a view currently you'd need to implement the visionOS counts as a bit of its own platform since it has its own third API set for its foveated rendering. |
I see no problem here. I would really like to see these definitions moved out of the compiler and into some form of external platform configuration, though. Maybe someday far in the future. |
Frankly, I am thinking the panoply of Apple operating system predefines has gone overboard. The symptom of that is the prevalence of this and related sequences: version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin; It tells me that, as far as the compiler's code generation is concerned, there is not a substantive difference between them. I'd be happy with just |
What are the target triplets for these mobile systems? |
|
The difference between them are mainly outside of the D runtime's scope. But for all intents and purposes they are seperate systems and having the seperation is useful if you for example develop apps that you want to be portable across macOS, iOS and iPadOS. While iPadOS and iOS count both as "iOS"; in reality there's important API differences that would cause compilation errors or segfaults. Having the D compiler provide these is useful for developers; in that we don't have to redefine it for every library and application we make. |
…ionOS
The Apple operating systems OSX, iOS, TVOS, WatchOS and VisionOS are close enough that we see various sequences of the following code repeated in druntime:
Like
Windows
covers bothWin32
andWin64
,Apple
will cover those versions.