Cache external programs in coredata.

pull/15/head
Jussi Pakkanen 12 years ago
parent 8c237ebfeb
commit 68b50bd732
  1. 9
      coredata.py
  2. 4
      interpreter.py

@ -37,14 +37,9 @@ class CoreData():
self.strip = options.strip
self.coverage = options.coverage
self.compilers = {}
self.deps = {}
# To prevent weird bugs, compiler name can not be altered
# after it is first declared. So always copy all compilers
# from old coredata.
if isinstance(options, CoreData):
self.compilers = options.compilers.copy()
else:
self.compilers = {}
self.ext_progs = {}
def load(filename):
obj = pickle.load(open(filename, 'rb'))

@ -615,8 +615,12 @@ class Interpreter():
if not isinstance(required, bool):
raise InvalidArguments('Line %d: "required" argument must be a boolean.' % node.lineno())
exename = args[0]
if exename in self.coredata.ext_progs and\
self.coredata.ext_progs[exename].found():
return self.coredata.ext_progs[exename]
result = shutil.which(exename) # Does .exe appending on Windows.
progobj = ExternalProgram(exename, result)
self.coredata.ext_progs[exename] = progobj
if required and not progobj.found():
raise InvalidArguments('Line %d: program "%s" not found.' % (node.lineno(), exename))
return progobj

Loading…
Cancel
Save