Skip to content

Instantly share code, notes, and snippets.

@rolandschulz
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolandschulz/ee636f517d75e48bc68c to your computer and use it in GitHub Desktop.
Save rolandschulz/ee636f517d75e48bc68c to your computer and use it in GitHub Desktop.
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