free hit counter

Friday, October 29, 2010

python helps qmake

The more python I write the more I like it. However, the whole join concept for printing lists seems a little odd untill you just accept its arbitraryness.

Still there's no arguing that this is a very concise, readable, little bit of code to generate a qmake .pri file from all the files in a dir.

# Generate a QMake include file for all the files in a dir

import os, re

theDir= "."
files= os.listdir(theDir)

rxHeaders= re.compile(".*\.h")
rxSources= re.compile(".*\.c(pp)?")

sources= filter(, files)
headers= filter(, files)

print "# autogenerated qMake include file for files in %s\n"%(os.path.realpath(theDir))
print "\n".join("HEADERS+= %s"%(i) for i in headers)
print "\n"
print "\n".join("SOURCES+= %s"%(i) for i in sources)



Post a Comment

<< Home