mirror of
https://github.com/rizinorg/rz-bindgen.git
synced 2026-11-08 08:08:19 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bee5c3771 | ||
|
|
dd35844550 | ||
|
|
e4aef7d474 | ||
|
|
a03d1f32f5 | ||
|
|
fc64be188f | ||
|
|
aabbf0df6b | ||
|
|
5740a3770b | ||
|
|
878f562385 | ||
|
|
a71ec49cf0 | ||
|
|
48bc95c67a | ||
|
|
4a15bfe470 | ||
|
|
f9456f670c | ||
|
|
961e34a258 | ||
|
|
ad843b76d1 | ||
|
|
00422160f1 | ||
|
|
fadef06f39 |
No files matched your search
+13
-19
@@ -26,20 +26,20 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-24.04, windows-2022, macos-15]
|
||||
os: [ubuntu-24.04, windows-2022, macos-14]
|
||||
|
||||
steps:
|
||||
- name: Install SWIG with Homebrew
|
||||
if: matrix.os == 'macos-15' && matrix.enabled
|
||||
if: matrix.os == 'macos-14' && matrix.enabled
|
||||
run: brew install swig
|
||||
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
|
||||
# runned only from workflow_call
|
||||
- name: Checkout rizin
|
||||
if: ${{ inputs.external_call }}
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
|
||||
- name: Checkout rizin (stable)
|
||||
if: ${{ !inputs.external_call && ((github.ref_name == 'stable') || (github.base_ref == 'stable')) }}
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
@@ -55,14 +55,14 @@ jobs:
|
||||
|
||||
- name: Checkout rizin (dev)
|
||||
if: ${{ !inputs.external_call && ((github.ref_name != 'stable') && (github.base_ref != 'stable')) }}
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
ref: dev
|
||||
|
||||
- name: Build rz-bindgen
|
||||
uses: pypa/cibuildwheel@v4.3.5
|
||||
uses: pypa/cibuildwheel@v3.4.1
|
||||
|
||||
- name: Upload sdist
|
||||
uses: actions/upload-artifact@v7
|
||||
@@ -81,14 +81,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: rz-bindgen
|
||||
|
||||
# runned only from workflow_call
|
||||
- name: Checkout rizin
|
||||
if: ${{ inputs.external_call }}
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
|
||||
- name: Checkout rizin (stable)
|
||||
if: ${{ !inputs.external_call && ((github.ref_name == 'stable') || (github.base_ref == 'stable')) }}
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
|
||||
- name: Checkout rizin (dev)
|
||||
if: ${{ !inputs.external_call && ((github.ref_name != 'stable') && (github.base_ref != 'stable')) }}
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
@@ -132,12 +132,6 @@ jobs:
|
||||
- name: Test python lang plugin
|
||||
run: rizin -qc "Ll" | grep "Python SWIG"
|
||||
|
||||
- name: Checkout our Testsuite Binaries
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
repository: rizinorg/rizin-testbins
|
||||
path: rz-bindgen/test/bins
|
||||
|
||||
- name: Run rz-test
|
||||
run: rz-test -L db/examples
|
||||
working-directory: rz-bindgen/test
|
||||
run: rz-test -L tests/
|
||||
working-directory: rz-bindgen
|
||||
@@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: REUSE compliance check
|
||||
uses: fsfe/reuse-action@v6
|
||||
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Install tools
|
||||
run: |
|
||||
pip install mypy pyflakes pylint black
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
security-events: write
|
||||
steps:
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v4
|
||||
with:
|
||||
|
||||
@@ -35,6 +35,6 @@ jobs:
|
||||
name: sdist
|
||||
path: dist
|
||||
- name: Publish wheels
|
||||
uses: pypa/[email protected].3
|
||||
uses: pypa/[email protected].0
|
||||
with:
|
||||
password: ${{ secrets.PYPI_TOKEN }}
|
||||
+1
-7
@@ -46,13 +46,7 @@ SPDX-FileCopyrightText = "2022 wingdeans <[email protected]>"
|
||||
SPDX-License-Identifier = "LGPL-3.0-only"
|
||||
|
||||
[[annotations]]
|
||||
path = "test/db/**"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2026 RizinOrg <[email protected]>"
|
||||
SPDX-License-Identifier = "LGPL-3.0-only"
|
||||
|
||||
[[annotations]]
|
||||
path = "test/.gitignore"
|
||||
path = "tests/**"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2026 RizinOrg <[email protected]>"
|
||||
SPDX-License-Identifier = "LGPL-3.0-only"
|
||||
|
||||
+2
-2
@@ -35,11 +35,11 @@ fi
|
||||
|
||||
pushd rizin
|
||||
|
||||
if [[ "$OSTYPE" =~ msys|cygwin ]]; then
|
||||
if [[ "$OSTYPE" =~ msys* ]]; then
|
||||
meson setup --buildtype=release --prefix='c:/rizin' --vsenv build
|
||||
meson install -C build
|
||||
else
|
||||
if [[ "$OSTYPE" == linux* ]]; then
|
||||
if [[ "$OSTYPE" =~ linux* ]]; then
|
||||
export CFLAGS="-include linux/limits.h"
|
||||
fi
|
||||
meson setup --buildtype=release --libdir=lib build
|
||||
|
||||
+3
-3
@@ -29,12 +29,12 @@ builder.enable_load_buffer = True
|
||||
plugin = builder.build(CustomBinPlugin())
|
||||
```
|
||||
|
||||
`RzBinPluginBuilder::build` returns an `RzBinPlugin` struct which has the enabled function pointers set to custom C functions which call into the currently active director. Enabling functions is done using variables on the builder which are named the same as their corresponding struct function pointer prefixed with `enable_`. To use the plugin, simply add the plugin to `core.bin`.
|
||||
`RzBinPluginBuilder::build` returns an `RzBinPlugin` struct which has the enabled function pointers set to custom C functions which call into the currently active director. Enabling functions is done using variables on the builder which are named the same as their corresponding struct function pointer prefixed with `enable_`. To use the plugin, simply append the struct to `core.bin.plugins`.
|
||||
|
||||
```py
|
||||
core = rizin.RzCore()
|
||||
plugin.thisown = False
|
||||
core.bin.plugin_add(plugin)
|
||||
core.bin.plugins.append(plugin)
|
||||
```
|
||||
|
||||
Now it is possible to see the `SWIGCustom` plugin when listing the binary plugins with `iL`:
|
||||
@@ -72,7 +72,7 @@ plugin, plugin_struct = rizin.register_RzBinPlugin(CustomBinPlugin)
|
||||
|
||||
core = rizin.RzCore()
|
||||
plugin_struct.thisown = False
|
||||
core.bin.plugin_add(plugin_struct)
|
||||
core.bin.plugins.append(plugin_struct)
|
||||
|
||||
# Run rizin and load binary
|
||||
core.bin.force_plugin(plugin.name)
|
||||
|
||||
@@ -30,7 +30,7 @@ builder.enable_load_buffer = True
|
||||
plugin = builder.build(CustomBinPlugin())
|
||||
|
||||
core = rizin.RzCore()
|
||||
core.bin.plugin_add(plugin)
|
||||
core.bin.plugins.append(plugin)
|
||||
|
||||
# Run rizin and load binary
|
||||
core.bin.force_plugin(plugin.name)
|
||||
|
||||
@@ -21,7 +21,7 @@ plugin, plugin_struct = rizin.register_RzBinPlugin(CustomBinPlugin)
|
||||
|
||||
core = rizin.RzCore()
|
||||
plugin_struct.thisown = False
|
||||
core.bin.plugin_add(plugin_struct)
|
||||
core.bin.plugins.append(plugin_struct)
|
||||
|
||||
# Run rizin and load binary
|
||||
core.bin.force_plugin(plugin.name)
|
||||
|
||||
@@ -16,7 +16,6 @@ def install_files(scheme):
|
||||
elif file.endswith(".so"):
|
||||
dest_type = 'platlib'
|
||||
install_dir = sysconfig.get_path(dest_type, scheme)
|
||||
os.makedirs(install_dir, exist_ok=True)
|
||||
shutil.copy(file, install_dir)
|
||||
print(f"Installing {os.path.basename(file)} to {install_dir}")
|
||||
|
||||
|
||||
+2
-2
@@ -19,11 +19,11 @@ environment = { PATH="/opt/rh/llvm-toolset-7.0/root/usr/bin:/opt/rh/llvm-toolset
|
||||
archs = ["x86_64"]
|
||||
|
||||
[tool.cibuildwheel.windows]
|
||||
environment = { CMAKE_PREFIX_PATH="C:/rizin", PATH="C:/rizin/bin;$PATH" }
|
||||
environment = { CMAKE_PREFIX_PATH="C:/rizin" }
|
||||
archs = ["AMD64"]
|
||||
|
||||
[tool.cibuildwheel.macos]
|
||||
environment = { PATH="/opt/homebrew/bin:$PATH", MACOSX_DEPLOYMENT_TARGET="15.0" }
|
||||
environment = { PATH="/opt/homebrew/bin:$PATH", MACOSX_DEPLOYMENT_TARGET="14.0" }
|
||||
|
||||
[project]
|
||||
name = "rz-bindings"
|
||||
|
||||
+5
-23
@@ -110,25 +110,8 @@ def cursor_get_annotations(cursor: Cursor) -> List[str]:
|
||||
]
|
||||
|
||||
|
||||
generic_types = {
|
||||
"RzList",
|
||||
"RzListIter",
|
||||
"RzPVector",
|
||||
"RzVector",
|
||||
"RzGraph",
|
||||
"HtPP",
|
||||
"RzThreadRingBuf",
|
||||
"RzThreadQueue",
|
||||
}
|
||||
skip_files = {
|
||||
"ht_inc.c",
|
||||
"ht_inc.h",
|
||||
"rz_th_ht.h",
|
||||
"rz_th.h",
|
||||
"thread_hash_table.c",
|
||||
"thread_queue.c",
|
||||
"thread_ring_buf.c",
|
||||
}
|
||||
generic_types = {"RzList", "RzListIter", "RzPVector", "RzVector", "RzGraph", "HtPP"}
|
||||
skip_files = {"ht_inc.c", "ht_inc.h", "rz_th_ht.h", "thread_hash_table.c"}
|
||||
|
||||
|
||||
def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]:
|
||||
@@ -207,22 +190,21 @@ def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]
|
||||
return comment
|
||||
|
||||
# Check pointer (or lack of) and space between pointer
|
||||
if typeref_spelling in {"RzList", "RzListIter", "RzPVector", "RzThreadQueue"}:
|
||||
if typeref_spelling in {"RzList", "RzListIter", "RzPVector"}:
|
||||
if comment[-2] != "*":
|
||||
warn(f"Type comment at {stringify_location(cursor.location)} lacks pointer")
|
||||
elif comment[-3] != " ":
|
||||
warn(
|
||||
f"Type comment at {stringify_location(cursor.location)} lacks space between pointer"
|
||||
)
|
||||
elif typeref_spelling in {"RzVector", "RzThreadRingBuf"}:
|
||||
elif typeref_spelling in {"RzVector"}:
|
||||
if comment[-2] == "*":
|
||||
warn(
|
||||
f"Type comment at {stringify_location(cursor.location)} should not have pointer"
|
||||
)
|
||||
elif typeref_spelling in {"RzGraph", "HtPP"}:
|
||||
if not re.match(
|
||||
r"<(struct |const )?[A-Za-z0-9_]+ \*, (struct |const )?[A-Za-z0-9_]+ \*>",
|
||||
comment,
|
||||
r"<(struct )?[A-Za-z0-9_]+ \*, (struct )?[A-Za-z0-9_]+ \*>", comment
|
||||
):
|
||||
if typeref_spelling == "RzGraph":
|
||||
warn(
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/bins
|
||||
@@ -1,42 +0,0 @@
|
||||
NAME=1-rz_core.py =
|
||||
FILE=--
|
||||
CMDS=<<EOF
|
||||
!echo q | python3 ../examples/1-rz_core.py =
|
||||
echo
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
Loaded 1 file(s)
|
||||
Corefile #1 has 1 binfile(s)
|
||||
* malloc://512
|
||||
rizin>
|
||||
EOF
|
||||
EXPECT_ERR=
|
||||
RUN
|
||||
|
||||
NAME=2a-rz_bin_plugin.py
|
||||
FILE=--
|
||||
CMDS=<<EOF
|
||||
!echo q | python3 ../examples/2a-rz_bin_plugin.py bins/elf/analysis/ls-linux64
|
||||
echo
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
name: bins/elf/analysis/ls-linux64
|
||||
size: 121584
|
||||
rizin>
|
||||
EOF
|
||||
EXPECT_ERR=
|
||||
RUN
|
||||
|
||||
NAME=2b-rz_bin_plugin.py
|
||||
FILE=--
|
||||
CMDS=<<EOF
|
||||
!echo q | python3 ../examples/2b-rz_bin_plugin.py bins/pe/hello_world_arm/hello_world_arm64.exe
|
||||
echo
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
name: bins/pe/hello_world_arm/hello_world_arm64.exe
|
||||
size: 8704
|
||||
rizin>
|
||||
EOF
|
||||
EXPECT_ERR=
|
||||
RUN
|
||||
@@ -0,0 +1,15 @@
|
||||
NAME=1-rz_core.py =
|
||||
FILE=--
|
||||
CMDS=<<EOF
|
||||
!echo q | python3 examples/1-rz_core.py =
|
||||
echo
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
Loaded 1 file(s)
|
||||
Corefile #1 has 1 binfile(s)
|
||||
* malloc://512
|
||||
rizin>
|
||||
EOF
|
||||
EXPECT_ERR=<<EOF
|
||||
EOF
|
||||
RUN
|
||||
Reference in new issue
Block a user