mirror of
https://github.com/radareorg/r2unity.git
synced 2026-11-07 06:36:00 -10:00
Add meson build
This commit is contained in:
1 parent
f481401bb9
commit
de6abe347a
5 files changed
+131
-1
No files matched your search
@@ -32,6 +32,35 @@ jobs:
|
||||
- name: Build plugin
|
||||
run: make plugin
|
||||
|
||||
meson:
|
||||
name: Meson (${{ matrix.os }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-24.04, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install Meson
|
||||
run: |
|
||||
python3 -m pip install --user meson ninja
|
||||
echo "$(python3 -m site --user-base)/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Install radare2
|
||||
id: r2
|
||||
uses: radareorg/github-actions@v1
|
||||
|
||||
- name: Configure
|
||||
run: meson setup build
|
||||
|
||||
- name: Build
|
||||
run: meson compile -C build
|
||||
|
||||
- name: Test
|
||||
run: meson test -C build --print-errorlogs
|
||||
|
||||
debian:
|
||||
name: Build Debian package
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
+2
-1
@@ -4,6 +4,8 @@
|
||||
# Build artifacts
|
||||
*.o
|
||||
/r2unity
|
||||
/build/
|
||||
/builddir/
|
||||
/src/r2/*.dylib
|
||||
/src/r2/*.so
|
||||
/src/r2/*.dll
|
||||
@@ -19,4 +21,3 @@
|
||||
|
||||
# Third-party reference checkouts (radare2, il2cpp dumper, etc.)
|
||||
/third_party/
|
||||
|
||||
@@ -32,6 +32,14 @@ make plugin
|
||||
make user-install
|
||||
```
|
||||
|
||||
Or with Meson:
|
||||
|
||||
```sh
|
||||
meson setup build
|
||||
meson compile -C build
|
||||
meson install -C build
|
||||
```
|
||||
|
||||
Most users can install it through r2pm:
|
||||
|
||||
```sh
|
||||
@@ -40,6 +48,9 @@ r2pm -ci r2unity
|
||||
|
||||
`make` builds the CLI. `make plugin` builds `core_r2unity` and `bin_r2unity`.
|
||||
`make user-install` installs both the CLI and plugins for the current user.
|
||||
Meson builds the CLI by default, matching `make`. Use `-Dplugins=enabled` to
|
||||
build the radare2 plugins too, or `-Dr2_plugindir=/path/to/plugins` to override
|
||||
the plugin install directory.
|
||||
|
||||
## CLI
|
||||
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
project(
|
||||
'r2unity',
|
||||
'c',
|
||||
version: '0.0.0',
|
||||
default_options: [
|
||||
'c_std=c99',
|
||||
'warning_level=2',
|
||||
'buildtype=debugoptimized',
|
||||
],
|
||||
)
|
||||
|
||||
r_util_dep = dependency('r_util')
|
||||
|
||||
lib_inc = include_directories('src/lib')
|
||||
lib_sources = files(
|
||||
'src/lib/elf.c',
|
||||
'src/lib/lib.c',
|
||||
'src/lib/macho.c',
|
||||
'src/lib/paths.c',
|
||||
'src/lib/pe.c',
|
||||
)
|
||||
|
||||
r2unity = executable(
|
||||
'r2unity',
|
||||
files('src/main.c') + lib_sources,
|
||||
include_directories: lib_inc,
|
||||
dependencies: r_util_dep,
|
||||
install: true,
|
||||
)
|
||||
|
||||
test('r2unity-help', r2unity, args: ['-h'])
|
||||
|
||||
plugins_opt = get_option('plugins')
|
||||
r_core_dep = dependency('r_core', required: plugins_opt)
|
||||
r_bin_dep = dependency('r_bin', required: plugins_opt)
|
||||
build_plugins = plugins_opt.enabled() or (
|
||||
plugins_opt.auto() and r_core_dep.found() and r_bin_dep.found()
|
||||
)
|
||||
|
||||
if build_plugins
|
||||
r2_plugindir = get_option('r2_plugindir')
|
||||
if r2_plugindir == ''
|
||||
r2 = find_program('r2', required: false)
|
||||
if r2.found()
|
||||
r2_user_plugins = run_command(r2, '-H', 'R2_USER_PLUGINS', check: false)
|
||||
if r2_user_plugins.returncode() == 0
|
||||
r2_plugindir = r2_user_plugins.stdout().strip()
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if r2_plugindir == ''
|
||||
r2_plugindir = join_paths(get_option('libdir'), 'radare2', 'plugins')
|
||||
warning('r2 was not found; installing plugins under ' + r2_plugindir)
|
||||
endif
|
||||
|
||||
shared_library(
|
||||
'core_r2unity',
|
||||
files('src/r2/core_r2unity.c') + lib_sources,
|
||||
include_directories: lib_inc,
|
||||
dependencies: r_core_dep,
|
||||
name_prefix: '',
|
||||
install: true,
|
||||
install_dir: r2_plugindir,
|
||||
)
|
||||
|
||||
shared_library(
|
||||
'bin_r2unity',
|
||||
files('src/r2/bin_r2unity.c') + lib_sources,
|
||||
include_directories: lib_inc,
|
||||
dependencies: r_bin_dep,
|
||||
name_prefix: '',
|
||||
install: true,
|
||||
install_dir: r2_plugindir,
|
||||
)
|
||||
endif
|
||||
@@ -0,0 +1,13 @@
|
||||
option(
|
||||
'plugins',
|
||||
type: 'feature',
|
||||
value: 'disabled',
|
||||
description: 'Build the radare2 core and bin plugins',
|
||||
)
|
||||
|
||||
option(
|
||||
'r2_plugindir',
|
||||
type: 'string',
|
||||
value: '',
|
||||
description: 'Plugin install directory; when empty, Meson uses `r2 -H R2_USER_PLUGINS` if available',
|
||||
)
|
||||
Reference in new issue
Block a user