diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-09-14 04:04:15 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-09-14 04:08:02 -0700 |
| commit | 2d6029e41c68fd44b22f8cef1b13fbaa44c8fad9 (patch) | |
| tree | bee6b86815c26a52dbf83844991da4f4a006ebc0 /toolsrc/src/commands_version.cpp | |
| parent | 263466642face5485d50bccb60b45e774fe31fd9 (diff) | |
| download | vcpkg-2d6029e41c68fd44b22f8cef1b13fbaa44c8fad9.tar.gz vcpkg-2d6029e41c68fd44b22f8cef1b13fbaa44c8fad9.zip | |
Introduce Version::warn_if_vcpkg_version_mismatch()
Diffstat (limited to 'toolsrc/src/commands_version.cpp')
| -rw-r--r-- | toolsrc/src/commands_version.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/toolsrc/src/commands_version.cpp b/toolsrc/src/commands_version.cpp index af81cd26e..fdbe7b66c 100644 --- a/toolsrc/src/commands_version.cpp +++ b/toolsrc/src/commands_version.cpp @@ -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) |
