Organize code layout
This commit is contained in:
parent
5c1e8985a1
commit
d0935fe533
14 changed files with 22 additions and 11 deletions
|
|
@ -5,14 +5,14 @@ all: _api.so _capsule.so
|
||||||
_api.so _capsule.so: api.cpp capsule.cpp
|
_api.so _capsule.so: api.cpp capsule.cpp
|
||||||
python setup.py build_ext --inplace
|
python setup.py build_ext --inplace
|
||||||
|
|
||||||
|
api.cpp api.py: src/*.py include/llvm_binding/*.h
|
||||||
api.cpp api.py: binding/*.py include/llvm_binding/*.h
|
python gen.py api src $(PYMODS)
|
||||||
cd binding; python gen.py api $(PYMODS)
|
|
||||||
mv binding/api.cpp api.cpp
|
|
||||||
mv binding/api.py api.py
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f _api.so _capsule.so
|
rm -f _api.so _capsule.so
|
||||||
rm -f api.cpp api.py
|
rm -f api.cpp api.py
|
||||||
|
|
||||||
|
check: _api.so api.py
|
||||||
|
python test2.py
|
||||||
|
|
||||||
|
@PHONY: all clean check
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,7 @@ class Context(object):
|
||||||
println('')
|
println('')
|
||||||
|
|
||||||
|
|
||||||
def add_module(self, modname):
|
def add_module(self, module):
|
||||||
module = __import__(modname)
|
|
||||||
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)
|
symtab = sorted(allsyms, key=lambda x: x[1].rank)
|
||||||
|
|
@ -190,17 +189,29 @@ def wrap_println(f):
|
||||||
return println
|
return println
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
outputfilename = sys.argv[1]
|
||||||
|
srcdir = sys.argv[2]
|
||||||
|
modnames = sys.argv[3:]
|
||||||
|
|
||||||
|
modules = []
|
||||||
|
for m in modnames:
|
||||||
|
path = '%s.%s' % (srcdir, m)
|
||||||
|
print path
|
||||||
|
module = __import__(path)
|
||||||
|
for token in path.split('.')[1:]:
|
||||||
|
module = getattr(module, token)
|
||||||
|
modules.append(module)
|
||||||
|
|
||||||
context = Context()
|
context = Context()
|
||||||
for mod in sys.argv[2:]:
|
|
||||||
|
for mod in modules:
|
||||||
context.add_module(mod)
|
context.add_module(mod)
|
||||||
|
|
||||||
filename = sys.argv[1]
|
with open('%s.cpp' % outputfilename, 'w') as outfile:
|
||||||
with open('%s.cpp' % filename, 'w') as outfile:
|
|
||||||
println = wrap_println(outfile)
|
println = wrap_println(outfile)
|
||||||
populate_headers(println)
|
populate_headers(println)
|
||||||
context.generate_cpp(println)
|
context.generate_cpp(println)
|
||||||
with open('%s.py' % filename, 'w') as outfile:
|
with open('%s.py' % outputfilename, 'w') as outfile:
|
||||||
println = wrap_println(outfile)
|
println = wrap_println(outfile)
|
||||||
context.generate_py(println)
|
context.generate_py(println)
|
||||||
|
|
||||||
0
newbinding/src/__init__.py
Normal file
0
newbinding/src/__init__.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue