LibCore: Add a small library with only ArgsParser for DynamicLoader
This will be used in the DynamicLoader code, as it can't do syscalls via LibCore code. Because we can't use most of the LibCore code, we convert the versioning code in Version.cpp to use LibC uname() function.
This commit is contained in:
parent
5f3ef1aa9e
commit
7e8dfe758c
Notes:
sideshowbarker
2024-07-17 09:41:18 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/7e8dfe758c Pull-request: https://github.com/SerenityOS/serenity/pull/21101 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/BertalanD Reviewed-by: https://github.com/DanShaders ✅ Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 18 additions and 5 deletions
|
@ -17,6 +17,13 @@ set(SOURCES
|
|||
serenity_lib(LibCoreMinimal coreminimal)
|
||||
target_link_libraries(LibCoreMinimal PRIVATE LibSystem)
|
||||
|
||||
if (SERENITYOS)
|
||||
add_library(DynamicLoader_LibCoreArgsParser
|
||||
ArgsParser.cpp
|
||||
Version.cpp)
|
||||
target_link_libraries(DynamicLoader_LibCoreArgsParser PUBLIC DynamicLoader_CompileOptions)
|
||||
endif()
|
||||
|
||||
set(SOURCES
|
||||
AnonymousBuffer.cpp
|
||||
Command.cpp
|
||||
|
|
|
@ -5,18 +5,24 @@
|
|||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCore/Version.h>
|
||||
|
||||
#ifdef AK_OS_SERENITY
|
||||
# include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
namespace Core::Version {
|
||||
|
||||
ErrorOr<String> read_long_version_string()
|
||||
{
|
||||
#ifdef AK_OS_SERENITY
|
||||
auto uname = TRY(Core::System::uname());
|
||||
|
||||
auto const* version = uname.release;
|
||||
auto const* git_hash = uname.version;
|
||||
struct utsname uts;
|
||||
int rc = uname(&uts);
|
||||
if ((rc) < 0) {
|
||||
return Error::from_syscall("uname"sv, rc);
|
||||
}
|
||||
auto const* version = uts.release;
|
||||
auto const* git_hash = uts.version;
|
||||
|
||||
return String::formatted("Version {} revision {}", version, git_hash);
|
||||
#else
|
||||
|
|
Loading…
Add table
Reference in a new issue