Skip to content

Return accurate system name by changing order of return - #1474

Merged
tobil4sk merged 3 commits into
HaxeFoundation:masterfrom
Jarrio:master
Nov 29, 2026
Merged

tobil4sk merged 3 commits into
HaxeFoundation:masterfrom
Jarrio:master

Conversation

@Jarrio

@Jarrio Jarrio commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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

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.
Comment thread src/hx/libs/std/Sys.cpp Outdated
#elif defined(ANDROID)
return HX_CSTRING("Android");
#elif defined(__EMSCRIPTEN__)
return HX_CSTRING("Emscripten");

@tobil4sk tobil4sk Nov 26, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll drop it and keep this PR to the cases that are actually wrong

Comment thread src/hx/libs/std/Sys.cpp
#elif defined(IPHONE)
return HX_CSTRING("iOS");
#elif defined(APPLETV)
return HX_CSTRING("tvOS");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to also leave a note, hashlink provides a precedent for these identifiers:

https://github.com/HaxeFoundation/hashlink/blob/8425bde866170df7d8f99c3165840c32d683a8e9/src/std/sys.c#L107-L110

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, so what would you like the pr to be changed to?

@Jarrio Jarrio Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved emscripten back

@tobil4sk
tobil4sk merged commit a3de84f into HaxeFoundation:master Nov 29, 2026
121 of 122 checks passed
@tobil4sk

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants