Change Info::version() to Version::version()

This commit is contained in:
Alexander Karatarakis 2017-02-17 20:08:29 -08:00
parent 7ae6c21526
commit ac2ec94129
7 changed files with 30 additions and 32 deletions

View File

@ -121,6 +121,7 @@ namespace vcpkg::Commands
namespace Version
{
const std::string& version();
void perform_and_exit(const vcpkg_cmd_arguments& args);
}

View File

@ -4,7 +4,5 @@
namespace vcpkg::Info
{
const std::string& version();
const std::string& email();
}

View File

@ -109,7 +109,7 @@ namespace vcpkg::Commands::Build
" Vcpkg version: %s\n"
"\n"
"Additionally, attach any relevant sections from the log files above."
, spec.toString(), Info::version());
, spec.toString(), Version::version());
}
void perform_and_exit(const package_spec& spec, const fs::path& port_dir, const std::unordered_set<std::string>& options, const vcpkg_paths& paths)

View File

@ -80,7 +80,7 @@ namespace vcpkg::Commands::Update
auto num1 = sscanf_s(version_contents->c_str(), "\"%d.%d.%d\"", &maj1, &min1, &rev1);
int maj2, min2, rev2;
auto num2 = sscanf_s(Info::version().c_str(), "%d.%d.%d-", &maj2, &min2, &rev2);
auto num2 = sscanf_s(Version::version().c_str(), "%d.%d.%d-", &maj2, &min2, &rev2);
if (num1 == 3 && num2 == 3)
{

View File

@ -1,10 +1,33 @@
#include "pch.h"
#include "vcpkg_Commands.h"
#include "vcpkg_System.h"
#include "vcpkg_info.h"
#include "metrics.h"
#define STRINGIFY(X) #X
#define MACRO_TO_STRING(X) STRINGIFY(X)
#define VCPKG_VERSION_AS_STRING MACRO_TO_STRING(VCPKG_VERSION)"" // Double quotes needed at the end to prevent blank token
namespace vcpkg::Commands::Version
{
const std::string& version()
{
static const std::string s_version =
#include "../VERSION.txt"
#pragma warning( push )
#pragma warning( disable : 4003)
// VCPKG_VERSION can be defined but have no value, which yields C4003.
+ std::string(VCPKG_VERSION_AS_STRING)
#pragma warning( pop )
#ifndef NDEBUG
+ std::string("-debug")
#endif
+ std::string(GetCompiledMetricsEnabled() ? "" : "-external");
return s_version;
}
void perform_and_exit(const vcpkg_cmd_arguments& args)
{
args.check_exact_arg_count(0);
@ -12,7 +35,7 @@ namespace vcpkg::Commands::Version
System::println("Vcpkg package management program version %s\n"
"\n"
"See LICENSE.txt for license information.", Info::version()
"See LICENSE.txt for license information.", version()
);
exit(EXIT_SUCCESS);
}

View File

@ -192,7 +192,7 @@ int wmain(const int argc, const wchar_t* const* const argv)
Flush();
});
TrackProperty("version", Info::version());
TrackProperty("version", Commands::Version::version());
const std::string trimmed_command_line = trim_path_from_command_line(Strings::utf16_to_utf8(GetCommandLineW()));
TrackProperty("cmdline", trimmed_command_line);
@ -238,7 +238,7 @@ int wmain(const int argc, const wchar_t* const* const argv)
<< " " << Info::email() << "\n"
<< "containing a brief summary of what you were trying to do and the following data blob:\n"
<< "\n"
<< "Version=" << Info::version() << "\n"
<< "Version=" << Commands::Version::version() << "\n"
<< "EXCEPTION='" << exc_msg << "'\n"
<< "CMD=\n";
for (int x = 0; x < argc; ++x)

View File

@ -1,32 +1,8 @@
#include "pch.h"
#include "vcpkg_info.h"
#include "metrics.h"
#define STRINGIFY(X) #X
#define MACRO_TO_STRING(X) STRINGIFY(X)
#define VCPKG_VERSION_AS_STRING MACRO_TO_STRING(VCPKG_VERSION)"" // Double quotes needed at the end to prevent blank token
namespace vcpkg::Info
{
const std::string& version()
{
static const std::string s_version =
#include "../VERSION.txt"
#pragma warning( push )
#pragma warning( disable : 4003)
// VCPKG_VERSION can be defined but have no value, which yields C4003.
+ std::string(VCPKG_VERSION_AS_STRING)
#pragma warning( pop )
#ifndef NDEBUG
+ std::string("-debug")
#endif
+ std::string(GetCompiledMetricsEnabled() ? "" : "-external");
return s_version;
}
const std::string& email()
{
static const std::string s_email = R"(vcpkg@microsoft.com)";