mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-17 04:18:10 +08:00
Introduce Version::warn_if_vcpkg_version_mismatch()
This commit is contained in:
parent
263466642f
commit
2d6029e41c
@ -210,6 +210,7 @@ namespace vcpkg::Commands
|
||||
namespace Version
|
||||
{
|
||||
const std::string& version();
|
||||
void warn_if_vcpkg_version_mismatch(const VcpkgPaths& paths);
|
||||
void perform_and_exit(const VcpkgCmdArguments& args);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "Paragraphs.h"
|
||||
#include "vcpkg_Commands.h"
|
||||
#include "vcpkg_Files.h"
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkglib.h"
|
||||
|
||||
@ -22,7 +21,7 @@ namespace vcpkg::Commands::Update
|
||||
std::vector<OutdatedPackage> output;
|
||||
for (const StatusParagraph* pgh : installed_packages)
|
||||
{
|
||||
auto it = src_names_to_versions.find(pgh->package.spec.name());
|
||||
const auto it = src_names_to_versions.find(pgh->package.spec.name());
|
||||
if (it == src_names_to_versions.end())
|
||||
{
|
||||
// Package was not installed from portfile
|
||||
@ -69,30 +68,7 @@ namespace vcpkg::Commands::Update
|
||||
install_line);
|
||||
}
|
||||
|
||||
auto version_file = paths.get_filesystem().read_contents(paths.root / "toolsrc" / "VERSION.txt");
|
||||
if (auto version_contents = version_file.get())
|
||||
{
|
||||
int maj1, min1, rev1;
|
||||
auto num1 = sscanf_s(version_contents->c_str(), "\"%d.%d.%d\"", &maj1, &min1, &rev1);
|
||||
|
||||
int maj2, min2, rev2;
|
||||
auto num2 = sscanf_s(Version::version().c_str(), "%d.%d.%d-", &maj2, &min2, &rev2);
|
||||
|
||||
if (num1 == 3 && num2 == 3)
|
||||
{
|
||||
if (maj1 != maj2 || min1 != min2 || rev1 != rev2)
|
||||
{
|
||||
System::println("Different source is available for vcpkg (%d.%d.%d -> %d.%d.%d). Use "
|
||||
".\\bootstrap-vcpkg.bat to update.",
|
||||
maj2,
|
||||
min2,
|
||||
rev2,
|
||||
maj1,
|
||||
min1,
|
||||
rev1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Version::warn_if_vcpkg_version_mismatch(paths);
|
||||
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace vcpkg::Commands::Version
|
||||
{
|
||||
const std::string& version()
|
||||
{
|
||||
static const std::string s_version =
|
||||
static const std::string S_VERSION =
|
||||
#include "../VERSION.txt"
|
||||
|
||||
+std::string(VCPKG_VERSION_AS_STRING)
|
||||
@ -21,7 +21,35 @@ namespace vcpkg::Commands::Version
|
||||
+ std::string("-debug")
|
||||
#endif
|
||||
+ std::string(Metrics::get_compiled_metrics_enabled() ? Strings::EMPTY : "-external");
|
||||
return s_version;
|
||||
return S_VERSION;
|
||||
}
|
||||
|
||||
void warn_if_vcpkg_version_mismatch(const VcpkgPaths& paths)
|
||||
{
|
||||
auto version_file = paths.get_filesystem().read_contents(paths.root / "toolsrc" / "VERSION.txt");
|
||||
if (const auto version_contents = version_file.get())
|
||||
{
|
||||
int maj1, min1, rev1;
|
||||
const auto num1 = sscanf_s(version_contents->c_str(), "\"%d.%d.%d\"", &maj1, &min1, &rev1);
|
||||
|
||||
int maj2, min2, rev2;
|
||||
const auto num2 = sscanf_s(Version::version().c_str(), "%d.%d.%d-", &maj2, &min2, &rev2);
|
||||
|
||||
if (num1 == 3 && num2 == 3)
|
||||
{
|
||||
if (maj1 != maj2 || min1 != min2 || rev1 != rev2)
|
||||
{
|
||||
System::println("Different source is available for vcpkg (%d.%d.%d -> %d.%d.%d). Use "
|
||||
".\\bootstrap-vcpkg.bat to update.",
|
||||
maj2,
|
||||
min2,
|
||||
rev2,
|
||||
maj1,
|
||||
min1,
|
||||
rev1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void perform_and_exit(const VcpkgCmdArguments& args)
|
||||
|
Loading…
x
Reference in New Issue
Block a user