diff options
author | Josh Morman <mormjb@gmail.com> | 2020-04-23 15:03:55 -0400 |
---|---|---|
committer | Josh Morman <mormjb@gmail.com> | 2020-06-04 10:05:48 -0400 |
commit | 999c0e723240ee783bca17942f77a9d05bbfc168 (patch) | |
tree | 3661aeb0ef10bad228df014a20e5b0a63627c833 /gr-utils/bindtool/scripts/bind_gr_module.py | |
parent | a4e6d4d55b35ac36dd5915dec5145073d8ec3b9a (diff) |
utils: add functionality to generate bindings
This currently exists in two places
1) Bindtool (longevity TBD) which calls blocktool to parse the public
header file in the include directory
2) Modtool - binding of headers added to add and bind. rm, update,
info, etc still TODO
Diffstat (limited to 'gr-utils/bindtool/scripts/bind_gr_module.py')
-rw-r--r-- | gr-utils/bindtool/scripts/bind_gr_module.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/gr-utils/bindtool/scripts/bind_gr_module.py b/gr-utils/bindtool/scripts/bind_gr_module.py new file mode 100644 index 0000000000..5b3c691461 --- /dev/null +++ b/gr-utils/bindtool/scripts/bind_gr_module.py @@ -0,0 +1,60 @@ +import argparse +import os +from gnuradio.bindtool import BindingGenerator +import pathlib + +parser = argparse.ArgumentParser(description='Bind a GR In-Tree Module') +parser.add_argument('names', type=str, nargs='+', + help='Names of gr modules to bind (e.g. fft digital analog)') + +parser.add_argument('--output_dir', default='/tmp', + help='Output directory of generated bindings') +parser.add_argument('--prefix', help='Prefix of Installed GNU Radio') +parser.add_argument('--src', help='Directory of gnuradio source tree', + default=os.path.dirname(os.path.abspath(__file__))+'/../../..') +parser.add_argument( + '--include', help='Additional Include Dirs, comma separated', default='') +args = parser.parse_args() + +# NOTES: +# To generate QTGUI requires adding the QT headers as --include, e.g. +# bind_gr_module.py --prefix /share/gnuradio/grpybind --output_dir /share/tmp/take5 +# --include /usr/include/x86_64-linux-gnu/qt5/QtGui,/usr/include/x86_64-linux-gnu/qt5, +# /usr/include/x86_64-linux-gnu/qt5/QtCore,/usr/include/x86_64-linux-gnu/qt5/QtWidgets,/usr/include/qwt qtgui + +# To generate UHD requires adding the UHD headers, e.g. +# python3 /share/gnuradio/grpybind/src/gnuradio/gr-utils/python/bindtool/scripts/bind_gr_module.py +# --prefix /share/gnuradio/grpybind +# --include $UHD_PATH,$UHD_PATH/utils,$UHD_PATH/types,$UHD_PATH/transport,$UHD_PATH/usrp_clock,$UHD_PATH/rfnoc +# --output_dir /share/tmp/take5 uhd + + +print(pathlib.Path(__file__).parent.absolute()) +print(args) + +prefix = args.prefix +output_dir = args.output_dir +includes = args.include +for name in args.names: + if name not in ['gr', 'pmt']: + namespace = ['gr', name] + module_dir = os.path.abspath( + os.path.join(args.src, 'gr-'+name, 'include')) + prefix_include_root = 'gnuradio/'+name # pmt, gnuradio/digital, etc. + else: + namespace = [name] + module_dir = os.path.abspath(os.path.join( + args.src, 'gnuradio-runtime', 'include')) + if name == 'gr': + prefix_include_root = 'gnuradio' + module_dir = os.path.join(module_dir, 'gnuradio') + elif name == 'pmt': + prefix_include_root = 'pmt' + module_dir = os.path.join(module_dir, 'pmt') + + import warnings + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + bg = BindingGenerator(prefix, namespace, prefix_include_root, + output_dir, addl_includes=includes, match_include_structure=True) + bg.gen_bindings(module_dir) |