Update generator script so that order of modules does not matter.

This commit is contained in:
Siu Kwan Lam 2013-01-23 15:28:46 -06:00
commit c247cf9527
2 changed files with 10 additions and 5 deletions

View file

@ -1,9 +1,9 @@
PYTHON = python
PYMODS = raw_ostream SmallVector Type DerivedTypes StringRef
PYMODS += Value User Constant
PYMODS += LLVMContext AssemblyAnnotationWriter Module
PYMODS += LLVMContext AssemblyAnnotationWriter Module
PYMODS += Value User Constant
all: _api.so _capsule.so

View file

@ -56,6 +56,7 @@ class Context(object):
self.functions = {}
self.classes = {}
self.definitions = []
self._pending_symbols = []
def generate_cpp(self, println):
for i in self.includes:
@ -168,12 +169,15 @@ _init_extra_wrapper()
def add_module(self, module):
allsyms = [(k, v) for k, v in vars(module).items()
if isinstance(v, Binding)]
symtab = sorted(allsyms, key=lambda x: x[1].rank)
# generate includes
for k, v in symtab:
for k, v in allsyms:
self.includes |= v.include
self._pending_symbols.extend(allsyms)
def materialize(self):
symtab = sorted(self._pending_symbols, key=lambda x: x[1].rank)
# compile everything
for k, v in symtab:
buf = StringIO()
@ -237,6 +241,7 @@ if __name__ == '__main__':
for mod in modules:
context.add_module(mod)
context.materialize()
with open('%s.cpp' % outputfilename, 'w') as outfile:
println = wrap_println(outfile)