mirror of
https://github.com/rizinorg/rz-bindgen.git
synced 2026-11-07 18:36:41 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
968f931b95 | ||
|
|
b8eba9a251 | ||
|
|
63e4acd999 | ||
|
|
bc98be658d | ||
|
|
efe87d6d1b | ||
|
|
9f0fea8837 | ||
|
|
7172f6e9ba | ||
|
|
66dd4bf9e9 | ||
|
|
19f9fad430 | ||
|
|
19b165c789 | ||
|
|
5ab96866a1 | ||
|
|
b6df7168e1 | ||
|
|
c09e93e06e | ||
|
|
ab25a61ee7 | ||
|
|
18bab79f2a | ||
|
|
be13ad624e | ||
|
|
7ba0eaafca | ||
|
|
336169bb07 |
No files matched your search
+15
-23
@@ -1,13 +1,13 @@
|
||||
name: run-rz-bindgen
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'src/**.py'
|
||||
- 'src/**.pyi'
|
||||
- 'src/**.i'
|
||||
- 'meson.build'
|
||||
- 'meson_options.txt'
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
rizin_ref:
|
||||
required: false
|
||||
type: string
|
||||
default: 'dev'
|
||||
|
||||
jobs:
|
||||
run-bindgen:
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-20.04, windows-2019, macos-latest]
|
||||
os: [ubuntu-latest, windows-2019, macos-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout rz-bindgen
|
||||
@@ -28,27 +28,19 @@ jobs:
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
ref: ${{ inputs.rizin_ref }}
|
||||
|
||||
- name: Run rz-bindgen
|
||||
uses: pypa/[email protected]
|
||||
|
||||
- name: Upload artifacts
|
||||
- name: Upload sdist
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
path: wheelhouse/*.whl
|
||||
name: sdist
|
||||
path: dist/*.tar.gz
|
||||
|
||||
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
|
||||
- name: Upload wheels
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: artifact
|
||||
path: dist
|
||||
- name: Publish wheels
|
||||
uses: pypa/[email protected]
|
||||
with:
|
||||
password: ${{ secrets.PYPI_TOKEN }}
|
||||
name: wheels
|
||||
path: wheelhouse/*.whl
|
||||
@@ -0,0 +1,41 @@
|
||||
name: release-rz-bindgen
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- rizin-v*_*
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
extract-rizin-version:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
rizin_version: ${{ steps.extract_version.outputs.result }}
|
||||
steps:
|
||||
- id: extract_version
|
||||
run: echo "result=$(echo ${{ github.ref }} | cut -d'_' -f1 | cut -d'-' -f2-)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
run-bindgen:
|
||||
uses: ./.github/workflows/ci.yml
|
||||
needs: [extract-rizin-version]
|
||||
with:
|
||||
rizin_ref: ${{ needs.extract-rizin-version.outputs.rizin_version }}
|
||||
|
||||
publish-pypi:
|
||||
name: Publish PyPi
|
||||
runs-on: ubuntu-latest
|
||||
needs: [run-bindgen]
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheels
|
||||
path: dist
|
||||
- name: Download sdist
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: sdist
|
||||
path: dist
|
||||
- name: Publish wheels
|
||||
uses: pypa/[email protected]
|
||||
with:
|
||||
password: ${{ secrets.PYPI_TOKEN }}
|
||||
+18
-1
@@ -4,12 +4,23 @@
|
||||
set -ex
|
||||
|
||||
# Install deps
|
||||
pip3 install meson ninja meson-python
|
||||
pip3 install meson ninja meson-python build
|
||||
|
||||
if command -v apt; then
|
||||
set +e
|
||||
grep VERSION_CODENAME=stretch /etc/os-release >/dev/null 2>/dev/null
|
||||
if [[ $? == 0 ]] ; then
|
||||
# Required because manylinux_2_24 uses Debian Stretch and the repos are not available anymore
|
||||
echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
|
||||
echo "deb http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list
|
||||
echo "Acquire::Check-Valid-Until no;" > /etc/apt/apt.conf.d/99no-check-valid-until
|
||||
fi
|
||||
set -e
|
||||
apt update && apt install --assume-yes libclang-7-dev clang-7 llvm-7
|
||||
elif command -v apk; then
|
||||
apk update && apk add clang-dev
|
||||
elif command -v brew; then
|
||||
brew install pkg-config
|
||||
fi
|
||||
|
||||
pushd rizin
|
||||
@@ -22,3 +33,9 @@ fi
|
||||
|
||||
meson install -C build
|
||||
popd
|
||||
|
||||
if command -v apt; then
|
||||
if [ ! -e dist/*.tar.gz ] ; then
|
||||
python3 -m build --sdist
|
||||
fi
|
||||
fi
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
project('rz-bindgen', 'c', 'cpp',
|
||||
version: 'v0.5.0dev',
|
||||
version: '0.6.0',
|
||||
license: 'LGPL3',
|
||||
meson_version: '>=0.53.0',
|
||||
default_options: ['python.install_env=auto'])
|
||||
@@ -21,7 +21,7 @@ doxygen_path = get_option('doxygen_path')
|
||||
if clang_path == ''
|
||||
llvm = dependency('llvm', required: false)
|
||||
if llvm.found()
|
||||
clang_path = llvm.get_variable(configtool: 'libdir', default_value: 'none')
|
||||
clang_path = llvm.get_variable(cmake: 'LLVM_LIBRARY_DIRS', configtool: 'libdir', default_value: 'none')
|
||||
elif build_machine.system() == 'darwin'
|
||||
clang_path = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/'
|
||||
elif build_machine.system() == 'windows'
|
||||
@@ -155,3 +155,4 @@ endif
|
||||
if get_option('plugin').enabled()
|
||||
subdir('plugin')
|
||||
endif
|
||||
|
||||
@@ -4,4 +4,5 @@ disable=too-many-instance-attributes,
|
||||
too-many-branches,
|
||||
too-many-return-statements,
|
||||
too-many-locals,
|
||||
fixme
|
||||
broad-exception-raised,
|
||||
fixme
|
||||
+17
-1
@@ -10,14 +10,30 @@ build-verbosity = 3
|
||||
before-all = "bash {project}/cibw_before_all.sh"
|
||||
manylinux-x86_64-image = "manylinux_2_24"
|
||||
manylinux-i686-image = "manylinux_2_24"
|
||||
manylinux-aarch64-image = "manylinux_2_24"
|
||||
manylinux-ppc64le-image = "manylinux_2_24"
|
||||
manylinux-s390x-image = "manylinux_2_24"
|
||||
manylinux-pypy_x86_64-image = "manylinux_2_24"
|
||||
manylinux-pypy_i686-image = "manylinux_2_24"
|
||||
manylinux-pypy_aarch64-image = "manylinux_2_24"
|
||||
skip = "pp*"
|
||||
|
||||
[tool.cibuildwheel.windows]
|
||||
environment = { CMAKE_PREFIX_PATH="C:\\rizin" }
|
||||
archs = ["AMD64"]
|
||||
|
||||
[tool.cibuildwheel.linux]
|
||||
#archs = ["x86_64", "aarch64", "ppc64le", "s390x"]
|
||||
archs = ["x86_64", "aarch64"]
|
||||
|
||||
[tool.cibuildwheel.macos]
|
||||
#archs = ["x86_64", "arm64", "universal2"]
|
||||
archs = ["x86_64"]
|
||||
|
||||
[project]
|
||||
name = "rz-bindings"
|
||||
version = "0.5.0"
|
||||
dynamic = [
|
||||
'version',
|
||||
]
|
||||
requires-python = ">=3.8"
|
||||
readme = "README.md"
|
||||
@@ -55,17 +55,3 @@ class Typemap:
|
||||
f"Function {func.cfunc.cursor.spelling} did not match typemap `{self.args}`. "
|
||||
f"Contents were: {args}"
|
||||
)
|
||||
|
||||
|
||||
buffer_len_typemap = Typemap(
|
||||
"buffer_len",
|
||||
[TypemapArg("unsigned char *", "buf"), TypemapArg("unsigned long long", "len")],
|
||||
)
|
||||
|
||||
const_buffer_len_typemap = Typemap(
|
||||
"const_buffer_len",
|
||||
[
|
||||
TypemapArg("const unsigned char *", "buf"),
|
||||
TypemapArg("unsigned long long", "len"),
|
||||
],
|
||||
)
|
||||
+8
-22
@@ -12,7 +12,6 @@ from binding_class import Class
|
||||
from binding_director import Director
|
||||
from binding_enum import Enum, MacroEnum
|
||||
from binding_generic import Generic
|
||||
from binding_typemap import buffer_len_typemap, const_buffer_len_typemap
|
||||
|
||||
HeaderFunc = Callable[[Header], None]
|
||||
threaded_headers: OrderedDict[str, HeaderFunc] = OrderedDict()
|
||||
@@ -169,6 +168,13 @@ 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:
|
||||
@@ -214,27 +220,7 @@ def bind_buf(buf_h: Header) -> None:
|
||||
RzBuf
|
||||
"""
|
||||
rz_buf = Class(buf_h, typedef="RzBuffer")
|
||||
|
||||
# const ut8 *buffer, ut64 len
|
||||
for name in [
|
||||
"append_bytes",
|
||||
"prepend_bytes",
|
||||
"set_bytes",
|
||||
"insert_bytes",
|
||||
"write",
|
||||
"write_at",
|
||||
]:
|
||||
rz_buf.add_method(
|
||||
f"rz_buf_{name}",
|
||||
rename=name,
|
||||
typemaps=[const_buffer_len_typemap],
|
||||
)
|
||||
|
||||
# ut8 *buffer, ut64 len
|
||||
rz_buf.add_method("rz_buf_read", rename="read", typemaps=[buffer_len_typemap])
|
||||
rz_buf.add_method("rz_buf_read_at", rename="read_at", typemaps=[buffer_len_typemap])
|
||||
|
||||
rz_buf.add_method("rz_buf_seek", rename="seek")
|
||||
rz_buf.add_prefixed_methods("rz_buf_")
|
||||
|
||||
MacroEnum(buf_h, "RZ_BUF_SET", "RZ_BUF_CUR", "RZ_BUF_END")
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ from clang.cindex import TranslationUnit, Cursor, CursorKind
|
||||
|
||||
from cparser_types import CType, wrap_type
|
||||
|
||||
|
||||
### Cursor wrappers ###
|
||||
class AttrCursor:
|
||||
"""
|
||||
|
||||
@@ -21,22 +21,10 @@ void rizin_try_warn_deprecate(const char *name, const char *c_name) {
|
||||
|
||||
// Buffer typemaps
|
||||
%include <pybuffer.i>
|
||||
|
||||
%define %buffer_len_activate(TYPE, SIZE)
|
||||
%pybuffer_mutable_binary(TYPE, SIZE);
|
||||
%enddef
|
||||
|
||||
%define %const_buffer_len_activate(TYPE, SIZE)
|
||||
%pybuffer_binary(TYPE, SIZE);
|
||||
%enddef
|
||||
|
||||
%define %buffer_len_deactivate(TYPE, SIZE)
|
||||
%typemap(in) (TYPE, SIZE);
|
||||
%enddef
|
||||
|
||||
%define %const_buffer_len_deactivate(TYPE, SIZE)
|
||||
%typemap(in) (TYPE, SIZE);
|
||||
%enddef
|
||||
%pybuffer_mutable_binary(unsigned char *buf, unsigned long long len);
|
||||
%pybuffer_binary(const unsigned char *buf, unsigned long long len);
|
||||
%pybuffer_mutable_binary(unsigned char *buf, int len);
|
||||
%pybuffer_binary(const unsigned char *buf, int len);
|
||||
|
||||
// CArrays
|
||||
%include <carrays.i>
|
||||
|
||||
Reference in new issue
Block a user