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

Better os version handling #3448

Merged
merged 5 commits into from
Aug 11, 2018
Merged

Better os version handling #3448

merged 5 commits into from
Aug 11, 2018

Conversation

hrubymar10
Copy link
Member

@hrubymar10 hrubymar10 commented Aug 10, 2018

Old os version detection was in case of macOS buggy so I reworked it. It is faster now and native.

TODO

  • Create new os version handler for macOS
  • Prepare apple specific code for iOS implementation

Idea

I used desktop::apple::os_version() namespace. It may be nice to rework rest of platform specific code to use this namespace style (not only os_version, but also notifications, ...)

#endif

//
// POSIX uname version.
Copy link
Member

Choose a reason for hiding this comment

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

Please don't remove this code. It's a fallback in case /etc/lsb_release doesn't exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done - 1bb926a

@@ -151,6 +151,22 @@ std::string os_version()
if(!ver.empty()) {
return ver;
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

It's better to not use else for this, in case /etc/lsb_release is empty (see the check right above).

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, that's true

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed - e5411de

@hrubymar10
Copy link
Member Author

If you don't like my idea with renaming namespaces to desktop::linux::os_version() and etc., then it could be merged now

Copy link
Member

@jyrkive jyrkive left a comment

Choose a reason for hiding this comment

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

I don't really care about namespace renaming either way.

//

Copy link
Member

Choose a reason for hiding this comment

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

Trailing space, please remove.

utsname u;

Copy link
Member

Choose a reason for hiding this comment

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

Trailing space.

if(uname(&u) != 0) {
ERR_DU << "os_version: uname error (" << strerror(errno) << ")\n";
}

return formatter() << u.sysname << ' '

Copy link
Member

Choose a reason for hiding this comment

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

Trailing space.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed - d6258b5


return formatter() << u.sysname << ' '
return formatter() << u.sysname << ' '
Copy link
Member

Choose a reason for hiding this comment

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

Please don't try to align the fields (they are not aligned; note that the following lines are indented with tabs).

@jyrkive jyrkive merged commit c10fc7f into 1.14 Aug 11, 2018
@jyrkive
Copy link
Member

jyrkive commented Aug 11, 2018

Thank you for the pull request! 👍

@jyrkive jyrkive deleted the better_os_version_handling branch August 11, 2018 11:33
jyrkive pushed a commit to jyrkive/wesnoth that referenced this pull request Aug 11, 2018
This new implementation works more reliably, avoids spawning subshells, and is faster.
@hrubymar10 hrubymar10 added this to the 1.14.5 milestone Aug 12, 2018
jostephd pushed a commit to jostephd/wesnoth that referenced this pull request Oct 6, 2018
This new implementation works more reliably, avoids spawning subshells, and is faster.
jostephd pushed a commit to jostephd/wesnoth that referenced this pull request Oct 7, 2018
This new implementation works more reliably, avoids spawning subshells, and is faster.

(cherry-picked from commit 4282ee3)
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.

None yet

2 participants