mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-24 03:27:12 +01:00
Split BuildType into separate h/cpp
This commit is contained in:
parent
4aef2485b9
commit
0a0a17b7f9
@ -5,48 +5,9 @@
|
||||
#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
|
||||
|
45
toolsrc/include/PostBuildLint_BuildType.h
Normal file
45
toolsrc/include/PostBuildLint_BuildType.h
Normal file
@ -0,0 +1,45 @@
|
||||
#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);
|
||||
}
|
@ -6,38 +6,6 @@
|
||||
|
||||
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);
|
||||
|
68
toolsrc/src/PostBuiltLint_BuildType.cpp
Normal file
68
toolsrc/src/PostBuiltLint_BuildType.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#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);
|
||||
}
|
||||
}
|
@ -151,6 +151,7 @@
|
||||
<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" />
|
||||
@ -212,6 +213,7 @@
|
||||
<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" />
|
||||
|
@ -165,6 +165,9 @@
|
||||
<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">
|
||||
@ -284,5 +287,8 @@
|
||||
<ClInclude Include="..\include\PostBuildLint_ConfigurationType.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\PostBuildLint_BuildType.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user