mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-24 03:27:12 +01:00
Introduce BuildPolicies (not used by the post_build checks yet)
This commit is contained in:
parent
bd1a10e5b9
commit
4599997869
@ -3,6 +3,8 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "Paragraphs.h"
|
#include "Paragraphs.h"
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include "BuildPolicies.h"
|
||||||
|
#include "opt_bool.h"
|
||||||
|
|
||||||
namespace vcpkg::PostBuildLint
|
namespace vcpkg::PostBuildLint
|
||||||
{
|
{
|
||||||
@ -119,10 +121,12 @@ namespace vcpkg::PostBuildLint
|
|||||||
|
|
||||||
struct BuildInfo
|
struct BuildInfo
|
||||||
{
|
{
|
||||||
static BuildInfo create(const std::unordered_map<std::string, std::string>& pgh);
|
static BuildInfo create(std::unordered_map<std::string, std::string> pgh);
|
||||||
|
|
||||||
std::string crt_linkage;
|
std::string crt_linkage;
|
||||||
std::string library_linkage;
|
std::string library_linkage;
|
||||||
|
|
||||||
|
std::map<BuildPolicies::type, opt_bool_t> policies;
|
||||||
};
|
};
|
||||||
|
|
||||||
BuildInfo read_build_info(const fs::path& filepath);
|
BuildInfo read_build_info(const fs::path& filepath);
|
||||||
|
30
toolsrc/include/BuildPolicies.h
Normal file
30
toolsrc/include/BuildPolicies.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace vcpkg::PostBuildLint::BuildPolicies
|
||||||
|
{
|
||||||
|
enum class backing_enum_t
|
||||||
|
{
|
||||||
|
UNKNOWN = 0,
|
||||||
|
DLLS_WITHOUT_LIBS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct type
|
||||||
|
{
|
||||||
|
static constexpr int length() { return 2; }
|
||||||
|
constexpr explicit type(backing_enum_t backing_enum) : backing_enum(backing_enum) { }
|
||||||
|
constexpr operator backing_enum_t() const { return backing_enum; }
|
||||||
|
|
||||||
|
const std::string& toString() const;
|
||||||
|
const std::string& cmake_variable() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
type();
|
||||||
|
backing_enum_t backing_enum;
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr type UNKNOWN(backing_enum_t::UNKNOWN);
|
||||||
|
static constexpr type DLLS_WITHOUT_LIBS(backing_enum_t::DLLS_WITHOUT_LIBS);
|
||||||
|
|
||||||
|
type parse(const std::string& s);
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "BuildInfo.h"
|
#include "BuildInfo.h"
|
||||||
#include "vcpkg_Checks.h"
|
#include "vcpkg_Checks.h"
|
||||||
|
#include "opt_bool.h"
|
||||||
#include "vcpkglib_helpers.h"
|
#include "vcpkglib_helpers.h"
|
||||||
|
|
||||||
namespace vcpkg::PostBuildLint
|
namespace vcpkg::PostBuildLint
|
||||||
@ -44,11 +45,20 @@ namespace vcpkg::PostBuildLint
|
|||||||
static const std::string LIBRARY_LINKAGE = "LibraryLinkage";
|
static const std::string LIBRARY_LINKAGE = "LibraryLinkage";
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildInfo BuildInfo::create(const std::unordered_map<std::string, std::string>& pgh)
|
BuildInfo BuildInfo::create(std::unordered_map<std::string, std::string> pgh)
|
||||||
{
|
{
|
||||||
BuildInfo build_info;
|
BuildInfo build_info;
|
||||||
build_info.crt_linkage = details::required_field(pgh, BuildInfoRequiredField::CRT_LINKAGE);
|
build_info.crt_linkage = details::remove_required_field(&pgh, BuildInfoRequiredField::CRT_LINKAGE);
|
||||||
build_info.library_linkage = details::required_field(pgh, BuildInfoRequiredField::LIBRARY_LINKAGE);
|
build_info.library_linkage = details::remove_required_field(&pgh, BuildInfoRequiredField::LIBRARY_LINKAGE);
|
||||||
|
|
||||||
|
// The remaining entries are policies
|
||||||
|
for (const std::unordered_map<std::string, std::string>::value_type& p : pgh)
|
||||||
|
{
|
||||||
|
const BuildPolicies::type policy = BuildPolicies::parse(p.first);
|
||||||
|
Checks::check_exit(policy != BuildPolicies::UNKNOWN, "Unknown policy found: %s", p.first);
|
||||||
|
const opt_bool_t status = opt_bool::parse(p.second);
|
||||||
|
build_info.policies.emplace(policy, status);
|
||||||
|
}
|
||||||
|
|
||||||
return build_info;
|
return build_info;
|
||||||
}
|
}
|
||||||
|
49
toolsrc/src/BuildPolicies.cpp
Normal file
49
toolsrc/src/BuildPolicies.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "BuildPolicies.h"
|
||||||
|
#include "vcpkg_Checks.h"
|
||||||
|
|
||||||
|
namespace vcpkg::PostBuildLint::BuildPolicies
|
||||||
|
{
|
||||||
|
static const std::string NAME_UNKNOWN = "PolicyUnknown";
|
||||||
|
static const std::string NAME_DLLS_WITHOUT_LIBS = "PolicyDLLsWithoutLIBs";
|
||||||
|
|
||||||
|
const std::string& type::toString() const
|
||||||
|
{
|
||||||
|
switch (this->backing_enum)
|
||||||
|
{
|
||||||
|
case DLLS_WITHOUT_LIBS:
|
||||||
|
return NAME_DLLS_WITHOUT_LIBS;
|
||||||
|
case UNKNOWN:
|
||||||
|
return NAME_UNKNOWN;
|
||||||
|
default:
|
||||||
|
Checks::unreachable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& type::cmake_variable() const
|
||||||
|
{
|
||||||
|
static const std::string CMAKE_VARIABLE_DLLS_WITHOUT_LIBS = "VCPKG_POLICY_DLLS_WITHOUT_LIBS";
|
||||||
|
|
||||||
|
switch (this->backing_enum)
|
||||||
|
{
|
||||||
|
case DLLS_WITHOUT_LIBS:
|
||||||
|
return CMAKE_VARIABLE_DLLS_WITHOUT_LIBS;
|
||||||
|
case UNKNOWN:
|
||||||
|
Checks::exit_with_message("No CMake command corresponds to UNKNOWN");
|
||||||
|
default:
|
||||||
|
Checks::unreachable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type::type(): backing_enum(backing_enum_t::UNKNOWN) {}
|
||||||
|
|
||||||
|
type parse(const std::string& s)
|
||||||
|
{
|
||||||
|
if (s == NAME_DLLS_WITHOUT_LIBS)
|
||||||
|
{
|
||||||
|
return BuildPolicies::DLLS_WITHOUT_LIBS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BuildPolicies::UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
@ -138,6 +138,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\include\BinaryParagraph.h" />
|
<ClInclude Include="..\include\BinaryParagraph.h" />
|
||||||
<ClInclude Include="..\include\BuildInfo.h" />
|
<ClInclude Include="..\include\BuildInfo.h" />
|
||||||
|
<ClInclude Include="..\include\BuildPolicies.h" />
|
||||||
<ClInclude Include="..\include\coff_file_reader.h" />
|
<ClInclude Include="..\include\coff_file_reader.h" />
|
||||||
<ClInclude Include="..\include\expected.h" />
|
<ClInclude Include="..\include\expected.h" />
|
||||||
<ClInclude Include="..\include\filesystem_fs.h" />
|
<ClInclude Include="..\include\filesystem_fs.h" />
|
||||||
@ -176,6 +177,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\src\BinaryParagraph.cpp" />
|
<ClCompile Include="..\src\BinaryParagraph.cpp" />
|
||||||
<ClCompile Include="..\src\BuildInfo.cpp" />
|
<ClCompile Include="..\src\BuildInfo.cpp" />
|
||||||
|
<ClCompile Include="..\src\BuildPolicies.cpp" />
|
||||||
<ClCompile Include="..\src\coff_file_reader.cpp" />
|
<ClCompile Include="..\src\coff_file_reader.cpp" />
|
||||||
<ClCompile Include="..\src\commands_available_commands.cpp" />
|
<ClCompile Include="..\src\commands_available_commands.cpp" />
|
||||||
<ClCompile Include="..\src\commands_build.cpp" />
|
<ClCompile Include="..\src\commands_build.cpp" />
|
||||||
|
@ -156,6 +156,9 @@
|
|||||||
<ClCompile Include="..\src\opt_bool.cpp">
|
<ClCompile Include="..\src\opt_bool.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\BuildPolicies.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\include\package_spec.h">
|
<ClInclude Include="..\include\package_spec.h">
|
||||||
@ -266,5 +269,8 @@
|
|||||||
<ClInclude Include="..\include\vcpkg_optional.h">
|
<ClInclude Include="..\include\vcpkg_optional.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\include\BuildPolicies.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user