Last active
August 29, 2015 14:02
-
-
Save rolandschulz/ee636f517d75e48bc68c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys,os,re | |
CMAKE_SOURCE_DIR="/home/rschulz/download/gromacs5.0" | |
sp=[CMAKE_SOURCE_DIR+"/src/", CMAKE_SOURCE_DIR+"/src/gromacs/legacyheaders/", os.path.abspath(os.path.dirname(sys.argv[1]))+"/"] | |
ll=file(sys.argv[1]).readlines() | |
of=file(sys.argv[1],"w") | |
inclp = re.compile('^# *include *"') | |
for l in ll: | |
if inclp.match(l): | |
fn=l[l.find('"')+1:l.rfind('"')] | |
if not fn.startswith("gromacs/"): | |
fp=None | |
for p in sp: | |
if os.path.isfile(p+fn): | |
np=os.path.relpath(p+fn, CMAKE_SOURCE_DIR+"/src") | |
if fp and fp!=np: | |
print "WARN %s: %s exists twice at %s and %s"%(sys.argv[1], fn, fp, np) | |
fp=np | |
if not fp: | |
print "WARN %s: %s not found"%(sys.argv[1], fn) | |
fp=fn | |
#print fn, fp | |
l=l[:l.find('"')+1]+fp+l[l.rfind('"'):] | |
of.write(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment