From b7f9634f6c914332196a287ef9a1ea9d4e531483 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 19 Aug 2023 16:31:07 -0600 Subject: [PATCH] LibCore: Add default version for Lagom applications Instead of grabbing `uname -vr` on non-Serenity platforms, let's just hardcode a version. This prevents Lagom builds of applications like Shell or Ladybird from reporting their version as that of the host OS. --- Userland/Libraries/LibCore/ArgsParser.cpp | 2 ++ Userland/Libraries/LibCore/Version.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index 78a12c9e50..d3f13432f5 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -383,6 +383,8 @@ void ArgsParser::print_usage_markdown(FILE* file, StringView argv0) void ArgsParser::print_version(FILE* file) { + // FIXME: Allow applications to override version string for --version. + // Especially useful for Lagom applications outln(file, Core::Version::read_long_version_string().release_value_but_fixme_should_propagate_errors()); } diff --git a/Userland/Libraries/LibCore/Version.cpp b/Userland/Libraries/LibCore/Version.cpp index 202b59d2cc..6802829486 100644 --- a/Userland/Libraries/LibCore/Version.cpp +++ b/Userland/Libraries/LibCore/Version.cpp @@ -12,12 +12,16 @@ namespace Core::Version { ErrorOr 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; return String::formatted("Version {} revision {}", version, git_hash); +#else + return String::from_utf8("Version 1.0"sv); +#endif } }