BuildInfo now holds enum instead of string
MODIFY
include/PostBuildLint_BuildInfo.h
include/PostBuildLint_BuildInfo.h
#include "Paragraphs.h"
#include "PostBuildLint_BuildPolicies.h"
#include "opt_bool.h"
+#include "PostBuildLint_LinkageType.h"
namespace vcpkg::PostBuildLint
{
@@ -11,8 +12,8 @@ namespace vcpkg::PostBuildLint
{
static BuildInfo create(std::unordered_map<std::string, std::string> pgh);
- std::string crt_linkage;
- std::string library_linkage;
+ LinkageType crt_linkage;
+ LinkageType library_linkage;
std::map<BuildPolicies::type, opt_bool_t> policies;
};

MODIFY
src/PostBuildLint.cpp
src/PostBuildLint.cpp
@@ -660,7 +660,7 @@ namespace vcpkg::PostBuildLint
error_count += check_lib_architecture(spec.target_triplet().architecture(), libs);
- switch (linkage_type_value_of(build_info.library_linkage))
+ switch (build_info.library_linkage)
{
case LinkageType::DYNAMIC:
{
@@ -691,16 +691,11 @@ namespace vcpkg::PostBuildLint
error_count += check_bin_folders_are_not_present_in_static_build(package_dir);
- error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::DEBUG, linkage_type_value_of(build_info.crt_linkage)), debug_libs, dumpbin_exe);
- error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, linkage_type_value_of(build_info.crt_linkage)), release_libs, dumpbin_exe);
+ error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::DEBUG, build_info.crt_linkage), debug_libs, dumpbin_exe);
+ error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, build_info.crt_linkage), release_libs, dumpbin_exe);
break;
}
case LinkageType::UNKNOWN:
- {
- error_count += 1;
- System::println(System::color::warning, "Unknown library_linkage architecture: [ %s ]", build_info.library_linkage);
- break;
- }
default:
Checks::unreachable();
}

MODIFY
src/PostBuildLint_BuildInfo.cpp
src/PostBuildLint_BuildInfo.cpp
@@ -16,8 +16,13 @@ namespace vcpkg::PostBuildLint
BuildInfo BuildInfo::create(std::unordered_map<std::string, std::string> pgh)
{
BuildInfo build_info;
- build_info.crt_linkage = details::remove_required_field(&pgh, BuildInfoRequiredField::CRT_LINKAGE);
- build_info.library_linkage = details::remove_required_field(&pgh, BuildInfoRequiredField::LIBRARY_LINKAGE);
+ const std::string crt_linkage_as_string = details::remove_required_field(&pgh, BuildInfoRequiredField::CRT_LINKAGE);
+ build_info.crt_linkage = linkage_type_value_of(crt_linkage_as_string);
+ Checks::check_exit(build_info.crt_linkage != LinkageType::UNKNOWN, "Invalid crt linkage type: [%s]", crt_linkage_as_string);
+
+ const std::string library_linkage_as_string = details::remove_required_field(&pgh, BuildInfoRequiredField::LIBRARY_LINKAGE);
+ build_info.library_linkage = linkage_type_value_of(library_linkage_as_string);
+ Checks::check_exit(build_info.library_linkage != LinkageType::UNKNOWN, "Invalid library linkage type: [%s]", library_linkage_as_string);
// The remaining entries are policies
for (const std::unordered_map<std::string, std::string>::value_type& p : pgh)

BuildInfo now holds enum instead of string