mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibCore+LibGUI: Define a Serenity version in LibCore
Before, `AboutDialog` and `ArgsParser` read from a build-time created file called `/res/version.ini`. This caused problems with utilities unveiling specific paths leaving the version file unaccessible. This commit hard-codes a serenity version in `LibCore`, and use it in `ArgsParser` and `AboutDialog`. The previous version contained the hash of the last GIT commit, this is omitted for the default use for the sake of simplicity.
This commit is contained in:
parent
e3f7753233
commit
ad80d4dce0
Notes:
sideshowbarker
2024-07-18 04:54:30 +09:00
Author: https://github.com/i3abghany Commit: https://github.com/SerenityOS/serenity/commit/ad80d4dce01 Pull-request: https://github.com/SerenityOS/serenity/pull/9661 Reviewed-by: https://github.com/nico ✅ Reviewed-by: https://github.com/sppmacd
3 changed files with 19 additions and 21 deletions
|
@ -7,7 +7,7 @@
|
|||
#include <AK/Format.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/Version.h>
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
@ -245,16 +245,7 @@ void ArgsParser::print_usage(FILE* file, const char* argv0)
|
|||
|
||||
void ArgsParser::print_version(FILE* file)
|
||||
{
|
||||
auto version_config = Core::ConfigFile::open("/res/version.ini");
|
||||
auto major_version = version_config->read_entry("Version", "Major", "0");
|
||||
auto minor_version = version_config->read_entry("Version", "Minor", "0");
|
||||
|
||||
StringBuilder builder;
|
||||
builder.appendff("{}.{}", major_version, minor_version);
|
||||
if (auto git_version = version_config->read_entry("Version", "Git", ""); git_version != "")
|
||||
builder.appendff(".g{}", git_version);
|
||||
|
||||
outln(file, builder.to_string());
|
||||
outln(file, Core::Version::SERENITY_VERSION);
|
||||
}
|
||||
|
||||
void ArgsParser::add_option(Option&& option)
|
||||
|
|
15
Userland/Libraries/LibCore/Version.h
Normal file
15
Userland/Libraries/LibCore/Version.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Mahmoud Mandour <ma.mandourr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace Core::Version {
|
||||
|
||||
constexpr StringView SERENITY_VERSION = "Version 1.0"sv;
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/Version.h>
|
||||
#include <LibGUI/AboutDialog.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
|
@ -92,15 +92,7 @@ AboutDialog::~AboutDialog()
|
|||
|
||||
String AboutDialog::version_string() const
|
||||
{
|
||||
auto version_config = Core::ConfigFile::open("/res/version.ini");
|
||||
auto major_version = version_config->read_entry("Version", "Major", "0");
|
||||
auto minor_version = version_config->read_entry("Version", "Minor", "0");
|
||||
|
||||
StringBuilder builder;
|
||||
builder.appendff("Version {}.{}", major_version, minor_version);
|
||||
if (auto git_version = version_config->read_entry("Version", "Git", ""); git_version != "")
|
||||
builder.appendff(".g{}", git_version);
|
||||
return builder.to_string();
|
||||
return Core::Version::SERENITY_VERSION;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue