diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-11-07 17:31:41 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-11-07 17:31:41 -0800 |
| commit | c91d8e41b60653b652b11c641f7a5b3d3eab7f6b (patch) | |
| tree | 6e81f76a7f1067bab8efdbb38e7b25338499f87f | |
| parent | 7a1bc07142577cce32ee88c8d8ef60b386d19b6a (diff) | |
| download | vcpkg-c91d8e41b60653b652b11c641f7a5b3d3eab7f6b.tar.gz vcpkg-c91d8e41b60653b652b11c641f7a5b3d3eab7f6b.zip | |
Introduce vcpkg_info.h/cpp
| -rw-r--r-- | toolsrc/include/vcpkg.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_info.h | 10 | ||||
| -rw-r--r-- | toolsrc/src/commands_help.cpp | 6 | ||||
| -rw-r--r-- | toolsrc/src/commands_installation.cpp | 3 | ||||
| -rw-r--r-- | toolsrc/src/commands_update.cpp | 3 | ||||
| -rw-r--r-- | toolsrc/src/main.cpp | 7 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_info.cpp | 34 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_version.cpp | 25 | ||||
| -rw-r--r-- | toolsrc/vcpkglib/vcpkglib.vcxproj | 3 | ||||
| -rw-r--r-- | toolsrc/vcpkglib/vcpkglib.vcxproj.filters | 9 |
10 files changed, 63 insertions, 39 deletions
diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h index b9d646e70..30d8adbf8 100644 --- a/toolsrc/include/vcpkg.h +++ b/toolsrc/include/vcpkg.h @@ -21,6 +21,4 @@ namespace vcpkg void deinstall_package(const vcpkg_paths& paths, const package_spec& spec, StatusParagraphs& status_db); void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db); - - const std::string& version(); } // namespace vcpkg diff --git a/toolsrc/include/vcpkg_info.h b/toolsrc/include/vcpkg_info.h new file mode 100644 index 000000000..01da06307 --- /dev/null +++ b/toolsrc/include/vcpkg_info.h @@ -0,0 +1,10 @@ +#pragma once + +#include <string> + +namespace vcpkg { namespace Info +{ + const std::string& version(); + + const std::string& email(); +}} diff --git a/toolsrc/src/commands_help.cpp b/toolsrc/src/commands_help.cpp index 194e809b1..fd02d948e 100644 --- a/toolsrc/src/commands_help.cpp +++ b/toolsrc/src/commands_help.cpp @@ -1,6 +1,6 @@ #include "vcpkg_Commands.h" -#include "vcpkg.h" #include "vcpkg_System.h" +#include "vcpkg_info.h" namespace vcpkg { @@ -9,7 +9,7 @@ namespace vcpkg args.check_exact_arg_count(0); System::println("Vcpkg package management program version %s\n" "\n" - "See LICENSE.txt for license information.", vcpkg::version() + "See LICENSE.txt for license information.", Info::version() ); exit(EXIT_SUCCESS); } @@ -39,7 +39,7 @@ namespace vcpkg void contact_command(const vcpkg_cmd_arguments& args) { args.check_exact_arg_count(0); - System::println("Send an email to vcpkg@microsoft.com with any feedback."); + System::println("Send an email to %s with any feedback.", Info::email()); exit(EXIT_SUCCESS); } diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index 3f40ba023..460fa1818 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -10,6 +10,7 @@ #include "vcpkg_Input.h" #include "vcpkg_Maps.h" #include "Paragraphs.h" +#include "vcpkg_info.h" namespace vcpkg { @@ -50,7 +51,7 @@ namespace vcpkg " Vcpkg version: %s\n" "\n" "Additionally, attach any relevant sections from the log files above." - , to_string(spec), version()); + , to_string(spec), Info::version()); TrackProperty("error", "build failed"); TrackProperty("build_error", to_string(spec)); exit(EXIT_FAILURE); diff --git a/toolsrc/src/commands_update.cpp b/toolsrc/src/commands_update.cpp index b448091f7..2d7444392 100644 --- a/toolsrc/src/commands_update.cpp +++ b/toolsrc/src/commands_update.cpp @@ -3,6 +3,7 @@ #include "vcpkg_System.h" #include "vcpkg_Files.h" #include "Paragraphs.h" +#include "vcpkg_info.h" namespace vcpkg { @@ -77,7 +78,7 @@ namespace vcpkg auto num1 = sscanf_s(version_contents->c_str(), "\"%d.%d.%d\"", &maj1, &min1, &rev1); int maj2, min2, rev2; - auto num2 = sscanf_s(version().c_str(), "%d.%d.%d-", &maj2, &min2, &rev2); + auto num2 = sscanf_s(Info::version().c_str(), "%d.%d.%d-", &maj2, &min2, &rev2); if (num1 == 3 && num2 == 3) { diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp index 22c45e5ab..70527ca1d 100644 --- a/toolsrc/src/main.cpp +++ b/toolsrc/src/main.cpp @@ -13,6 +13,7 @@ #include "vcpkg_System.h" #include "vcpkg_Input.h" #include "Paragraphs.h" +#include "vcpkg_info.h" using namespace vcpkg; @@ -192,7 +193,7 @@ int wmain(const int argc, const wchar_t* const* const argv) Flush(); }); - TrackProperty("version", version()); + TrackProperty("version", Info::version()); const std::string trimmed_command_line = trim_path_from_command_line(Strings::utf16_to_utf8(GetCommandLineW())); TrackProperty("cmdline", trimmed_command_line); @@ -234,10 +235,10 @@ int wmain(const int argc, const wchar_t* const* const argv) std::cerr << "vcpkg.exe has crashed.\n" << "Please send an email to:\n" - << " vcpkg@microsoft.com\n" + << " " << Info::email() << "\n" << "containing a brief summary of what you were trying to do and the following data blob:\n" << "\n" - << "Version=" << version() << "\n" + << "Version=" << Info::version() << "\n" << "EXCEPTION='" << exc_msg << "'\n" << "CMD=\n"; for (int x = 0; x < argc; ++x) diff --git a/toolsrc/src/vcpkg_info.cpp b/toolsrc/src/vcpkg_info.cpp new file mode 100644 index 000000000..25c09d6da --- /dev/null +++ b/toolsrc/src/vcpkg_info.cpp @@ -0,0 +1,34 @@ +#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 { namespace 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)"; + return s_email; + } +}} diff --git a/toolsrc/src/vcpkg_version.cpp b/toolsrc/src/vcpkg_version.cpp deleted file mode 100644 index da52b7cab..000000000 --- a/toolsrc/src/vcpkg_version.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "vcpkg.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 - -const std::string& vcpkg::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; -} diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj b/toolsrc/vcpkglib/vcpkglib.vcxproj index de8e3c8ca..766cdf6a8 100644 --- a/toolsrc/vcpkglib/vcpkglib.vcxproj +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj @@ -133,6 +133,7 @@ <ClInclude Include="..\include\vcpkg.h" /> <ClInclude Include="..\include\vcpkglib_helpers.h" /> <ClInclude Include="..\include\vcpkg_paths.h" /> + <ClInclude Include="..\include\vcpkg_info.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="..\src\BinaryParagraph.cpp" /> @@ -146,7 +147,7 @@ <ClCompile Include="..\src\triplet.cpp" /> <ClCompile Include="..\src\vcpkglib_helpers.cpp" /> <ClCompile Include="..\src\vcpkg_paths.cpp" /> - <ClCompile Include="..\src\vcpkg_version.cpp" /> + <ClCompile Include="..\src\vcpkg_info.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters index 24a417c0d..705a65a33 100644 --- a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters @@ -15,9 +15,6 @@ </Filter> </ItemGroup> <ItemGroup> - <ClCompile Include="..\src\vcpkg_version.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="..\src\package_spec.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -51,6 +48,9 @@ <ClCompile Include="..\src\vcpkg.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="..\src\vcpkg_info.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\include\vcpkg.h"> @@ -86,5 +86,8 @@ <ClInclude Include="..\include\Paragraphs.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\include\vcpkg_info.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> </Project>
\ No newline at end of file |
