Compare commits

3 changed files with 34 additions and 24 deletions

No files matched your search

+19 -4
View File
@@ -1,9 +1,11 @@
project('rz-bindgen', 'c', 'cpp',
version: 'v0.5.0dev',
license: 'LGPL3')
license: 'LGPL3',
meson_version: '>=0.53.0')
pymod = import('python')
py = pymod.find_installation('python')
fs = import('fs')
py = pymod.find_installation()
clang_path = get_option('clang_path')
clang_args = get_option('clang_args')
@@ -28,6 +30,10 @@ if clang_path == ''
endif
endif
if not fs.exists(clang_path)
error('CLang path does not exist')
endif
if rizin_include_path == ''
rz_main = dependency('rz_main')
if rz_main.type_name() == 'pkgconfig'
@@ -79,6 +85,14 @@ bindgen_outputs = custom_target(
)
if target_swig
install_dir = py.get_install_dir()
plat_dir = py.get_path('platlib')
if plat_dir.startswith('/opt/homebrew') and (install_dir.endswith(plat_dir) or install_dir.endswith(plat_dir / '/'))
# Just use directly the platlib, this is a bug in Homebrew python / Meson
# See https://github.com/mesonbuild/meson/issues/10459
install_dir = plat_dir
endif
swig_output = custom_target(
'swig_output',
input: bindgen_outputs[swig_source_idx],
@@ -89,7 +103,7 @@ if target_swig
'-outdir', '@OUTDIR@', '@INPUT@'
],
install: true,
install_dir: [py.get_install_dir(), false]
install_dir: [install_dir, false]
)
swig_py = swig_output[0]
swig_wrap = swig_output[1]
@@ -106,7 +120,8 @@ if target_swig
rizin_include_path,
rizin_include_path / 'sdb'
),
install: true
install: true,
install_dir: install_dir
)
endif
-14
View File
@@ -377,20 +377,6 @@ def bind_io(io_h: Header) -> None:
Class(io_h, typedef="RzIOPlugin")
@threaded_header("rz_main.h")
def bind_main(main_h: Header) -> None:
"""
RzMain
"""
main_h.ignore("rz_main_version")
rz_main = Class(main_h, typedef="RzMain")
rz_main.add_constructor("rz_main_new")
rz_main.add_destructor("rz_main_free")
rz_main.add_prefixed_methods("rz_main_")
rz_main.add_prefixed_funcs("rz_main_")
@threaded_header("rz_util/rz_num.h")
def bind_num(num_h: Header) -> None:
"""
+15 -6
View File
@@ -4,11 +4,8 @@ def register_group(self, cmd, summary):
help_desc.summary = summary
self.rcmd.register_swig_command(cmd, None, None, help_desc)
import inspect
def register_command(self, cmd, fn):
import inspect
params = list(inspect.signature(fn).parameters.values())
core_arg = None
@@ -61,19 +58,31 @@ def register_command(self, cmd, fn):
if core_arg:
args[core_arg] = core
for i, param in enumerate(params):
arg = args_array[i + 1]
orig_arg = args_array[i + 1]
arg = orig_arg
if param.annotation == RzNumArg:
if not core.num.is_valid_input(arg):
raise ValueError(f"Could not convert '{orig_arg}' to RzNum value")
arg = core.num.math(arg)
elif param.annotation == int:
arg = int(arg)
try:
arg = int(arg)
except ValueError:
raise ValueError(f"Could not convert '{orig_arg}' to int") from e
elif param.annotation == RzFlagItem:
arg = core.flags.get(arg)
if arg is None:
raise ValueError(f"Could not find a flag named '{orig_arg}'")
elif param.annotation == RzAnalysisFunction:
arg = core.analysis.get_function_byname(arg)
if arg is None:
raise ValueError(f"Could not find a function named '{orig_arg}'")
args[param.name] = arg
return fn(**args)
except Exception as e:
print(e)
return False
director = wrapper()
director.__disown__()