Closed dafvid closed 1 year ago
Wow. I had no idea anyone even noticed this project yet. I'll add a readme. What kind of use were you thinking of?
The project is very early on. I can parse almost all of fully formed makefiles. I can output S-expressions, regenerate the makefile.
Heh, 8 years in the making though. First hit on Google for python parse make files
. My usage is I wanna follow changes in default versions in the FreeBSD ports tree and they are defined in a make file. So I thought there must a package for it and there was!
So this is the file I want to parse https://raw.githubusercontent.com/freebsd/freebsd-ports/main/Mk/bsd.default-versions.mk
I was bored at a previous job so started working on pymake in my spare time to give my brain something to chew on. Then I started a new job and got distracted for 6 years. :-D I keep needing to debug vendor makefiles so dragged myself back to this project. Taking a look at that bsd makefile...
I don't think my little project can help you. https://man.openbsd.org/make.1 Unfortunately, BSD make is quite a different dialect than GNU make. Looks like BSD make uses a ".name" structure which is very different than the $() style GNU make uses. (That's so weird. BSD probably preceded GNU so why did GNU use such a different syntax?)
Aw that's too bad. I'll have to keep looking or maybe try and parse just this one file.
Take a look at pyparsing. Really powerful, easy to use python parser generator. I started with it but turns out GNU make has very particular uses of whitespace the pyparsing couldn't handle.
Aw that's too bad. I'll have to keep looking or maybe try and parse just this one file.
I've been playing with using a tree-sitter based Makefile parser and have been relatively happy with the results. The one I'm using is at https://github.com/alemuller/tree-sitter-make.
I finally added a usage()
Hi I'd really like to use this but it's pretty hard to know where to start. Could you add something short on usage in the Readme perhaps?