summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2017-08-21 20:39:29 -0500
committerYifan Hong2017-08-23 17:29:15 -0500
commitee8bc5e17a95c1abb4587550f61dc32790d1df51 (patch)
treec0a4f269de6b36e3ae671c9225e8897d6a6b643a
parentcef6437c31623647ec2200d46272f7ac5485aeb1 (diff)
downloadplatform-system-libvintf-ee8bc5e17a95c1abb4587550f61dc32790d1df51.tar.gz
platform-system-libvintf-ee8bc5e17a95c1abb4587550f61dc32790d1df51.tar.xz
platform-system-libvintf-ee8bc5e17a95c1abb4587550f61dc32790d1df51.zip
Add <conditions> to <kernel> in framework compat mat
When <conditions> are present, the <kernel> tag is only checked when all conditions are met. This is to support arch-specific kernel config requirements. Test: libvintf_test Bug: 64124223 Change-Id: I91ecd115ca42473b79bda24d9b8613eed817e7e2 Merged-In: I91ecd115ca42473b79bda24d9b8613eed817e7e2
-rw-r--r--include/vintf/MatrixKernel.h8
-rw-r--r--parse_xml.cpp17
2 files changed, 24 insertions, 1 deletions
diff --git a/include/vintf/MatrixKernel.h b/include/vintf/MatrixKernel.h
index 4b261a6..a2fa7c9 100644
--- a/include/vintf/MatrixKernel.h
+++ b/include/vintf/MatrixKernel.h
@@ -50,12 +50,18 @@ struct MatrixKernel {
50 // for (const KernelConfig &config : kernel.configs()) {...} 50 // for (const KernelConfig &config : kernel.configs()) {...}
51 const std::vector<KernelConfig> &configs() const { return mConfigs; } 51 const std::vector<KernelConfig> &configs() const { return mConfigs; }
52 52
53private: 53 // Return an iterable on all kernel config conditions. Use it as follows:
54 // for (const KernelConfig &config : kernel.conditions()) {...}
55 const std::vector<KernelConfig>& conditions() const { return mConditions; }
56
57 private:
54 friend struct MatrixKernelConverter; 58 friend struct MatrixKernelConverter;
59 friend struct MatrixKernelConditionsConverter;
55 friend class AssembleVintf; 60 friend class AssembleVintf;
56 61
57 KernelVersion mMinLts; 62 KernelVersion mMinLts;
58 std::vector<KernelConfig> mConfigs; 63 std::vector<KernelConfig> mConfigs;
64 std::vector<KernelConfig> mConditions;
59}; 65};
60 66
61} // namespace vintf 67} // namespace vintf
diff --git a/parse_xml.cpp b/parse_xml.cpp
index 5239275..df3cb54 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -549,14 +549,31 @@ struct MatrixHalConverter : public XmlNodeConverter<MatrixHal> {
549 549
550const MatrixHalConverter matrixHalConverter{}; 550const MatrixHalConverter matrixHalConverter{};
551 551
552struct MatrixKernelConditionsConverter : public XmlNodeConverter<std::vector<KernelConfig>> {
553 std::string elementName() const override { return "conditions"; }
554 void mutateNode(const std::vector<KernelConfig>& conds, NodeType* root,
555 DocType* d) const override {
556 appendChildren(root, kernelConfigConverter, conds, d);
557 }
558 bool buildObject(std::vector<KernelConfig>* object, NodeType* root) const override {
559 return parseChildren(root, kernelConfigConverter, object);
560 }
561};
562
563const MatrixKernelConditionsConverter matrixKernelConditionsConverter{};
564
552struct MatrixKernelConverter : public XmlNodeConverter<MatrixKernel> { 565struct MatrixKernelConverter : public XmlNodeConverter<MatrixKernel> {
553 std::string elementName() const override { return "kernel"; } 566 std::string elementName() const override { return "kernel"; }
554 void mutateNode(const MatrixKernel &kernel, NodeType *root, DocType *d) const override { 567 void mutateNode(const MatrixKernel &kernel, NodeType *root, DocType *d) const override {
555 appendAttr(root, "version", kernel.mMinLts); 568 appendAttr(root, "version", kernel.mMinLts);
569 if (!kernel.mConditions.empty()) {
570 appendChild(root, matrixKernelConditionsConverter(kernel.mConditions, d));
571 }
556 appendChildren(root, kernelConfigConverter, kernel.mConfigs, d); 572 appendChildren(root, kernelConfigConverter, kernel.mConfigs, d);
557 } 573 }
558 bool buildObject(MatrixKernel *object, NodeType *root) const override { 574 bool buildObject(MatrixKernel *object, NodeType *root) const override {
559 if (!parseAttr(root, "version", &object->mMinLts) || 575 if (!parseAttr(root, "version", &object->mMinLts) ||
576 !parseOptionalChild(root, matrixKernelConditionsConverter, {}, &object->mConditions) ||
560 !parseChildren(root, kernelConfigConverter, &object->mConfigs)) { 577 !parseChildren(root, kernelConfigConverter, &object->mConfigs)) {
561 return false; 578 return false;
562 } 579 }