Compare commits

10 changed files with 65 additions and 141 deletions

No files matched your search

+17 -7
View File
@@ -17,18 +17,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-2019, macos-latest]
os: [ubuntu-20.04, windows-2019, macos-latest]
steps:
- name: Checkout rz-bindgen
uses: actions/checkout@v3
- name: Checkout rizin
uses: actions/checkout@v3
with:
repository: rizinorg/rizin
path: rizin
- name: Run rz-bindgen
uses: pypa/[email protected]
@@ -36,3 +30,19 @@ jobs:
uses: actions/upload-artifact@v3
with:
path: wheelhouse/*.whl
publish-pypi:
name: Publish PyPi
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [run-bindgen]
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish wheels
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_TOKEN }}
-50
View File
@@ -1,50 +0,0 @@
name: release-rz-bindgen
on:
push:
tags:
- v*
workflow_dispatch:
jobs:
run-bindgen:
name: Run bindgen
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-2019, macos-latest]
steps:
- name: Checkout rz-bindgen
uses: actions/checkout@v3
- name: Checkout rizin
uses: actions/checkout@v3
with:
repository: rizinorg/rizin
path: rizin
ref: ${{ github.ref }}
- name: Run rz-bindgen
uses: pypa/[email protected]
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: wheelhouse/*.whl
publish-pypi:
name: Publish PyPi
runs-on: ubuntu-latest
needs: [run-bindgen]
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish wheels
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_TOKEN }}
+2
View File
@@ -12,6 +12,8 @@ elif command -v apk; then
apk update && apk add clang-dev
fi
# Install rizin
git clone --depth 1 https://github.com/wingdeans/rizin.git -b header-types
pushd rizin
if [[ "$OSTYPE" =~ msys* ]]; then
+35 -48
View File
@@ -1,8 +1,7 @@
project('rz-bindgen', 'c', 'cpp',
version: 'v0.5.0dev',
license: 'LGPL3',
meson_version: '>=0.53.0',
default_options: ['python.install_env=auto'])
meson_version: '>=0.53.0')
pymod = import('python')
fs = import('fs')
@@ -35,13 +34,12 @@ if not fs.exists(clang_path)
error('CLang path does not exist')
endif
rz_core = disabler()
if rizin_include_path == ''
rz_core = dependency('rz_core')
if rz_core.type_name() == 'pkgconfig'
rizin_include_path = rz_core.get_variable(pkgconfig: 'includedir') / 'librz'
elif rz_core.type_name() == 'cmake'
rizin_include_path = rz_core.get_variable(cmake: 'PACKAGE_INCLUDE_DIRS').split(';')[0]
rz_main = dependency('rz_main')
if rz_main.type_name() == 'pkgconfig'
rizin_include_path = rz_main.get_variable(pkgconfig: 'includedir') / 'librz'
elif rz_main.type_name() == 'cmake'
rizin_include_path = rz_main.get_variable(cmake: 'PACKAGE_INCLUDE_DIRS').split(';')[0]
endif
endif
@@ -72,42 +70,29 @@ summary({
'Clang path': clang_path,
})
if target_swig or target_sphinx
src_files = files(
'src/binding_class.py',
'src/binding_director.py',
'src/binding_enum.py',
'src/binding_func.py',
'src/binding_generic.py',
'src/binding_generic_specializations.py',
'src/binding_typemap.py',
'src/bindings.py',
'src/cparser_header.py',
'src/cparser_types.py',
'src/generator_sphinx.py',
'src/generator_swig.py',
'src/lint.py',
'src/main.py',
'src/writer.py',
)
bindgen_outputs = custom_target(
'bindgen_outputs',
input: 'src' / 'main.py',
output: bindgen_output_names,
depend_files: src_files,
command: [
py, '@INPUT@',
'-o', '@OUTDIR@',
'--clang-path', clang_path,
'--clang-args', clang_args,
'--rizin-include-path', rizin_include_path,
'--targets', ','.join(targets)
] + (doxygen_path != '' ? ['--doxygen-path', doxygen_path] : [])
)
endif
bindgen_outputs = custom_target(
'bindgen_outputs',
input: 'src' / 'main.py',
output: bindgen_output_names,
command: [
py, '@INPUT@',
'-o', '@OUTDIR@',
'--clang-path', clang_path,
'--clang-args', clang_args,
'--rizin-include-path', rizin_include_path,
'--targets', ','.join(targets)
] + (doxygen_path != '' ? ['--doxygen-path', doxygen_path] : [])
)
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],
@@ -118,23 +103,25 @@ 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]
if not rz_core.found()
rz_core = dependency('rz_core')
endif
py.extension_module(
'_rizin',
swig_wrap,
dependencies: [
py.dependency(),
rz_core,
dependency('openssl', required: false),
dependency('rz_main')
],
include_directories: include_directories(
rizin_include_path,
rizin_include_path / 'sdb'
),
install: true,
install_dir: install_dir
)
endif
+1 -6
View File
@@ -8,17 +8,12 @@ swig_runtime = custom_target(
]
)
rz_core_dep = dependency('rz_core')
rizin_plugdir = rz_core_dep.get_variable(pkgconfig: 'plugindir', cmake: 'rz_core_PLUGINDIR')
library(
'rz-bindings-plugin',
['plugin.c', swig_runtime],
dependencies: [
py.dependency(embed: true),
dependency('openssl', required: false),
rz_core_dep,
dependency('rz_main')
],
install: true,
install_dir: rizin_plugdir,
)
+7 -18
View File
@@ -3,7 +3,6 @@
#include <Python.h>
#include <rz_core.h>
#include <rz_util/rz_file.h>
#include <swig_runtime.h>
static PyObject *rizin_module = NULL;
@@ -29,11 +28,6 @@ static PyObject *rizin_module = NULL;
} \
return result;
static int rz_bindings_run_file(RzLang *lang, const char *filename) {
FILE *file = fopen(filename, "rb");
return PyRun_SimpleFile(file, filename) == 0;
}
static int rz_bindings_init(RzLang *lang) {
DEFER_SETUP;
@@ -75,23 +69,12 @@ static int rz_bindings_init(RzLang *lang) {
Py_INCREF(py_rz_core);
Py_INCREF(rizin_module);
char *globpath = rz_file_path_join(bindings_dir, "*.py");
RzList *files = rz_file_globsearch(globpath, 1);
RzListIter *it;
char *filename;
rz_list_foreach(files, it, filename) {
rz_bindings_run_file(lang, filename);
}
free(globpath);
rz_list_free(files);
DEFER_CLEANUP;
}
static int rz_bindings_fini(RzLang *lang) {
Py_XDECREF(rizin_module);
return Py_FinalizeEx() == 0;
return Py_FinalizeEx();
}
static int rz_bindings_prompt(RzLang *lang) {
@@ -170,6 +153,11 @@ static int rz_bindings_prompt(RzLang *lang) {
DEFER_CLEANUP;
}
static int rz_bindings_run_file(RzLang *lang, const char *filename) {
FILE *file = fopen(filename, "rb");
return PyRun_SimpleFile(file, filename) == 0;
}
RzLangPlugin rz_lang_plugin_bindings = {
.name = "python",
.desc = "Python SWIG bindings",
@@ -186,4 +174,5 @@ RzLibStruct rizin_plugin = {
.data = &rz_lang_plugin_bindings,
.version = RZ_VERSION,
.free = NULL,
.pkgname = "rz-bindings",
};
+1 -2
View File
@@ -4,5 +4,4 @@ disable=too-many-instance-attributes,
too-many-branches,
too-many-return-statements,
too-many-locals,
broad-exception-raised,
fixme
fixme
+2 -2
View File
@@ -1,7 +1,7 @@
[build-system]
requires = [
"meson>=0.62.2",
"meson-python>=0.7.0"
"meson==0.62.2",
"meson-python==0.7.0"
]
build-backend = "mesonpy"
-7
View File
@@ -169,13 +169,6 @@ def bind_analysis(analysis_h: Header) -> None:
Class(analysis_h, typedef="RzAnalysisEsil")
Class(analysis_h, typedef="RzAnalysisPlugin")
Class(
analysis_h,
typedef="RzAnalysisXRef",
rename_fields={"from": "from_addr", "to": "to_addr"},
)
Enum(analysis_h, typedef="RzAnalysisXRefType")
@threaded_header("rz_asm.h")
def bind_asm(asm_h: Header) -> None:
-1
View File
@@ -12,7 +12,6 @@ from clang.cindex import TranslationUnit, Cursor, CursorKind
from cparser_types import CType, wrap_type
### Cursor wrappers ###
class AttrCursor:
"""