Compare commits

...
Author SHA1 Message Date
billow 8618b4051a Add binding for RzAnnotatedCode and RzCodeAnnotation headers 2025-10-01 03:01:38 +08:00
Khairul Azhar Kasmiran 318cfbc9b3 Cleanup inclusion of linux/limits.h (#80) 2025-03-16 14:53:25 +08:00
Khairul Azhar Kasmiran 05ce528bc2 ci: Upgrade to Ubuntu 24.04 (Noble) (#79)
* ci: Upgrade to Ubuntu 24.04 (Noble)
* Remove `pip3 --break-system-packages`
* Use `-include linux/limits.h` for Alpine build
2025-03-14 20:18:43 +08:00
Giovanni d9b84f46e7 Fix compilation (#77)
* Fix compilation due defines being redefined
* Add support for TypeKind.FUNCTIONNOPROTO
2025-02-18 15:40:17 +08:00
Anton Kochkov fe8468ea29 ci: use corresponding rizin branch 2024-12-21 20:44:59 +08:00
Anton Kochkov 4e324800d8 ci: use corresponding rizin branch (#75) 2024-12-21 20:11:59 +08:00
Anton Kochkov eecc6bb442 ci/mypy: disable unnecessary warning (#73) 2024-12-21 18:57:35 +08:00
Khairul Azhar Kasmiran b93006e24b Use / instead of \\ in CMAKE_PREFIX_PATH for Windows (#72) 2024-12-21 18:33:10 +08:00
wargio f1dbe864e6 Ensure argument name never matches the function name 2024-12-20 21:51:55 +08:00
wargio 1723f6e06e Revert "Fix wrong check on nonnull args which are inner not outer."
This reverts commit c527db8fcb.
2024-12-20 21:51:55 +08:00
wargio c527db8fcb Fix wrong check on nonnull args which are inner not outer. 2024-12-20 19:47:10 +08:00
Anton Kochkov 918136cbc2 ci: support pip3 for python 3.12 and later 2024-12-20 19:47:10 +08:00
Anton Kochkov 84a9542c9e ci: use macOS 14 as macOS 12 is deprecated 2024-12-20 19:47:10 +08:00
Anton Kochkov b47d3071c2 Update pypa/cibuildwheel to 2.22.0 2024-12-20 19:47:10 +08:00
Anton Kochkov 66f06da3cf Remove lastline from RzCons bindings 2024-12-20 19:47:10 +08:00
Anton Kochkov 8d233afef2 Remove SdbList as it was removed in Rizin (#64) 2024-05-22 22:48:05 +08:00
wargio 3fc9aedc2b Print filename when assert. 2024-05-22 20:35:27 +08:00
Khairul Azhar Kasmiran 046a905246 Uniquify artifact names (#63) 2024-04-19 19:03:47 +08:00
Khairul Azhar Kasmiran d00a7e9174 Use manylinux2014 base image instead (#62)
* Use `manylinux2014` base image instead
* Drop i686 support
2024-04-18 23:40:18 +08:00
Anton Kochkov 52d315929b Fix SWIG snippet example (#61) 2024-04-16 23:38:52 +08:00
pelijah 97d3a2d579 Add missing ht_* headers into cparser_header.py (#60) 2024-04-16 23:20:43 +08:00
Anton Kochkov 4d92885261 ci: update used pypa/cibuildwheel version (#59) 2024-04-16 20:57:16 +08:00
pelijah e106047c66 Add missing HT types to lint.py (#58) 2024-04-16 12:05:27 +03:00
wargio 23dcdda1b0 Revert "Format via black & fix lint check"
This reverts commit aa3340800e.
2024-04-16 11:39:00 +08:00
wargio aa3340800e Format via black & fix lint check 2024-04-16 11:36:06 +08:00
pelijah 438499c470 Add bindings for HtSP, HtSS, HtSU (#57) 2024-04-16 06:30:40 +08:00
Giovanni 1caa6237ee Merge pull request #55 from rizinorg/meson-wheel-option
Add meson option for wheel build
2024-03-15 22:32:29 +08:00
Khairul Azhar Kasmiran 70b2c55651 Add meson option for wheel build 2024-03-15 18:37:56 +08:00
16 changed files with 209 additions and 66 deletions

No files matched your search

+78 -31
View File
@@ -4,6 +4,11 @@ on:
workflow_dispatch:
workflow_call:
inputs:
external_call:
description: 'To distinguish workflow_call from regular push'
type: boolean
required: false
default: true
rizin_ref:
required: false
type: string
@@ -16,53 +21,95 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-2019, macos-12]
os: [ubuntu-24.04, windows-2019, macos-14]
steps:
- name: Checkout rz-bindgen
uses: actions/checkout@v3
- name: Install SWIG with Homebrew
if: matrix.os == 'macos-14' && matrix.enabled
run: brew install swig
- name: Checkout rz-bindgen
uses: actions/checkout@v4
# runned only from workflow_call
- name: Checkout rizin
uses: actions/checkout@v3
if: ${{ inputs.external_call }}
uses: actions/checkout@v4
with:
repository: rizinorg/rizin
path: rizin
ref: ${{ inputs.rizin_ref }}
- name: Build rz-bindgen
uses: pypa/[email protected]
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/*.tar.gz
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: wheelhouse/*.whl
ubuntu-default-llvm:
runs-on: ubuntu-22.04
steps:
- name: Checkout rz-bindgen
uses: actions/checkout@v3
with:
path: rz-bindgen
- name: Checkout rizin
uses: actions/checkout@v3
- name: Checkout rizin (stable)
if: ${{ !inputs.external_call && ((github.ref_name == 'stable') || (github.base_ref == 'stable')) }}
uses: actions/checkout@v4
with:
repository: rizinorg/rizin
path: rizin
ref: stable
- name: Checkout rizin (dev)
if: ${{ !inputs.external_call && ((github.ref_name != 'stable') && (github.base_ref != 'stable')) }}
uses: actions/checkout@v4
with:
repository: rizinorg/rizin
path: rizin
ref: dev
- name: Build rz-bindgen
uses: pypa/[email protected]
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist-${{ matrix.os }}
path: dist/*.tar.gz
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
ubuntu-default-llvm:
runs-on: ubuntu-24.04
steps:
- name: Checkout rz-bindgen
uses: actions/checkout@v4
with:
path: rz-bindgen
# runned only from workflow_call
- name: Checkout rizin
if: ${{ inputs.external_call }}
uses: actions/checkout@v4
with:
repository: rizinorg/rizin
path: rizin
ref: ${{ inputs.rizin_ref }}
- name: Checkout rizin (stable)
if: ${{ !inputs.external_call && ((github.ref_name == 'stable') || (github.base_ref == 'stable')) }}
uses: actions/checkout@v4
with:
repository: rizinorg/rizin
path: rizin
ref: stable
- name: Checkout rizin (dev)
if: ${{ !inputs.external_call && ((github.ref_name != 'stable') && (github.base_ref != 'stable')) }}
uses: actions/checkout@v4
with:
repository: rizinorg/rizin
path: rizin
ref: dev
- name: Install dependencies
run: |
sudo apt update
sudo apt-get --assume-yes install cmake swig pkg-config clang libclang-dev llvm wget unzip python3-wheel python3-setuptools build-essential python3-pip && sudo pip3 install meson ninja
sudo apt-get --assume-yes install cmake swig pkg-config clang libclang-dev llvm wget unzip python3-wheel python3-setuptools build-essential python3-pip
sudo pip3 install meson ninja
- name: Install rizin
run: |
+4 -4
View File
@@ -2,7 +2,7 @@ name: lint
on: push
jobs:
licenses:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout rz-bindgen
uses: actions/checkout@v3
@@ -10,7 +10,7 @@ jobs:
uses: fsfe/reuse-action@v1
python:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout rz-bindgen
uses: actions/checkout@v3
@@ -19,7 +19,7 @@ jobs:
pip install mypy pyflakes pylint black
- name: Run mypy
run: |
mypy src/main.py
mypy --disable-error-code misc src/main.py
if: ${{ always() }}
- name: Run pyflakes
run: |
@@ -35,7 +35,7 @@ jobs:
if: ${{ always() }}
codeql:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
permissions:
security-events: write
steps:
+2 -2
View File
@@ -7,7 +7,7 @@ on:
jobs:
extract-rizin-version:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
outputs:
rizin_version: ${{ steps.extract_version.outputs.result }}
steps:
@@ -21,7 +21,7 @@ jobs:
rizin_ref: ${{ needs.extract-rizin-version.outputs.rizin_version }}
publish-pypi:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: [build]
steps:
- name: Download artifacts
+22 -6
View File
@@ -4,32 +4,48 @@
set -ex
# Install deps
pip3 install meson ninja meson-python build
pygt311=$(python3 -c 'import sys; print(0) if sys.version_info.minor > 11 else print(1)' 2>&1)
if [[ $pygt311 == '0' ]]; then
pip3 install --break-system-packages meson ninja meson-python build
else
pip3 install meson ninja meson-python build
fi
if command -v apt; then
if command -v brew; then
brew install --require-sha swig
elif 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
# 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
apt update && apt install --assume-yes libclang-7-dev clang-7 llvm-7 sudo
elif command -v apk; then
apk update && apk add clang-dev
apk update && apk add clang-dev sudo
elif command -v yum; then
yum -y install llvm-toolset-7.0 llvm-toolset-7.0-llvm-devel sudo
# (CentOS 7) Uncomment following lines to see required paths in build log:
# yum -y install centos-release-scl
# source scl_source enable llvm-toolset-7.0 || true
fi
pushd rizin
if [[ "$OSTYPE" =~ msys* ]]; then
meson setup --buildtype=release --prefix='c:/rizin' --vsenv build
meson install -C build
else
if [[ "$OSTYPE" =~ linux* ]]; then
export CFLAGS="-include linux/limits.h"
fi
meson setup --buildtype=release --libdir=lib build
sudo meson install -C build
fi
meson install -C build
popd
if command -v apt; then
+3 -2
View File
@@ -108,6 +108,7 @@ if target_swig or target_sphinx
endif
if target_swig
wheel = get_option('wheel')
swig_output = custom_target(
'swig_output',
input: bindgen_outputs[swig_source_idx],
@@ -117,7 +118,7 @@ if target_swig
'-python', '-c++',
'-outdir', '@OUTDIR@', '@INPUT@'
],
install: host_machine.system() == 'windows',
install: wheel or host_machine.system() == 'windows',
install_dir: [py.get_install_dir(), false]
)
swig_py = swig_output[0]
@@ -134,7 +135,7 @@ if target_swig
py.dependency(),
rz_core,
],
install: host_machine.system() == 'windows',
install: wheel or host_machine.system() == 'windows',
)
if host_machine.system() != 'windows'
meson.add_install_script('py_install.py', swig_py.full_path(), ext_mod.full_path())
+1
View File
@@ -4,5 +4,6 @@ option('rizin_include_path', type: 'string', value: '')
option('targets', type: 'array', choices: ['SWIG', 'sphinx'], value: ['SWIG'])
option('plugin', type: 'feature', value: 'disabled')
option('wheel', type: 'boolean', value: false, description: 'Set up for pypa wheel build')
option('doxygen_path', type: 'string', value: '')
+7
View File
@@ -2,6 +2,13 @@
// SPDX-License-Identifier: LGPL-3.0-only
#include <Python.h>
/**
* Some defines in rz_userconf.h are conflicting with the ones in python.h
**/
#undef HAVE_EXPLICIT_BZERO
#undef HAVE_SIGACTION
#undef HAVE_REALPATH
#include <rz_core.h>
#include <rz_util/rz_file.h>
#include <swig_runtime.h>
+13 -4
View File
@@ -5,21 +5,30 @@ requires = [
]
build-backend = "mesonpy"
[tool.meson-python.args]
setup = ['-Dwheel=true']
[tool.cibuildwheel]
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-x86_64-image = "manylinux2014"
skip = "pp*"
[tool.cibuildwheel.linux]
environment = { PATH="/opt/rh/llvm-toolset-7.0/root/usr/bin:/opt/rh/llvm-toolset-7.0/root/usr/sbin:$PATH", LD_LIBRARY_PATH="/opt/rh/llvm-toolset-7.0/root/usr/lib64:$LD_LIBRARY_PATH" }
archs = ["x86_64"]
[tool.cibuildwheel.windows]
environment = { CMAKE_PREFIX_PATH="C:\\rizin" }
environment = { CMAKE_PREFIX_PATH="C:/rizin" }
archs = ["AMD64"]
[tool.cibuildwheel.macos]
environment = { PATH="/opt/homebrew/bin:$PATH", MACOSX_DEPLOYMENT_TARGET="14.0" }
[project]
name = "rz-bindings"
dynamic = [
'version',
]
requires-python = ">=3.8"
requires-python = ">=3.9"
readme = "README.md"
+47 -9
View File
@@ -258,7 +258,6 @@ def bind_cons(cons_h: Header) -> None:
typedef="RzCons",
ignore_fields={"term_raw", "term_buf"}, # struct termios
rename_fields={
"lastline": "_lastline",
"echo": "_echo",
"highlight": "_highlight",
"newline": "_newline",
@@ -328,6 +327,29 @@ def bind_core(core_h: Header) -> None:
Class(core_h, typedef="RzCoreFile")
@threaded_header("rz_util/rz_annotated_code.h")
def bind_annotated_code(annotated_code_h: Header) -> None:
"""
RzAnnotatedCode
"""
rz_code_annotation = Class(
annotated_code_h,
typedef="RzCodeAnnotation",
struct="rz_code_annotation_t",
)
rz_code_annotation.add_prefixed_methods("rz_annotation_")
rz_code_annotation.add_prefixed_funcs("rz_annotation_")
rz_annotated_code = Class(
annotated_code_h,
typedef="RzAnnotatedCode",
struct="rz_annotated_code_t",
)
rz_annotated_code.add_constructor("rz_annotated_code_new")
rz_annotated_code.add_destructor("rz_annotated_code_free")
rz_annotated_code.add_prefixed_methods("rz_annotated_code_")
rz_annotated_code.add_prefixed_funcs("rz_annotated_code_")
@threaded_header("rz_flag.h")
def bind_flag(flag_h: Header) -> None:
@@ -416,14 +438,6 @@ def bind_sdb(sdb_h: Header) -> None:
Class(sdb_h, typedef="Sdb", ignore_fields={"db", "m"})
@threaded_header("sdb/ls.h")
def bind_ls(ls_h: Header) -> None:
"""
ls
"""
Class(ls_h, typedef="SdbList")
@threaded_header("rz_util/ht_pp.h")
def bind_ht_pp(ht_pp_h: Header) -> None:
"""
@@ -454,3 +468,27 @@ def bind_ht_uu(ht_uu_h: Header) -> None:
ht_uu
"""
Class(ht_uu_h, typedef="HtUU")
@threaded_header("rz_util/ht_sp.h")
def bind_ht_sp(ht_sp_h: Header) -> None:
"""
ht_sp
"""
Class(ht_sp_h, typedef="HtSP")
@threaded_header("rz_util/ht_ss.h")
def bind_ht_ss(ht_ss_h: Header) -> None:
"""
ht_ss
"""
Class(ht_ss_h, typedef="HtSS")
@threaded_header("rz_util/ht_su.h")
def bind_ht_su(ht_su_h: Header) -> None:
"""
ht_su
"""
Class(ht_su_h, typedef="HtSU")
+2 -2
View File
@@ -2224,7 +2224,7 @@ class Type(Structure):
return result
assert self.kind == TypeKind.FUNCTIONPROTO
assert self.kind in (TypeKind.FUNCTIONPROTO, TypeKind.FUNCTIONNOPROTO)
return ArgumentsIterator(self)
@property
@@ -2320,7 +2320,7 @@ class Type(Structure):
def is_function_variadic(self):
"""Determine whether this function Type is a variadic function type."""
assert self.kind == TypeKind.FUNCTIONPROTO
assert self.kind in (TypeKind.FUNCTIONPROTO, TypeKind.FUNCTIONNOPROTO)
return conf.lib.clang_isFunctionTypeVariadic(self)
+1
View File
@@ -38,6 +38,7 @@ class TypeKind(Enum):
POINTER: TypeKind
CONSTANTARRAY: TypeKind
FUNCTIONPROTO: TypeKind
FUNCTIONNOPROTO: TypeKind
INCOMPLETEARRAY: TypeKind
RECORD: TypeKind
+10 -2
View File
@@ -98,12 +98,20 @@ class HeaderBuilder:
assert rizin_include_path
filename = os.path.abspath(os.path.join(rizin_include_path, *name_segments))
assert os.path.exists(filename)
assert os.path.exists(filename), f"File {filename} does not exist"
self.filename = filename
# Parse ht_inc.h if importing SDB hashtable header
self.extra_filename = None
if name_segments[-1] in ["ht_pp.h", "ht_pu.h", "ht_up.h", "ht_uu.h"]:
if name_segments[-1] in [
"ht_pp.h",
"ht_pu.h",
"ht_up.h",
"ht_uu.h",
"ht_sp.h",
"ht_ss.h",
"ht_su.h",
]:
self.extra_filename = "ht_inc.h"
def translation_unit(self) -> TranslationUnit:
+1 -1
View File
@@ -123,7 +123,7 @@ def wrap_type(type_: Type) -> CType:
cursor=type_.get_declaration(),
)
if type_.kind == TypeKind.FUNCTIONPROTO:
if type_.kind in (TypeKind.FUNCTIONPROTO, TypeKind.FUNCTIONNOPROTO):
return CFunctionType(
orig_type,
result=wrap_type(type_.get_result()),
+5
View File
@@ -265,6 +265,11 @@ def write_func(writer: Writer, func: Func, name: str, kind: FuncKind) -> None:
if arg_name == "self":
arg_name = "_self"
# if function arg is the same as the function name
# we rename the argument
if arg_name == name:
arg_name += "_arg"
arg_decl = stringify_decl(
arg_name,
arg.ctype,
+11 -1
View File
@@ -164,7 +164,17 @@ def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]
warn(
f"Type comment at {stringify_location(cursor.location)} should not have pointer"
)
elif typeref_spelling in {"HtPP", "HtUP", "HtUU", "RBTree", "SdbList"}:
elif typeref_spelling in {
"HtPP",
"HtUP",
"HtUU",
"HtPU",
"HtSP",
"HtSS",
"HtSU",
"RBTree",
"SdbList",
}:
pass
else:
warn(
+2 -2
View File
@@ -13,7 +13,7 @@ void register_swig_command(const char *str, CmdDirector *director,
} else {
char *dup = strdup(str);
dup[len - 1] = '\0';
parent = (RzCmdDesc *)ht_pp_find($self->ht_cmds, dup, NULL);
parent = (RzCmdDesc *)ht_sp_find($self->ht_cmds, dup, NULL);
free(dup);
}
@@ -21,7 +21,7 @@ void register_swig_command(const char *str, CmdDirector *director,
throw "Could not get parent RzCmdDesc";
}
RzCmdDesc *prev = (RzCmdDesc *)ht_pp_find($self->ht_cmds, str, NULL);
RzCmdDesc *prev = (RzCmdDesc *)ht_sp_find($self->ht_cmds, str, NULL);
std::string cmd(str);
if (prev) { // Update existing RzCmdDesc
auto it = SWIGCmds.find(cmd);