Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Scripting the kernel configuration.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Cheesyjuggler64
n00b
n00b


Joined: 16 May 2024
Posts: 39

PostPosted: Fri Dec 27, 2024 6:38 pm    Post subject: Scripting the kernel configuration. Reply with quote

I've been trying to understand how interact with the kconfig system that the Linux kernel operates on to script it and I've got no idea how. Is there anyway to programmatically traverse the kconfig structure like menu config does but instead save it is some sort of custom data structure or do you have to individually read the kconfig and set up the structure yourself. Is there no way to hook into some preexisting configuration scripts which all ready have to read all this data like make menuconfig and work from there?
Back to top
View user's profile Send private message
zen_desu
Tux's lil' helper
Tux's lil' helper


Joined: 25 Oct 2024
Posts: 80

PostPosted: Fri Dec 27, 2024 6:42 pm    Post subject: Reply with quote

I'd like to be wrong, but I think you have to read the kconfig files in each dir and handle the includes in them.

that being said, you could use the parser from an existing script, and i think there are libraries for this.
_________________
µgRD dev
Wiki writer
Back to top
View user's profile Send private message
Cheesyjuggler64
n00b
n00b


Joined: 16 May 2024
Posts: 39

PostPosted: Fri Dec 27, 2024 11:04 pm    Post subject: Reply with quote

So if I were to try and build one is the best way to just read in all the kconfig files and assimilate a structure from there?
Back to top
View user's profile Send private message
Cheesyjuggler64
n00b
n00b


Joined: 16 May 2024
Posts: 39

PostPosted: Sat Dec 28, 2024 2:32 am    Post subject: Reply with quote

After doing some research, it says that there already exists an inbuilt parser for kconfig files. https://github.com/paulgazz/kmax/blob/master/kextractors/kextractor-4.12.8/README.md But I have no idea how to use it/ get its output. If anyone more experienced with this sort of thing could give me heads up that'd be great.

Moderator note: Fixed the url format. -- Banana
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2189

PostPosted: Sat Dec 28, 2024 11:31 am    Post subject: Reply with quote

Cheesyjuggler,

If you're into python, you might like https://pypi.org/project/kconfiglib/.

My experience writing an awk parser for Kconfig files is that their syntax is pretty horrible - basically an agglomeration of ad-hoc rules, resulting in such horrors as parsing producing different results depending on tab settings. Also, there are a heck of a lot of them in the kernel tree, not all of which will be relevant to any particular enquiry.

Net of that is, if someone's already gone through the pain and written a parser, then use it, don't reinvent the wheel!
_________________
Greybeard
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum