aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/PostBuildLint_BuildType.cpp
diff options
context:
space:
mode:
authorThomas Fussell <thomas.fussell@gmail.com>2017-03-12 17:44:06 -0400
committerThomas Fussell <thomas.fussell@gmail.com>2017-03-12 17:44:06 -0400
commit2f42035ab43dd50cd863b51944aa099a99ae60f0 (patch)
tree4b6cfd43955e946721c58028fd8564c861d5c331 /toolsrc/src/PostBuildLint_BuildType.cpp
parente02e85626f3206feda86a6f5757009005e0cfe3e (diff)
parent1c9873a0daf625f67474aaf3e163c592c27ecb65 (diff)
downloadvcpkg-2f42035ab43dd50cd863b51944aa099a99ae60f0.tar.gz
vcpkg-2f42035ab43dd50cd863b51944aa099a99ae60f0.zip
Merge branch 'master' of git://github.com/Microsoft/vcpkg
Diffstat (limited to 'toolsrc/src/PostBuildLint_BuildType.cpp')
-rw-r--r--toolsrc/src/PostBuildLint_BuildType.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/toolsrc/src/PostBuildLint_BuildType.cpp b/toolsrc/src/PostBuildLint_BuildType.cpp
new file mode 100644
index 000000000..f2fb292d7
--- /dev/null
+++ b/toolsrc/src/PostBuildLint_BuildType.cpp
@@ -0,0 +1,85 @@
+#include "pch.h"
+#include "PostBuildLint_BuildType.h"
+#include "vcpkg_Enums.h"
+
+namespace vcpkg::PostBuildLint::BuildType
+{
+ type value_of(const ConfigurationType::type& config, const LinkageType::type& linkage)
+ {
+ if (config == ConfigurationType::DEBUG && linkage == LinkageType::STATIC)
+ {
+ return DEBUG_STATIC;
+ }
+
+ if (config == ConfigurationType::DEBUG && linkage == LinkageType::DYNAMIC)
+ {
+ return DEBUG_DYNAMIC;
+ }
+
+ if (config == ConfigurationType::RELEASE && linkage == LinkageType::STATIC)
+ {
+ return RELEASE_STATIC;
+ }
+
+ if (config == ConfigurationType::RELEASE && linkage == LinkageType::DYNAMIC)
+ {
+ return RELEASE_DYNAMIC;
+ }
+
+ Enums::unreachable(ENUM_NAME);
+ }
+
+ const ConfigurationType::type& type::config() const
+ {
+ return this->m_config;
+ }
+
+ const LinkageType::type& type::linkage() const
+ {
+ return this->m_linkage;
+ }
+
+ const std::regex& type::crt_regex() const
+ {
+ static const std::regex REGEX_DEBUG_STATIC(R"(/DEFAULTLIB:LIBCMTD)", std::regex_constants::icase);
+ static const std::regex REGEX_DEBUG_DYNAMIC(R"(/DEFAULTLIB:MSVCRTD)", std::regex_constants::icase);
+ static const std::regex REGEX_RELEASE_STATIC(R"(/DEFAULTLIB:LIBCMT[^D])", std::regex_constants::icase);
+ static const std::regex REGEX_RELEASE_DYNAMIC(R"(/DEFAULTLIB:MSVCRT[^D])", std::regex_constants::icase);
+
+ switch (backing_enum)
+ {
+ case BuildType::DEBUG_STATIC:
+ return REGEX_DEBUG_STATIC;
+ case BuildType::DEBUG_DYNAMIC:
+ return REGEX_DEBUG_DYNAMIC;
+ case BuildType::RELEASE_STATIC:
+ return REGEX_RELEASE_STATIC;
+ case BuildType::RELEASE_DYNAMIC:
+ return REGEX_RELEASE_DYNAMIC;
+ default:
+ Enums::unreachable(ENUM_NAME);
+ }
+ }
+
+ const std::string& type::toString() const
+ {
+ static const std::string NAME_DEBUG_STATIC("Debug,Static");
+ static const std::string NAME_DEBUG_DYNAMIC("Debug,Dynamic");
+ static const std::string NAME_RELEASE_STATIC("Release,Static");
+ static const std::string NAME_RELEASE_DYNAMIC("Release,Dynamic");
+
+ switch (backing_enum)
+ {
+ case BuildType::DEBUG_STATIC:
+ return NAME_DEBUG_STATIC;
+ case BuildType::DEBUG_DYNAMIC:
+ return NAME_DEBUG_DYNAMIC;
+ case BuildType::RELEASE_STATIC:
+ return NAME_RELEASE_STATIC;
+ case BuildType::RELEASE_DYNAMIC:
+ return NAME_RELEASE_DYNAMIC;
+ default:
+ Enums::unreachable(ENUM_NAME);
+ }
+ }
+}