mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
use $INCLUDE path (Mark Hammond)
This commit is contained in:
parent
3256e87dbc
commit
514d351d45
1 changed files with 26 additions and 7 deletions
|
@ -38,6 +38,14 @@ p_char = regex.compile("'\(\\\\.[^\\\\]*\|[^\\\\]\)'")
|
||||||
|
|
||||||
filedict = {}
|
filedict = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
searchdirs=string.splitfields(os.environ['include'],';')
|
||||||
|
except KeyError:
|
||||||
|
try:
|
||||||
|
searchdirs=string.splitfields(os.environ['INCLUDE'],';')
|
||||||
|
except KeyError:
|
||||||
|
searchdirs=['/usr/include']
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'i:')
|
opts, args = getopt.getopt(sys.argv[1:], 'i:')
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
|
@ -59,8 +67,10 @@ def main():
|
||||||
outfp = open(outfile, 'w')
|
outfp = open(outfile, 'w')
|
||||||
outfp.write('# Generated by h2py from %s\n' % filename)
|
outfp.write('# Generated by h2py from %s\n' % filename)
|
||||||
filedict = {}
|
filedict = {}
|
||||||
if filename[:13] == '/usr/include/':
|
for dir in searchdirs:
|
||||||
filedict[filename[13:]] = None
|
if filename[:len(dir)] == dir:
|
||||||
|
filedict[filename[len(dir)+1:]] = None # no '/' trailing
|
||||||
|
break
|
||||||
process(fp, outfp)
|
process(fp, outfp)
|
||||||
outfp.close()
|
outfp.close()
|
||||||
fp.close()
|
fp.close()
|
||||||
|
@ -114,9 +124,18 @@ def process(fp, outfp, env = {}):
|
||||||
filename = line[a:b]
|
filename = line[a:b]
|
||||||
if not filedict.has_key(filename):
|
if not filedict.has_key(filename):
|
||||||
filedict[filename] = None
|
filedict[filename] = None
|
||||||
outfp.write(
|
inclfp = None
|
||||||
'\n# Included from %s\n' % filename)
|
for dir in searchdirs:
|
||||||
inclfp = open('/usr/include/' + filename, 'r')
|
try:
|
||||||
process(inclfp, outfp, env)
|
inclfp = open(dir + '/' + filename, 'r')
|
||||||
main()
|
break
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
if inclfp:
|
||||||
|
outfp.write(
|
||||||
|
'\n# Included from %s\n' % filename)
|
||||||
|
process(inclfp, outfp, env)
|
||||||
|
else:
|
||||||
|
sys.stderr.write('Warning - could not find file %s' % filename)
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue