Repository navigation
Return accurate system name by changing order of return - #1474
Conversation
Android builds also set NEKO_LINUX (the compiler defines __linux__), so systemName() returned "Linux" before it reached the Android check. Apple's other systems also set NEKO_MAC (__APPLE__), so iOS, tvOS and watchOS returned "Mac". Check those systems first, using the toolchains' flags (ANDROID, IPHONE, APPLETV, HX_APPLEWATCH). Emscripten also moves ahead of Linux, for older versions that define __linux__. The other systems' names are unchanged.
| #elif defined(ANDROID) | ||
| return HX_CSTRING("Android"); | ||
| #elif defined(__EMSCRIPTEN__) | ||
| return HX_CSTRING("Emscripten"); |
There was a problem hiding this comment.
So is it also a problem with emscripten? Which of the defines overrides it?
EDIT: Sorry, I missed the note in the commit message: Emscripten also moves ahead of Linux, for older versions that define __linux__.. Do we know what emscripten environments would have set __linux__? I wasn't able to find information online, so is it definitely not a problem on the hxcpp side?
There was a problem hiding this comment.
I'll drop it and keep this PR to the cases that are actually wrong
| #elif defined(IPHONE) | ||
| return HX_CSTRING("iOS"); | ||
| #elif defined(APPLETV) | ||
| return HX_CSTRING("tvOS"); |
There was a problem hiding this comment.
Just to also leave a note, hashlink provides a precedent for these identifiers:
There was a problem hiding this comment.
I don't really use hashlink I just assumed it was all fed through here, given this is cpp I never thought farther than that lol. The names here match HashLink's (iOS, tvOS, Android). HashLink has no watchOS case; I used watchOS to match Apple's naming next to tvOS, but I'm happy to drop it if you'd rather stay with what HashLink has.
I think it's more accurate to not use the hashlink prefix on cpp though
There was a problem hiding this comment.
Yeah, this is all good, just wanted to leave a note so we make sure it matches what other targets are already returning on these platforms. Hashlink doesn't support watchOS but hxcpp does, so I think it makes sense to have it here.
There was a problem hiding this comment.
cool, so what would you like the pr to be changed to?
There was a problem hiding this comment.
to clarify, I figured putting it in order of specificity would be best because I don't think there's many situations where one would want to get linux back on an android device. I don't think there could be any conflicts here, this API is likely not used much because of the current output
There was a problem hiding this comment.
There is no issue for me with the apple ones, I just wanted to note the reference to compare with another haxe target.
But for the emscripten change, if we don't have a specific reason to move it then we can probably keep it as is.
There was a problem hiding this comment.
I have moved emscripten back
|
Thanks! |
On Android,
Sys.systemName()returned "Linux", and on iPhone, Apple TV and Apple Watch it returned "Mac". Android is built on Linux and those Apple systems share code with macOS, so they also pass the Linux and Mac checks.The fix moves the more specific checks first, so each system now reports its own name. Linux, macOS, Windows and the rest report what they did before.
I would like to confirm that I haven't tested the macos side of things just yet as I don't have the devices but I suspect the logic wouldn't break - please let me know if it's a problem and I can undo the change for those platforms in particular