Update generator script so that order of modules does not matter.
This commit is contained in:
parent
e9e1f5703d
commit
c247cf9527
2 changed files with 10 additions and 5 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
PYTHON = python
|
PYTHON = python
|
||||||
|
|
||||||
PYMODS = raw_ostream SmallVector Type DerivedTypes StringRef
|
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
|
all: _api.so _capsule.so
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class Context(object):
|
||||||
self.functions = {}
|
self.functions = {}
|
||||||
self.classes = {}
|
self.classes = {}
|
||||||
self.definitions = []
|
self.definitions = []
|
||||||
|
self._pending_symbols = []
|
||||||
|
|
||||||
def generate_cpp(self, println):
|
def generate_cpp(self, println):
|
||||||
for i in self.includes:
|
for i in self.includes:
|
||||||
|
|
@ -168,12 +169,15 @@ _init_extra_wrapper()
|
||||||
def add_module(self, module):
|
def add_module(self, module):
|
||||||
allsyms = [(k, v) for k, v in vars(module).items()
|
allsyms = [(k, v) for k, v in vars(module).items()
|
||||||
if isinstance(v, Binding)]
|
if isinstance(v, Binding)]
|
||||||
symtab = sorted(allsyms, key=lambda x: x[1].rank)
|
|
||||||
|
|
||||||
# generate includes
|
# generate includes
|
||||||
for k, v in symtab:
|
for k, v in allsyms:
|
||||||
self.includes |= v.include
|
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
|
# compile everything
|
||||||
for k, v in symtab:
|
for k, v in symtab:
|
||||||
buf = StringIO()
|
buf = StringIO()
|
||||||
|
|
@ -237,6 +241,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
for mod in modules:
|
for mod in modules:
|
||||||
context.add_module(mod)
|
context.add_module(mod)
|
||||||
|
context.materialize()
|
||||||
|
|
||||||
with open('%s.cpp' % outputfilename, 'w') as outfile:
|
with open('%s.cpp' % outputfilename, 'w') as outfile:
|
||||||
println = wrap_println(outfile)
|
println = wrap_println(outfile)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue