2017-01-27 12:49:09 -08:00
|
|
|
#include "pch.h"
|
2017-02-01 13:24:06 -08:00
|
|
|
#include "PostBuildLint_BuildInfo.h"
|
2016-11-08 14:12:49 -08:00
|
|
|
#include "vcpkg_Checks.h"
|
2017-01-31 17:09:48 -08:00
|
|
|
#include "opt_bool.h"
|
2016-11-08 14:12:49 -08:00
|
|
|
#include "vcpkglib_helpers.h"
|
|
|
|
|
2017-01-05 14:25:50 -08:00
|
|
|
namespace vcpkg::PostBuildLint
|
2016-11-08 14:12:49 -08:00
|
|
|
{
|
|
|
|
//
|
|
|
|
namespace BuildInfoRequiredField
|
|
|
|
{
|
|
|
|
static const std::string CRT_LINKAGE = "CRTLinkage";
|
|
|
|
static const std::string LIBRARY_LINKAGE = "LibraryLinkage";
|
|
|
|
}
|
|
|
|
|
2017-01-31 17:09:48 -08:00
|
|
|
BuildInfo BuildInfo::create(std::unordered_map<std::string, std::string> pgh)
|
2016-11-08 14:12:49 -08:00
|
|
|
{
|
|
|
|
BuildInfo build_info;
|
2017-02-09 18:39:03 -08:00
|
|
|
const std::string crt_linkage_as_string = details::remove_required_field(&pgh, BuildInfoRequiredField::CRT_LINKAGE);
|
2017-02-09 19:00:09 -08:00
|
|
|
build_info.crt_linkage = LinkageType::value_of(crt_linkage_as_string);
|
|
|
|
Checks::check_exit(build_info.crt_linkage != LinkageType::NULLVALUE, "Invalid crt linkage type: [%s]", crt_linkage_as_string);
|
2017-02-09 18:39:03 -08:00
|
|
|
|
|
|
|
const std::string library_linkage_as_string = details::remove_required_field(&pgh, BuildInfoRequiredField::LIBRARY_LINKAGE);
|
2017-02-09 19:00:09 -08:00
|
|
|
build_info.library_linkage = LinkageType::value_of(library_linkage_as_string);
|
|
|
|
Checks::check_exit(build_info.library_linkage != LinkageType::NULLVALUE, "Invalid library linkage type: [%s]", library_linkage_as_string);
|
2017-01-31 17:09:48 -08:00
|
|
|
|
|
|
|
// 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);
|
2017-02-09 19:00:09 -08:00
|
|
|
Checks::check_exit(policy != BuildPolicies::NULLVALUE, "Unknown policy found: %s", p.first);
|
2017-01-31 17:09:48 -08:00
|
|
|
const opt_bool_t status = opt_bool::parse(p.second);
|
|
|
|
build_info.policies.emplace(policy, status);
|
|
|
|
}
|
2016-11-08 14:12:49 -08:00
|
|
|
|
|
|
|
return build_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildInfo read_build_info(const fs::path& filepath)
|
|
|
|
{
|
|
|
|
const std::vector<std::unordered_map<std::string, std::string>> pghs = Paragraphs::get_paragraphs(filepath);
|
2016-11-30 14:16:37 -08:00
|
|
|
Checks::check_exit(pghs.size() == 1, "Invalid BUILD_INFO file for package");
|
2016-11-08 14:12:49 -08:00
|
|
|
|
|
|
|
return BuildInfo::create(pghs[0]);
|
|
|
|
}
|
2016-11-10 11:04:33 -08:00
|
|
|
|
2017-01-05 14:25:50 -08:00
|
|
|
}
|