Split BuildType into separate h/cpp
MODIFY
include/PostBuildLint_BuildInfo.h
include/PostBuildLint_BuildInfo.h
#include <regex>
#include "PostBuildLint_BuildPolicies.h"
#include "opt_bool.h"
-#include "PostBuildLint_LinkageType.h"
-#include "PostBuildLint_ConfigurationType.h"
namespace vcpkg::PostBuildLint
{
- struct BuildType
- {
- static BuildType value_of(const ConfigurationType& config, const LinkageType& linkage);
-
- static const BuildType DEBUG_STATIC;
- static const BuildType DEBUG_DYNAMIC;
- static const BuildType RELEASE_STATIC;
- static const BuildType RELEASE_DYNAMIC;
-
- static const std::vector<BuildType>& values()
- {
- static const std::vector<BuildType> v = {DEBUG_STATIC, DEBUG_DYNAMIC, RELEASE_STATIC, RELEASE_DYNAMIC};
- return v;
- }
-
- BuildType() = delete;
-
- const ConfigurationType& config() const;
- const LinkageType& linkage() const;
- std::regex crt_regex() const;
- std::string toString() const;
-
- private:
- BuildType(const ConfigurationType& config, const LinkageType& linkage, const std::string& crt_regex_as_string)
- : m_config(config), m_linkage(linkage), m_crt_regex_as_string(crt_regex_as_string)
- {
- }
-
- ConfigurationType m_config;
- LinkageType m_linkage;
- std::string m_crt_regex_as_string;
- };
-
- bool operator ==(const BuildType& lhs, const BuildType& rhs);
-
- bool operator !=(const BuildType& lhs, const BuildType& rhs);
-
struct OutdatedDynamicCrt
{
// Old CPP

ADD
include/PostBuildLint_BuildType.h
+#pragma once
+#include "PostBuildLint_ConfigurationType.h"
+#include "PostBuildLint_LinkageType.h"
+#include <vector>
+#include <regex>
+
+namespace vcpkg::PostBuildLint
+{
+ struct BuildType
+ {
+ static BuildType value_of(const ConfigurationType& config, const LinkageType& linkage);
+
+ static const BuildType DEBUG_STATIC;
+ static const BuildType DEBUG_DYNAMIC;
+ static const BuildType RELEASE_STATIC;
+ static const BuildType RELEASE_DYNAMIC;
+
+ static const std::vector<BuildType>& values()
+ {
+ static const std::vector<BuildType> v = { DEBUG_STATIC, DEBUG_DYNAMIC, RELEASE_STATIC, RELEASE_DYNAMIC };
+ return v;
+ }
+
+ BuildType() = delete;
+
+ const ConfigurationType& config() const;
+ const LinkageType& linkage() const;
+ std::regex crt_regex() const;
+ std::string toString() const;
+
+ private:
+ BuildType(const ConfigurationType& config, const LinkageType& linkage, const std::string& crt_regex_as_string)
+ : m_config(config), m_linkage(linkage), m_crt_regex_as_string(crt_regex_as_string)
+ {
+ }
+
+ ConfigurationType m_config;
+ LinkageType m_linkage;
+ std::string m_crt_regex_as_string;
+ };
+
+ bool operator ==(const BuildType& lhs, const BuildType& rhs);
+
+ bool operator !=(const BuildType& lhs, const BuildType& rhs);
+}

MODIFY
src/PostBuildLint_BuildInfo.cpp
src/PostBuildLint_BuildInfo.cpp
namespace vcpkg::PostBuildLint
{
- const ConfigurationType& BuildType::config() const
- {
- return this->m_config;
- }
-
- const LinkageType& BuildType::linkage() const
- {
- return this->m_linkage;
- }
-
- std::regex BuildType::crt_regex() const
- {
- const std::regex r(this->m_crt_regex_as_string, std::regex_constants::icase);
- return r;
- }
-
- std::string BuildType::toString() const
- {
- const std::string s = Strings::format("[%s,%s]", to_string(this->m_config), to_string(this->m_linkage));
- return s;
- }
-
- bool operator==(const BuildType& lhs, const BuildType& rhs)
- {
- return lhs.config() == rhs.config() && lhs.linkage() == rhs.linkage();
- }
-
- bool operator!=(const BuildType& lhs, const BuildType& rhs)
- {
- return !(lhs == rhs);
- }
-
//
namespace BuildInfoRequiredField
{
@@ -63,36 +31,6 @@ namespace vcpkg::PostBuildLint
return build_info;
}
- const BuildType BuildType::DEBUG_STATIC = BuildType(ConfigurationType::DEBUG, LinkageType::STATIC, R"(/DEFAULTLIB:LIBCMTD)");
- const BuildType BuildType::DEBUG_DYNAMIC = BuildType(ConfigurationType::DEBUG, LinkageType::DYNAMIC, R"(/DEFAULTLIB:MSVCRTD)");
- const BuildType BuildType::RELEASE_STATIC = BuildType(ConfigurationType::RELEASE, LinkageType::STATIC, R"(/DEFAULTLIB:LIBCMT[^D])");
- const BuildType BuildType::RELEASE_DYNAMIC = BuildType(ConfigurationType::RELEASE, LinkageType::DYNAMIC, R"(/DEFAULTLIB:MSVCRT[^D])");
-
- BuildType BuildType::value_of(const ConfigurationType& config, const LinkageType& 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;
- }
-
- Checks::unreachable();
- }
-
BuildInfo read_build_info(const fs::path& filepath)
{
const std::vector<std::unordered_map<std::string, std::string>> pghs = Paragraphs::get_paragraphs(filepath);

ADD
src/PostBuiltLint_BuildType.cpp
+#include "pch.h"
+#include "PostBuildLint_BuildType.h"
+#include "vcpkg_Checks.h"
+
+namespace vcpkg::PostBuildLint
+{
+ const BuildType BuildType::DEBUG_STATIC = BuildType(ConfigurationType::DEBUG, LinkageType::STATIC, R"(/DEFAULTLIB:LIBCMTD)");
+ const BuildType BuildType::DEBUG_DYNAMIC = BuildType(ConfigurationType::DEBUG, LinkageType::DYNAMIC, R"(/DEFAULTLIB:MSVCRTD)");
+ const BuildType BuildType::RELEASE_STATIC = BuildType(ConfigurationType::RELEASE, LinkageType::STATIC, R"(/DEFAULTLIB:LIBCMT[^D])");
+ const BuildType BuildType::RELEASE_DYNAMIC = BuildType(ConfigurationType::RELEASE, LinkageType::DYNAMIC, R"(/DEFAULTLIB:MSVCRT[^D])");
+
+ BuildType BuildType::value_of(const ConfigurationType& config, const LinkageType& 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;
+ }
+
+ Checks::unreachable();
+ }
+
+ const ConfigurationType& BuildType::config() const
+ {
+ return this->m_config;
+ }
+
+ const LinkageType& BuildType::linkage() const
+ {
+ return this->m_linkage;
+ }
+
+ std::regex BuildType::crt_regex() const
+ {
+ const std::regex r(this->m_crt_regex_as_string, std::regex_constants::icase);
+ return r;
+ }
+
+ std::string BuildType::toString() const
+ {
+ const std::string s = Strings::format("[%s,%s]", to_string(this->m_config), to_string(this->m_linkage));
+ return s;
+ }
+
+ bool operator==(const BuildType& lhs, const BuildType& rhs)
+ {
+ return lhs.config() == rhs.config() && lhs.linkage() == rhs.linkage();
+ }
+
+ bool operator!=(const BuildType& lhs, const BuildType& rhs)
+ {
+ return !(lhs == rhs);
+ }
+}

MODIFY
vcpkglib/vcpkglib.vcxproj
vcpkglib/vcpkglib.vcxproj
<ClInclude Include="..\include\Paragraphs.h" />
<ClInclude Include="..\include\pch.h" />
<ClInclude Include="..\include\PostBuildLint.h" />
+ <ClInclude Include="..\include\PostBuildLint_BuildType.h" />
<ClInclude Include="..\include\PostBuildLint_ConfigurationType.h" />
<ClInclude Include="..\include\PostBuildLint_LinkageType.h" />
<ClInclude Include="..\include\SourceParagraph.h" />
<ClCompile Include="..\src\PostBuildLint.cpp" />
<ClCompile Include="..\src\PostBuildLint_ConfigurationType.cpp" />
<ClCompile Include="..\src\PostBuildLint_LinkageType.cpp" />
+ <ClCompile Include="..\src\PostBuiltLint_BuildType.cpp" />
<ClCompile Include="..\src\Stopwatch.cpp" />
<ClCompile Include="..\src\vcpkglib.cpp" />
<ClCompile Include="..\src\package_spec.cpp" />

MODIFY
vcpkglib/vcpkglib.vcxproj.filters
vcpkglib/vcpkglib.vcxproj.filters
<ClCompile Include="..\src\PostBuildLint_ConfigurationType.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\src\PostBuiltLint_BuildType.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\package_spec.h">
<ClInclude Include="..\include\PostBuildLint_ConfigurationType.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\include\PostBuildLint_BuildType.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file

Split BuildType into separate h/cpp