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:
Liav A 2023-09-16 21:30:04 +03:00 committed by Andrew Kaster
parent 5f3ef1aa9e
commit 7e8dfe758c
Notes: sideshowbarker 2024-07-17 09:41:18 +09:00
2 changed files with 18 additions and 5 deletions

View file

@ -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

View file

@ -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