Skip to content

Commit

Permalink
Initial support for meson builds
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Apr 16, 2024
1 parent c2b4b2a commit 29ef558
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
sudo dpkg -i "radare2-dev_${R2V}_amd64.deb"
- name: Installing yara via r2pm
run: r2pm -Ui yara
- name: Building with meson
run: |
sudo apt install meson
r2pm -ci ninja
r2pm -r meson b
r2pm -r ninja -C b
- name: Building r2yara
run: |
r2pm -r ./configure
Expand All @@ -46,8 +52,10 @@ jobs:
sys/install.sh
- name: Installing yara and r2yara via r2pm
run: r2pm -Uci r2yara
- name: Testing r2yara installation
run: R2_DEBUG=1 r2 -qcq -c 'yrv' --
- name: Running Testsuite
run: make -C test
run: r2pm -r make -C test
build-macos:
runs-on: macos-11
# runs-on: macos-12 # maybe this version have aclocal
Expand Down
2 changes: 1 addition & 1 deletion dist/debian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ all: root
root:
cd ../.. && $(MAKE) clean ; ./configure --prefix=/usr $(R2CFG_FLAGS) ; make
mkdir -p root/$(R2PLUGDIR)
cp -f ../../src/core_yara.so root/$(R2PLUGDIR)
cp -f ../../src/core_r2yara.so root/$(R2PLUGDIR)

purge: clean
rm -rf root
Expand Down
69 changes: 69 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
project(
'r2yara',
['c'],
license : 'LGPL3',
meson_version : '>=0.50.1',
version : '1.2.0'
)

r2yara_sources = [
'src/core_r2yara.c',
]

incdirs = [
'src',
]

res = run_command(['radare2','-HR2_LIBR_PLUGINS'], capture:true, check:false)
if res.returncode() == 0
r2_plugdir = res.stdout().strip()
else
prefix = get_option('prefix')
r2_plugdir = prefix + '/lib/radare2/plugins'
endif

add_global_arguments('-DR2Y_VERSION="1.1.2"', language:'c')
c = meson.get_compiler('c')
if c.get_id() == 'msvc'
incdirs += [
'radare2/include/libr',
'radare2/include/libr/sdb',
]
add_global_arguments('-D_WINDOWS', language:'c')
r2libdir = [
meson.current_source_dir() + '\\radare2\\lib',
'C:\\radare2\\lib'
]
r_core = [
c.find_library('r_core', dirs: r2libdir),
c.find_library('r_io', dirs: r2libdir),
c.find_library('r_bin', dirs: r2libdir),
c.find_library('r_cons', dirs: r2libdir),
c.find_library('r_asm', dirs: r2libdir),
c.find_library('r_esil', dirs: r2libdir),
c.find_library('r_arch', dirs: r2libdir),
c.find_library('r_flag', dirs: r2libdir),
c.find_library('r_reg', dirs: r2libdir),
c.find_library('r_util', dirs: r2libdir),
c.find_library('r_anal', dirs: r2libdir),
c.find_library('r_config', dirs: r2libdir),
]
else
r_core = dependency('r_core')
endif
libyara = dependency('yara')

r2yara_incdirs = include_directories(incdirs)

r2yara_core_sources = [
r2yara_sources,
'src/core_r2yara.c'
]

r2yara_core_plugin = library('core_r2yara',
r2yara_core_sources,
dependencies: [r_core, libyara],
include_directories: r2yara_incdirs,
install: true,
install_dir: r2_plugdir
)
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include ../config.mk

CFLAGS+=-g

MOD=core_yara
MOD=core_r2yara
MKDIR=mkdir -p
RULESDIR=rules-yara3

Expand Down
2 changes: 0 additions & 2 deletions src/core_yara.c → src/core_r2yara.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <r_core.h>
#include <yara.h>
#include "config.h"

#if R2_VERSION_NUMBER < 50809
static inline char *r_str_after(char *s, char c) {
Expand Down Expand Up @@ -34,7 +33,6 @@ static int cmd_yara_add_file(const char* rules_path);
static int cmd_yara_call(void *user, const char *input);
static int cmd_yara_clear();
static int cmd_yara_init(void *user, const char *cmd);
static int cmd_yara_help(const RCore* core);
static int cmd_yara_process(const RCore* core, const char* input);
static int cmd_yara_scan(const RCore* core, const char* option);
static int cmd_yara_load_default_rules(const RCore* core);
Expand Down
1 change: 1 addition & 0 deletions test/db/extras/yara
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN

NAME=yara scan
FILE=bins/elf/vim
ARGS=-n
CMDS=<<EOF
yr-
yr ../rules/crypto.yara
Expand Down

0 comments on commit 29ef558

Please sign in to comment.