mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 18:13:01 +08:00
[vcpkg] Add optional Abi field to BinaryParagraph for future use.
This commit is contained in:
parent
b3fe4462e2
commit
33fc44a0e3
@ -30,6 +30,7 @@ namespace vcpkg
|
|||||||
std::string feature;
|
std::string feature;
|
||||||
std::vector<std::string> default_features;
|
std::vector<std::string> default_features;
|
||||||
std::vector<std::string> depends;
|
std::vector<std::string> depends;
|
||||||
|
std::string abi;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BinaryControlFile
|
struct BinaryControlFile
|
||||||
|
@ -190,6 +190,20 @@ namespace UnitTest1
|
|||||||
Assert::AreEqual("c", pgh.depends[2].c_str());
|
Assert::AreEqual("c", pgh.depends[2].c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(BinaryParagraph_Abi)
|
||||||
|
{
|
||||||
|
vcpkg::BinaryParagraph pgh({
|
||||||
|
{"Package", "zlib"},
|
||||||
|
{"Version", "1.2.8"},
|
||||||
|
{"Architecture", "x86-windows"},
|
||||||
|
{"Multi-Arch", "same"},
|
||||||
|
{"Abi", "abcd123"},
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert::AreEqual(size_t(0), pgh.depends.size());
|
||||||
|
Assert::IsTrue(pgh.abi == "abcd123");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_METHOD(parse_paragraphs_empty)
|
TEST_METHOD(parse_paragraphs_empty)
|
||||||
{
|
{
|
||||||
const char* str = "";
|
const char* str = "";
|
||||||
@ -385,5 +399,21 @@ namespace UnitTest1
|
|||||||
Assert::AreEqual(size_t(1), pghs.size());
|
Assert::AreEqual(size_t(1), pghs.size());
|
||||||
Assert::AreEqual("a, b, c", pghs[0]["Depends"].c_str());
|
Assert::AreEqual("a, b, c", pghs[0]["Depends"].c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(BinaryParagraph_serialize_abi)
|
||||||
|
{
|
||||||
|
vcpkg::BinaryParagraph pgh({
|
||||||
|
{"Package", "zlib"},
|
||||||
|
{"Version", "1.2.8"},
|
||||||
|
{"Architecture", "x86-windows"},
|
||||||
|
{"Multi-Arch", "same"},
|
||||||
|
{"Depends", "a, b, c"},
|
||||||
|
{"Abi", "123abc"},
|
||||||
|
});
|
||||||
|
std::string ss = Strings::serialize(pgh);
|
||||||
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||||
|
Assert::AreEqual(size_t(1), pghs.size());
|
||||||
|
Assert::AreEqual("123abc", pghs[0]["Abi"].c_str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ namespace vcpkg
|
|||||||
|
|
||||||
namespace Fields
|
namespace Fields
|
||||||
{
|
{
|
||||||
|
static const std::string ABI = "Abi";
|
||||||
static const std::string FEATURE = "Feature";
|
static const std::string FEATURE = "Feature";
|
||||||
static const std::string DESCRIPTION = "Description";
|
static const std::string DESCRIPTION = "Description";
|
||||||
static const std::string MAINTAINER = "Maintainer";
|
static const std::string MAINTAINER = "Maintainer";
|
||||||
@ -47,6 +48,8 @@ namespace vcpkg
|
|||||||
this->description = parser.optional_field(Fields::DESCRIPTION);
|
this->description = parser.optional_field(Fields::DESCRIPTION);
|
||||||
this->maintainer = parser.optional_field(Fields::MAINTAINER);
|
this->maintainer = parser.optional_field(Fields::MAINTAINER);
|
||||||
|
|
||||||
|
this->abi = parser.optional_field(Fields::ABI);
|
||||||
|
|
||||||
std::string multi_arch;
|
std::string multi_arch;
|
||||||
parser.required_field(Fields::MULTI_ARCH, multi_arch);
|
parser.required_field(Fields::MULTI_ARCH, multi_arch);
|
||||||
|
|
||||||
@ -118,6 +121,7 @@ namespace vcpkg
|
|||||||
out_str.append("Multi-Arch: same\n");
|
out_str.append("Multi-Arch: same\n");
|
||||||
|
|
||||||
if (!pgh.maintainer.empty()) out_str.append("Maintainer: ").append(pgh.maintainer).push_back('\n');
|
if (!pgh.maintainer.empty()) out_str.append("Maintainer: ").append(pgh.maintainer).push_back('\n');
|
||||||
|
if (!pgh.abi.empty()) out_str.append("Abi: ").append(pgh.abi).push_back('\n');
|
||||||
if (!pgh.description.empty()) out_str.append("Description: ").append(pgh.description).push_back('\n');
|
if (!pgh.description.empty()) out_str.append("Description: ").append(pgh.description).push_back('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user