kconfig_compiler : generate kconfig settings with subgroup
ClosedPublic

Authored by crossi on Feb 3 2020, 4:31 PM.

Details

Summary

Following D27059, add parentGroupName attribute to group element to generate kconfig settings with subgroups

Diff Detail

Repository
R237 KConfig
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
crossi created this revision.Feb 3 2020, 4:31 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 3 2020, 4:31 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
crossi requested review of this revision.Feb 3 2020, 4:31 PM
meven added a subscriber: meven.Feb 5 2020, 9:12 AM
meven added inline comments.
src/kconfig_compiler/KConfigSourceGenerator.cpp
337

This character won't be easy on the user.
Ideally we perhaps would want to allow users to add <group key><group key> </group></group>
We could use alternatively attributes.

crossi updated this revision to Diff 75032.Feb 5 2020, 9:42 AM

remove TODO comment that was addressed

crossi added inline comments.Feb 5 2020, 9:54 AM
src/kconfig_compiler/KConfigSourceGenerator.cpp
337

I'm open for another separator, btw this part is not intended for the user, they have super user friendly KCM to edit their settings.

Adding nested <group> as you mentioned has bigger impact on compiler, xsd, and so on.

meven added inline comments.Feb 5 2020, 9:55 AM
src/kconfig_compiler/KConfigSourceGenerator.cpp
337

Here, I meant kcfg user, i.e dev users, since kconfig is a lib

crossi updated this revision to Diff 75056.Feb 5 2020, 3:32 PM

fix compiling error for kcfgfile arg="true"

crossi updated this revision to Diff 75059.Feb 5 2020, 3:39 PM

update tests

ervin added a comment.Feb 12 2020, 1:37 PM

@dfaure, any opinion on the separator character? It came from me checking which character is forbidden in group names, and it seems that only "group separator" is, so it started a bit like a joke with "I wonder if we'd need to patch KConfigSkeleton at all for subgroups if we pass that in a name", turns out we don't really and seeing how it look in the XML is... meh.

I see two ways out: modifying the schema to be able to specify subgroups in the XML or hijacking a different character that no one use in the wild (which would mean looking at every single kcfg out there... not easy).

I really have zero experience with this stuff, but you're asking for my opinion nonetheless, so you'll get it, as crappy as it might be :-)

Your comment refers to "group separator" as if it was an existing notion in KConfig. Can you point me where? Grepping for '241' or for 'separator' gives nothing.
Do KConfig files use this already? Or is this all kconfig_compiler specific?
I told you, I'm clueless :-)

ervin added a comment.EditedFeb 25 2020, 3:00 PM

I really have zero experience with this stuff, but you're asking for my opinion nonetheless, so you'll get it, as crappy as it might be :-)

Your comment refers to "group separator" as if it was an existing notion in KConfig. Can you point me where? Grepping for '241' or for 'separator' gives nothing.
Do KConfig files use this already? Or is this all kconfig_compiler specific?
I told you, I'm clueless :-)

Right, on the C++ side you'd have to look for \x1d which is the "group separator" character in the ascii table, for more information: https://www.asciihex.com/character/control/29/0x1D/gs-group-separator

dfaure added a comment.EditedFeb 25 2020, 4:08 PM

OK.

I wonder how/why it becomes &#x241d; in XML, but quick googling says that entity seems to be '␝' which indeed reads GS :)

At the KConfig level, this is good for catching people who don't use the proper APIs that encapsulate that stuff :-)
But at the kconfig_compiler level, people want to be able to write XML files by hand.
So "modifying the schema to be able to specify subgroups in the XML" sounds like the way to go, not coming up with yet another weird character (it might as well be this one then, for consistency).

crossi planned changes to this revision.EditedMar 2 2020, 4:24 PM

Thanks for your comments.

A new attribute to the group element would be more readable and easier to edit/maintain.

To generate code like :

KConfig config;
KConfigGroup generalGroup( &config, "General" );
KConfigGroup colorsGroup = generalGroup.group( "Colors" );

kcfg will look like :

<group name="Colors" parentGroup="General">
    <entry name="Foo" type="Bool">
        <default>true</default>
    </entry>
</group>

Currently, I only need one level of subgroup, let's keep it simple and drop the group separator stuff for the moment.

crossi updated this revision to Diff 76833.Mar 3 2020, 10:32 AM

rework: introduce parentGroup attribute to group element

crossi edited the summary of this revision. (Show Details)Mar 3 2020, 10:33 AM
ervin requested changes to this revision.Mar 5 2020, 2:59 PM
ervin added inline comments.
autotests/kconfig_compiler/kconfigcompiler_test.cpp
73

This seems unrelated... So we had this test case available but it was in fact never run?

autotests/kconfig_compiler/test_subgroups.kcfg
11

Now that I see it, I think I'd go for "parentGroupName" since this is not referential and really about the name (like the name parameter)

21

Probably worth also having cases with:

  • the group name being parameterized but not the parentGroup
  • both name and parentGroup not be parameterized

Just to have all the possible combinations.

src/kconfig_compiler/KConfigSourceGenerator.cpp
349

Unrelated right, this is not due to your patch, or am I confused?

src/kconfig_compiler/KConfigXmlParser.cpp
497

I'd const auto it, or at least const.

This revision now requires changes to proceed.Mar 5 2020, 2:59 PM
crossi planned changes to this revision.Mar 5 2020, 5:49 PM
crossi added inline comments.
autotests/kconfig_compiler/test_subgroups.kcfg
11

parentGroupName sounds more explicit, I will replace with it.

src/kconfig_compiler/KConfigSourceGenerator.cpp
349

It was there before my patch, just pointing it for later.

Fortunately, some of the concerns have been addressed in D27497

crossi updated this revision to Diff 77049.Mar 5 2020, 6:22 PM

rename attribute to parentGroupName

crossi marked 5 inline comments as done.Mar 5 2020, 6:24 PM
ervin accepted this revision.Mar 6 2020, 10:18 AM
This revision is now accepted and ready to land.Mar 6 2020, 10:18 AM

@dfaure, any opinion on this revision ?

apol added a subscriber: apol.Mar 11 2020, 4:18 PM

The patch and the feature sound good to me, the resulting xml feels a bit weird and could use some clarification.

autotests/kconfig_compiler/test_subgroups.kcfg
22

It feels odd to reference the parent name rather than having a group inside the other.

Why don't we do something like:

<group name="Potato">
    //entries
    <group name="SmallPotato">
        //entries
    </group>
</group>

Might be missing something.

In D27133#625924, @apol wrote:

The patch and the feature sound good to me, the resulting xml feels a bit weird and could use some clarification.

Thank you for your comment.

I agree it looks a bit odd, nested group element would be more xmlish.
We choose a simpler approach as moving in the kconfig_compiler code isn't easy and the need was for one kcm (notifications).

crossi edited the summary of this revision. (Show Details)Mar 12 2020, 8:37 AM
ervin accepted this revision.Mar 16 2020, 6:45 PM
meven accepted this revision.Apr 20 2020, 10:53 AM
This revision was automatically updated to reflect the committed changes.