diff --git a/meson.build b/meson.build index 85e75d5d..06369e09 100644 --- a/meson.build +++ b/meson.build @@ -618,6 +618,19 @@ shared_library( install: false, ) +i_source = join_paths(meson.source_root(), 'src', 'hidpp.i') +c_source = swig_gen.process(i_source) +shared_library( + 'hidpp', + c_source, + name_prefix: '_', + c_args : ['-Wno-missing-prototypes', '-Wno-format-nonliteral'], + extra_files: [ i_source ] + src_libratbag , + dependencies: deps_libratbag + wrapper_deps, + include_directories : include_directories('src', 'tools'), + install: false, +) + # ratbagc is the layer that maps ratbagctl to the swig bindings ratbagc_py_conf = configuration_data() ratbagc_py_conf.set('LIBRATBAG_DATA_DIR', libratbag_data_dir_devel) diff --git a/src/hidpp.i b/src/hidpp.i new file mode 100644 index 00000000..3228307b --- /dev/null +++ b/src/hidpp.i @@ -0,0 +1,23 @@ +/* wrapping libratbag functions from hidpp*.h using SWIG. */ + +%module hidpp +%{ + /* the resulting C file should be built as a python extension */ + #define SWIG_FILE_WITH_INIT + /* Includes the header in the wrapper code */ + #include + #include + #include +%} +#define __attribute__(x) +#define _Static_assert(a,b) + + +/* Parse the header file to generate wrappers */ +%include "stdint.i" +%include "cpointer.i" +%pointer_functions(int, intp); +%pointer_functions(uint8_t, uint8_tp); +%pointer_functions(uint16_t, uint16_tp); +%include "hidpp-generic.h" +%include "hidpp20.h"