-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add the GetPlatformInfo action #55
Conversation
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.
Thanks for this pull request, a lot of solid research! I left some initial comments that can shape how the overall code looks in the future, so not diving into details yet.
fn main() { | ||
#[cfg(all(target_os = "linux", feature = "action-platform-info"))] | ||
{ | ||
println!("cargo:rerun-if-changed=src/action/libc_version.c"); | ||
|
||
cc::Build::new() | ||
.file("src/action/libc_version.c") | ||
.compile("liblibc_version.a"); | ||
} | ||
} |
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.
I am affraid build script is not an option — this does not play well with our internal build infrastructure (for rrg-proto
I already have to do some awkward workarounds).
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.
Yes, we can scrap the build script. The libc::gnu_get_libc_version function is now available in the standard library.
cocoa = { git = "https://github.com/servo/core-foundation-rs.git", rev = "786895643140fa0ee4f913d7b4aeb0c4626b2085", optional = true } | ||
objc = { version = "0.2", optional = true } |
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.
These seem like a quite heavy dependencies, I wonder if there is a way to avoid these. Moreover, I would prefer not to depend on anything that is not on crates.io because of our internal build infrastructure.
#include <features.h> | ||
#ifdef __GNU_LIBRARY__ | ||
#include <gnu/libc-version.h> | ||
#else | ||
#include <stddef.h> | ||
#endif | ||
|
||
const char *libc_version(void) { | ||
#ifdef __GNU_LIBRARY__ | ||
return gnu_get_libc_version(); | ||
#else | ||
return NULL; | ||
#endif | ||
} |
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.
What is the benefit over libc::gnu_get_libc_version
?
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.
Yes, excellent. I did not know that the gnu_get_* APIs were added recently
/// The system platform (Windows|Darwin|Linux). | ||
system: String, |
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.
Why not an enum
?
/// The architecture of this binary. (Note this can be different from | ||
/// the machine architecture in the case of a 32 bit binary running | ||
/// on a 64 bit system) | ||
architecture: String, |
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.
Since this just uses std::env::consts::ARCH
this can be typed as &'static str
.
Adds the GetPlatformInfo action.
The implementation is following the Python cpython runtime, but is not as backwards compatible.
Known compatibility requirements
Comparison matrix table of the protocol buffer properties (source code)
system
node
release
version
machine
kernel
fqdn
install_date
libc_ver
architecture
pep425tag
Differences (marked with an asterisk * in the comparison matrix table above)
release
andversion
properties. As the library is quite extensive (source code), the raw values from libc::utsname are used instead. The conversion to a human readable format should be done on the server.pep425tag
property is always unset, as it only exists on Python to identify the unique signature of a Python runtime (PEP 425 specification).libc_version
property is only set, if the client was compiled against the GNU libc library.release
property is hardcoded and set to the value "OSX" by default, similar to the grr client (source code).version
property is set using the NSProcessInfo.processInfo function. The interface containing the operating system version is available equal to or after MacOS 10.10. In the Python cpython runtime implementation, the MacOS version is read using the SystemVersion.plist file (source code).system
property is hardcoded and set to the value "Windows" by default.version
property does not include the service pack version. The service pack version can be read using the GetVersionExA function, but this function might be altered or unavailable for releases after Windows 8.1. The concept of service packs is obsolete since Windows 10.machine
property is set using the GetVersion function and uses the SYSTEM_INFO structure to determine the processor architecture.Example - Linux
Example - MacOS
Example - Windows
References
Resolves #6