aboutsummaryrefslogtreecommitdiff
path: root/src/kconfig_compiler
diff options
context:
space:
mode:
authorCyril Rossi <cyril.rossi@enioka.com>2020-02-03 13:50:17 +0100
committerCyril Rossi <cyril.rossi@enioka.com>2020-04-22 09:13:09 +0200
commit00213a3a0906f0e1b5fa97a9e8de235a1e3cdcbf (patch)
tree5638cbcaea1c46cf079f7232b1248c00b445d804 /src/kconfig_compiler
parentfb29718d3ac64bdc9e1f2a3d15a506f7798e4a76 (diff)
downloadkconfig-00213a3a0906f0e1b5fa97a9e8de235a1e3cdcbf.tar.gz
kconfig-00213a3a0906f0e1b5fa97a9e8de235a1e3cdcbf.tar.bz2
kconfig_compiler : generate kconfig settings with subgroup
Summary: Following D27059, add `parentGroupName` attribute to `group` element to generate kconfig settings with subgroups Reviewers: ervin, dfaure, #frameworks, meven Reviewed By: ervin, meven Subscribers: apol, meven, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27133
Diffstat (limited to 'src/kconfig_compiler')
-rw-r--r--src/kconfig_compiler/KConfigCommonStructs.h1
-rw-r--r--src/kconfig_compiler/KConfigSourceGenerator.cpp30
-rw-r--r--src/kconfig_compiler/KConfigSourceGenerator.h1
-rw-r--r--src/kconfig_compiler/KConfigXmlParser.cpp8
-rw-r--r--src/kconfig_compiler/KConfigXmlParser.h2
-rw-r--r--src/kconfig_compiler/kcfg.xsd1
6 files changed, 38 insertions, 5 deletions
diff --git a/src/kconfig_compiler/KConfigCommonStructs.h b/src/kconfig_compiler/KConfigCommonStructs.h
index 70249d47..8ed1d22f 100644
--- a/src/kconfig_compiler/KConfigCommonStructs.h
+++ b/src/kconfig_compiler/KConfigCommonStructs.h
@@ -83,6 +83,7 @@ public:
public:
QString group;
+ QString parentGroup;
QString type;
QString key;
QString name;
diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp
index 0da8d4df..bb2694b2 100644
--- a/src/kconfig_compiler/KConfigSourceGenerator.cpp
+++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp
@@ -333,6 +333,10 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr
}
}
+ if (!entry->parentGroup.isEmpty()) {
+ stream() << " " << itemVarStr << "->setGroup(cg" << QString(entry->group).remove(QRegExp(QStringLiteral("\\W"))) << ");\n";
+ }
+
stream() << " addItem( " << itemVarStr;
QString quotedName = entry->name;
addQuotes(quotedName);
@@ -342,6 +346,11 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr
stream() << " );\n";
}
+// TODO : Some compiler option won't work or generate bogus settings file.
+// * Does not manage properly Notifiers=true kcfgc option for parameterized entries :
+// ** KConfigCompilerSignallingItem generated with wrong userData parameter (4th one).
+// ** setWriteFlags() is missing.
+// * Q_PROPERTY signal won't work
void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QString &key)
{
for (int i = 0; i <= entry->paramMax; i++) {
@@ -410,8 +419,25 @@ void KConfigSourceGenerator::handleCurrentGroupChange(const CfgEntry *entry)
}
mCurrentGroup = entry->group;
- stream() << " setCurrentGroup( " << paramString(mCurrentGroup, parseResult.parameters) << " );";
- stream() << "\n\n";
+
+ if (!entry->parentGroup.isEmpty()) {
+ QString parentGroup = QString(entry->parentGroup).remove(QRegExp(QStringLiteral("\\W")));
+ if (!mConfigGroupList.contains(parentGroup)) {
+ stream() << " KConfigGroup cg" << parentGroup
+ << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n";
+ mConfigGroupList << parentGroup;
+ }
+ QString currentGroup = QString(mCurrentGroup).remove(QRegExp(QStringLiteral("\\W")));
+ if (!mConfigGroupList.contains(currentGroup)) {
+ stream() << " KConfigGroup cg" << currentGroup
+ << " = cg" << QString(entry->parentGroup).remove(QRegExp(QStringLiteral("\\W")))
+ << ".group(" << paramString(mCurrentGroup, parseResult.parameters) << ");\n";
+ mConfigGroupList << currentGroup;
+ }
+ } else {
+ stream() << " setCurrentGroup( " << paramString(mCurrentGroup, parseResult.parameters) << " );";
+ stream() << "\n\n";
+ }
}
void KConfigSourceGenerator::doConstructor()
diff --git a/src/kconfig_compiler/KConfigSourceGenerator.h b/src/kconfig_compiler/KConfigSourceGenerator.h
index 76897f39..db2c8e72 100644
--- a/src/kconfig_compiler/KConfigSourceGenerator.h
+++ b/src/kconfig_compiler/KConfigSourceGenerator.h
@@ -68,6 +68,7 @@ private:
private:
QString mCurrentGroup;
+ QStringList mConfigGroupList; // keeps track of generated KConfigGroup;
};
#endif
diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp
index 46ce0921..3120d006 100644
--- a/src/kconfig_compiler/KConfigXmlParser.cpp
+++ b/src/kconfig_compiler/KConfigXmlParser.cpp
@@ -344,7 +344,7 @@ void KConfigXmlParser::readParamDefaultValues(CfgEntry &readEntry, const QDomEle
}
}
-CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QDomElement &element)
+CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &parentGroup, const QDomElement &element)
{
CfgEntry readEntry;
readEntry.type = element.attribute(QStringLiteral("type"));
@@ -352,6 +352,7 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QDomElement &
readEntry.key = element.attribute(QStringLiteral("key"));
readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true");;
readEntry.group = group;
+ readEntry.parentGroup = parentGroup;
const bool nameIsEmpty = readEntry.name.isEmpty();
@@ -400,6 +401,7 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QDomElement &
// creating another one to fill the code.
CfgEntry *result = new CfgEntry();
result->group = readEntry.group;
+ result->parentGroup = readEntry.parentGroup;
result->type = readEntry.type;
result->key = readEntry.key;
result->name = readEntry.name;
@@ -492,11 +494,13 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e)
exit (1);
}
+ const QString parentGroup = e.attribute(QStringLiteral("parentGroupName"));
+
for (QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement()) {
if (e2.tagName() != QLatin1String("entry")) {
continue;
}
- CfgEntry *entry = parseEntry(group, e2);
+ CfgEntry *entry = parseEntry(group, parentGroup, e2);
if (entry) {
mParseResult.entries.append(entry);
} else {
diff --git a/src/kconfig_compiler/KConfigXmlParser.h b/src/kconfig_compiler/KConfigXmlParser.h
index fa46e4b9..742cb496 100644
--- a/src/kconfig_compiler/KConfigXmlParser.h
+++ b/src/kconfig_compiler/KConfigXmlParser.h
@@ -46,7 +46,7 @@ private:
// TODO: Use std::optional and CfgEntry (without heap allocation) for this function
// *or* fail hard if the parse fails.
- CfgEntry *parseEntry(const QString &group, const QDomElement &element);
+ CfgEntry *parseEntry(const QString &group, const QString &parentGroup, const QDomElement &element);
// Steps
void readIncludeTag(const QDomElement &element);
diff --git a/src/kconfig_compiler/kcfg.xsd b/src/kconfig_compiler/kcfg.xsd
index f28a70d7..1ec1dc81 100644
--- a/src/kconfig_compiler/kcfg.xsd
+++ b/src/kconfig_compiler/kcfg.xsd
@@ -155,6 +155,7 @@
</xsd:element>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="parentGroupName" use="optional" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>