radare2/r2-bindings
2013-09-27 21:10:09 +02:00
..
awk Minor r2awk fixes 2012-11-05 14:52:32 +01:00
ctypes ctypes bindings no longer need __init_methods__() hack 2013-09-27 21:10:09 +02:00
cxx Lot of build fixes for --as-needed and mingw32 2012-08-10 11:35:38 +02:00
dlang Initial support for D language bindings 2013-06-28 09:31:11 +02:00
gir Made r2-bindings work again (though, not tested) with valabind. 2012-06-29 17:35:44 +03:00
go * Add missing goenv.sh 2011-08-21 14:34:07 +02:00
guile * More work for the bindings 2011-11-04 03:48:28 +01:00
java Added Java JNI install support 2013-07-17 00:07:34 +02:00
lua Many enhacements for the lua bindings 2013-06-25 02:45:12 +02:00
luvit * Add initial luvit bindings for testing (sync) 2012-03-13 18:45:19 +01:00
newlisp * Enhacements for rarun2 2011-10-24 04:35:42 +02:00
node-ffi Fix double free when loading malformed PE file 2013-07-03 11:57:37 +02:00
perl * Rename swig/ to r2-bindings 2011-05-18 01:35:52 +02:00
php5 Made r2-bindings work again (though, not tested) with valabind. 2012-06-29 17:35:44 +03:00
python Add test-r_dehug example and minor bindings update 2013-09-27 01:38:49 +02:00
ruby * Rename swig/ to r2-bindings 2011-05-18 01:35:52 +02:00
vapi Add test-r_dehug example and minor bindings update 2013-09-27 01:38:49 +02:00
autogen.sh * Rename swig/ to r2-bindings 2011-05-18 01:35:52 +02:00
check-langs.sh Fix x86-16 disasm issue and add ctypes (wip) 2012-11-15 15:37:25 +01:00
config.mk.acr Completely remove DEVEL_MODE from r2-bindings 2013-09-21 10:58:26 +02:00
configure Completely remove DEVEL_MODE from r2-bindings 2013-09-21 10:58:26 +02:00
configure-langs * More fixes for the r2-bindings configure 2012-06-13 18:15:28 +02:00
configure.acr Completely remove DEVEL_MODE from r2-bindings 2013-09-21 10:58:26 +02:00
configure.hook Fix lua bindings build 2013-07-16 08:20:58 +02:00
do-swig.sh Added Java JNI install support 2013-07-17 00:07:34 +02:00
do-test.sh * Rename swig/ to r2-bindings 2011-05-18 01:35:52 +02:00
getostype.sh * Fix pkg-config-symstall 2011-05-20 19:49:50 +02:00
libs.mk * More work for the bindings 2011-11-04 03:48:28 +01:00
Makefile Fix #171 autodetect script by extension, Initial work on 'ts' 2013-08-17 19:53:04 +02:00
mp.py * Fix bindings 2011-12-05 01:09:15 +01:00
python-config-wrapper Try to fix #168 rlang's python plugin not properly linked 2013-08-18 01:30:03 +02:00
python-wrapper * Add 'python-wrapper' to use python2 in install-python target 2012-06-26 15:21:48 +02:00
README.md Add 16bit dithering for 256/16M rgb console + fixes 2013-07-17 22:12:14 +02:00
rules.mk More work on ctypes+rcore 2013-09-24 23:03:39 +02:00
TODO * fix make clean in r2-bindings 2012-06-21 18:13:41 +02:00

=============== = = = R2-Bindings = Language bindings for r2 api = = =============== --pancake

Description

This directory contains the code necessary to use the r2 api from your favourite language.

It supports a large list of programming languages:

  • Vala, Genie, Java, Go, Python, Ruby, Perl, LUA, NewLisp, Guile

And some other experimental bindings are for:

  • GIR, C++

This package also contains the vdoc/ subdirectory which contains the rules used to generate all interactive html documentation found at:

http://radare.org/vdoc

Dependencies

To build r2-bindings from repository you need the following programs installed:

  • swig: enables support for python, perl, lua, java and many other
  • vala: if you want to have Vala or Genie bindings
  • valabind: required only in developer mode (not release tarball)

Release tarballs come with all the pregenerated .cxx files, so you have no extra dependencies apart from the language libraries and C++ compiler.

To get install all dependencies do the following steps in order:

  • Install swig and mercurial from repository (ensure you don't have vala installed from package)

    arch$ sudo pacman -S swig mercurial git deb$ sudo apt-get install swig mercurial

  • Install latest release of Vala from tarball

    http://live.gnome.org/Vala

    ./configure --prefix=/usr make sudo make install

  • Clone vala compiler from git repository:

    $ git clone git://git.gnome.org/vala $ cd vala $ sh autogen.sh --prefix=/usr $ make $ sudo make install

  • Fetch valabind from the repository:

    $ hg clone http://hg.youterm.com/valabind $ cd valabind $ make $ sudo make install PREFIX=/usr

To keep bindings up-to-date

When changes are done in libr an ABI break can occur. The bindings will require to be recompiled to work again.

It's recommendable to keep your system always up to date, and upgrade vala and valabind from git/hg.

$ cd vala $ git pull $ make $ sudo make install

$ cd ../valabind $ hg pull -u $ make $ sudo make install PREFIX=/usr

r2-bindings

If you compile from the repo you need the latest version of valabind and then:

./configure --prefix=/usr

You can select the languages you want to compile with --enable={list-of-langs}

./configure --prefix=/usr --enable=python

PYTHON

To select the version of python to compile for use the PYTHON_CONFIG environment variable as follows:

$ ./configure --prefix=/usr --enable-devel $ cd python $ PYTHON_CONFIG=python2.7-config make $ su -

PYTHON_CONFIG=python2.7-config make install

RANDOM NOTES

The valabind integration forces us to do some changes in the r2 API.

These api changes are for:

  • Avoid keywords in function names

    Every language has its own keywords, r2api should try to workaround all those keywords to avoid collisions for bindings.

    Example: use, del, from, continue, etc..

    TODO: we need to review APIs, find better names for functions using those keywords, etc..

  • Review basic data structures

    Linked lists, hash tables, r_db, arrays, ... must be reviewed to fit with vala and swig basics to be able to use them with simple APIs or integrate them with the syntax sugar of the target language.

    Example: foreach (var foo in binls.get_symbols ()) { print ("%s 0x%08"PFMT64x"\n", foo.name, foo.offset); }

  • Unit testing

    Having bindings for python, perl, ruby, .. is good for unit testing because it hardly simplifies the way to test APIs, find bugs, ...

    TODO: write unit testing frameworks for perl, ruby, python, etc..

  • API unification for all languages

    All the previous development points are meant to reduce code in r2, avoid syntax exceptions, simplify api usage, and much moar ;)

SWIG is not complete, there are still so many bugs to fix and so many unimplemented stuff. Here's a list of the most anoying things of it:

  • unsigned char * : not implemented