mirror of
https://github.com/triqs/dft_tools
synced 2024-12-25 05:43:40 +01:00
desc generator : minor cleaning
- while porting apps. examples to 1.2 - add build_ipytriqs, etc... - various details...
This commit is contained in:
parent
51b008c369
commit
522477eb2d
@ -151,6 +151,25 @@ macro (triqs_prepare_local_pytriqs_merged_with_my_python python_destination)
|
|||||||
)
|
)
|
||||||
execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_pytriqs)
|
execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_pytriqs)
|
||||||
|
|
||||||
|
# the ipython -> just replace python by ipython, keep the same path
|
||||||
|
STRING (REPLACE "python" "ipython" TRIQS_IPYTHON_INTERPRETER ${TRIQS_PYTHON_INTERPRETER})
|
||||||
|
|
||||||
|
# Create the local build_ipytriqs executable
|
||||||
|
file(WRITE ${CMAKE_BINARY_DIR}/build_ipytriqs
|
||||||
|
"#!/bin/bash
|
||||||
|
export PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH
|
||||||
|
${TRIQS_IPYTHON_INTERPRETER} $@"
|
||||||
|
)
|
||||||
|
execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_ipytriqs)
|
||||||
|
|
||||||
|
# Create the local build_ipytriqs_notebook executable
|
||||||
|
file(WRITE ${CMAKE_BINARY_DIR}/build_ipytriqs_notebook
|
||||||
|
"#!/bin/bash
|
||||||
|
export PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH
|
||||||
|
${TRIQS_IPYTHON_INTERPRETER} notebook --pylab=inline $@"
|
||||||
|
)
|
||||||
|
execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_ipytriqs_notebook)
|
||||||
|
|
||||||
# Get a list of all local py and pyx files
|
# Get a list of all local py and pyx files
|
||||||
file(GLOB_RECURSE relative_local RELATIVE ${CMAKE_SOURCE_DIR}/python *.py *.pyx)
|
file(GLOB_RECURSE relative_local RELATIVE ${CMAKE_SOURCE_DIR}/python *.py *.pyx)
|
||||||
foreach(f IN LISTS relative_local)
|
foreach(f IN LISTS relative_local)
|
||||||
|
@ -158,12 +158,13 @@ def build_functions_and_classes(cursor, namespaces=[]):
|
|||||||
|
|
||||||
def parse(filename, debug, compiler_options, where_is_libclang):
|
def parse(filename, debug, compiler_options, where_is_libclang):
|
||||||
|
|
||||||
compiler_options = [ '-std=c++11', '-stdlib=libc++', '-D__CODE_GENERATOR__'] + compiler_options
|
compiler_options = [ '-std=c++11', '-stdlib=libc++'] + compiler_options
|
||||||
|
|
||||||
clang.cindex.Config.set_library_file(where_is_libclang)
|
clang.cindex.Config.set_library_file(where_is_libclang)
|
||||||
index = clang.cindex.Index.create()
|
index = clang.cindex.Index.create()
|
||||||
|
print "Parsing the C++ file (may take a few seconds) ..."
|
||||||
translation_unit = index.parse(filename, ['-x', 'c++'] + compiler_options)
|
translation_unit = index.parse(filename, ['-x', 'c++'] + compiler_options)
|
||||||
print "Parsing done. \nExtracting ..."
|
print "... done. \nExtracting ..."
|
||||||
|
|
||||||
# If clang encounters errors, we report and stop
|
# If clang encounters errors, we report and stop
|
||||||
errors = [d for d in translation_unit.diagnostics if d.severity >= 3]
|
errors = [d for d in translation_unit.diagnostics if d.severity >= 3]
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
for m in c.methods :
|
for m in c.methods :
|
||||||
for t,n,d in m.params : analyse(t)
|
for t,n,d in m.params : analyse(t)
|
||||||
analyse(m.rtype)
|
analyse(m.rtype)
|
||||||
|
for p in c.proplist :
|
||||||
|
analyse(p.getter.rtype)
|
||||||
|
|
||||||
for f in functions :
|
for f in functions :
|
||||||
for t,n,d in f.params : analyse(t)
|
for t,n,d in f.params : analyse(t)
|
||||||
@ -51,7 +53,8 @@
|
|||||||
%>
|
%>
|
||||||
##
|
##
|
||||||
##
|
##
|
||||||
# Generated automatically using libclang
|
# Generated automatically using libclang using the command :
|
||||||
|
# ${shell_command}
|
||||||
from wrap_generator import *
|
from wrap_generator import *
|
||||||
|
|
||||||
# The module
|
# The module
|
||||||
@ -69,7 +72,7 @@ module.add_include("${args.filename}")
|
|||||||
module.add_preamble("""
|
module.add_preamble("""
|
||||||
// using namespace XXX;
|
// using namespace XXX;
|
||||||
""")
|
""")
|
||||||
##
|
|
||||||
##
|
##
|
||||||
%for c in classes :
|
%for c in classes :
|
||||||
# The class ${c.name}
|
# The class ${c.name}
|
||||||
|
@ -76,7 +76,7 @@ if __name__ == '__main__' :
|
|||||||
cls.methods = [m for m in cls.methods if m not in exclude]
|
cls.methods = [m for m in cls.methods if m not in exclude]
|
||||||
|
|
||||||
tpl = Template(filename=triqs_install_location + '/share/triqs/wrap_generator/wrap_desc.mako.py')
|
tpl = Template(filename=triqs_install_location + '/share/triqs/wrap_generator/wrap_desc.mako.py')
|
||||||
rendered = tpl.render(classes = classes, functions = functions, modulename=modulename, args = args )
|
rendered = tpl.render(classes = classes, functions = functions, modulename=modulename, args = args, shell_command= ' '.join(sys.argv) )
|
||||||
|
|
||||||
with open("{modulename}_desc.py".format(modulename=modulename), "w") as f:
|
with open("{modulename}_desc.py".format(modulename=modulename), "w") as f:
|
||||||
f.write(rendered)
|
f.write(rendered)
|
||||||
|
Loading…
Reference in New Issue
Block a user