* fix make clean in r2-bindings

* bump configure.acr
* automatize update of node_modules with make
* deprecate nodejs/ (as requested by eddyb)
This commit is contained in:
pancake 2012-06-21 18:13:41 +02:00
parent fb315d5079
commit e095383371
10 changed files with 72 additions and 283 deletions

View File

@ -225,8 +225,10 @@ oldtest:
clean:
@for a in $(LANGS); do \
if [ -d $$a ]; then \
echo "Cleaning $$a " ; \
cd $$a ; ${MAKE} clean ; cd .. ; \
( cd $$a && ${MAKE} clean ) ; \
fi ; \
done
mrproper:

View File

@ -1,2 +1,10 @@
* proper integration for gjs and nodejs
* make vapi for RRegex
* fix c++ bindings like this:
namespace Radere {
namespace Core {
class RAnalValue{
public:
RAnalValue *m_self; //No se pq li dius self, pot confondre amb el this ¿no?
};
}//ns Radare
}//ns Core

View File

@ -1,5 +1,5 @@
VERSION=@VERSION@
RELEASE=1
RELEASE=0
CC=@USERCC@
CXX=@USERCXX@

114
r2-bindings/configure vendored
View File

@ -1,5 +1,5 @@
#!/bin/sh
# This script was automatically generated by ACR v0.8.9
# This script was automatically generated by ACR v0.9.1
# @author: pancake <youterm.com>
# @url: http://www.nopcode.org
# @repo: hg clone http://hg.youterm.com/acr
@ -93,7 +93,8 @@ done
: ${INSTALL_DIR:=${INSTALL} -d}
: ${INSTALL_DATA:=${INSTALL} -m 644}
: ${INSTALL_SCRIPT:=${INSTALL} -m 755}
: ${INSTALL_PROGRAM:=${INSTALL} -m 755 -s}
: ${INSTALL_PROGRAM:=${INSTALL} -m 755}
: ${INSTALL_PROGRAM_STRIP:=${INSTALL} -m 755 -s}
: ${INSTALL_MAN:=${INSTALL} -m 444}
: ${INSTALL_LIB:=${INSTALL} -c}
PKGNAME='radare2-bindings' ; VERSION='0.9.1hg' ; CONTACT_MAIL="pancake@nopcode.org" ; CONTACT_NAME="pancake" ; CONTACT="pancake <pancake@nopcode.org>" ;
@ -139,15 +140,12 @@ System types:
--target=TARGET configure for building compilers for TARGET [HOST]
EOF2
printf "
Optional Features:
printf "\nOptional Features:
--enable-devel Enable development mode (use valabind and swig)
--with-cc Define C compiler to use (gcc by default) (USERCC=gcc)
--with-cxx Define C++ compiler to use (g++ by default) (USERCXX=g++)
--with-ostype Choose OS type (gnulinux windows darwin) (USEROSTYPE=auto)
"
printf "
Some influential environment variables:
--with-ostype Choose OS type (gnulinux windows darwin) (USEROSTYPE=auto)\n"
printf "\nSome influential environment variables:
CC C compiler command
CFLAGS C compiler flags
CPPFLAGS C preprocessor flags
@ -157,10 +155,8 @@ Some influential environment variables:
headers in a nonstandard directory <include dir>
CPP C preprocessor
CXX C++ compiler command
CXXFLAGS C++ compiler flags
"
printf "
Report bugs to: pancake <pancake@nopcode.org>"
CXXFLAGS C++ compiler flags\n"
printf "\nReport bugs to: pancake <pancake@nopcode.org>"
echo ""
exit 0
}
@ -175,7 +171,7 @@ take_environ() {
}
show_version() {
echo "radare2-bindings-0.9.1hg configuration script done with acr v0.8.9.
echo "radare2-bindings-0.9.1hg configuration script done with acr v0.9.1.
The 'Free Software Foundation' message is only for autodetection.
Originally written by pancake <youterm.com>."
exit 0
@ -265,7 +261,7 @@ parse_options $1
shift
done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C CXX CXXFLAGS HAVE_LANG_CXX HAVE_VALABIND VALABIND HAVE_SWIG SWIG HAVE_GIRCOMPILER GIRCOMPILER DEVEL_MODE USERCC USERCXX USEROSTYPE FOO HAVE_PKGCFG_R_CORE"
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C CXX CXXFLAGS HAVE_LANG_CXX HAVE_VALABIND VALABIND HAVE_SWIG SWIG HAVE_GIRCOMPILER GIRCOMPILER DEVEL_MODE USERCC USERCXX USEROSTYPE FOO HAVE_PKGCFG_R_CORE"
create_environ
@ -316,64 +312,64 @@ exit 1
fi
printf "checking for valabind... "
if [ -x "${VALABIND}" ]; then
FIND=${VALABIND}
FIND=${VALABIND}
else
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/valabind" ]; then
FIND="${A}/valabind"
break;
fi
done
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/valabind" ]; then
FIND="${A}/valabind"
break;
fi
done
fi
if [ -n "${FIND}" ]; then
echo ${FIND};
HAVE_VALABIND=1
VALABIND=${FIND}
echo ${FIND};
HAVE_VALABIND=1
VALABIND=${FIND}
else
HAVE_VALABIND=0
VALABIND=valabind
echo no ; fi
HAVE_VALABIND=0
VALABIND=valabind
echo no ; fi
printf "checking for swig... "
if [ -x "${SWIG}" ]; then
FIND=${SWIG}
FIND=${SWIG}
else
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/swig" ]; then
FIND="${A}/swig"
break;
fi
done
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/swig" ]; then
FIND="${A}/swig"
break;
fi
done
fi
if [ -n "${FIND}" ]; then
echo ${FIND};
HAVE_SWIG=1
SWIG=${FIND}
echo ${FIND};
HAVE_SWIG=1
SWIG=${FIND}
else
HAVE_SWIG=0
SWIG=swig
echo no ; fi
HAVE_SWIG=0
SWIG=swig
echo no ; fi
printf "checking for g-ir-compiler... "
if [ -x "${GIRCOMPILER}" ]; then
FIND=${GIRCOMPILER}
FIND=${GIRCOMPILER}
else
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/g-ir-compiler" ]; then
FIND="${A}/g-ir-compiler"
break;
fi
done
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/g-ir-compiler" ]; then
FIND="${A}/g-ir-compiler"
break;
fi
done
fi
if [ -n "${FIND}" ]; then
echo ${FIND};
HAVE_GIRCOMPILER=1
GIRCOMPILER=${FIND}
echo ${FIND};
HAVE_GIRCOMPILER=1
GIRCOMPILER=${FIND}
else
HAVE_GIRCOMPILER=0
GIRCOMPILER=g-ir-compiler
echo no ; fi
HAVE_GIRCOMPILER=0
GIRCOMPILER=g-ir-compiler
echo no ; fi
if [ "$USEROSTYPE" = "auto" ]; then
if [ "$HOST_OS" = "linux" ]; then
USEROSTYPE="gnulinux"
@ -391,13 +387,13 @@ if [ "$HOST_OS" = "darwin" ]; then
USEROSTYPE="darwin"; fi; fi; fi; fi; fi; fi
printf 'checking pkg-config flags for r_core... '
tmp=`pkg-config --cflags r_core 2>/dev/null`
if [ $? = 1 ]; then echo no ; HAVE_PKGCFG_R_CORE=0;
if [ '!' $? = 0 ]; then echo no ; HAVE_PKGCFG_R_CORE=0;
echo 'This package is required'
exit 1
else
FOO=$tmp;
tmp=`pkg-config --libs r_core 2>/dev/null`
if [ ! $? = 1 ]; then
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_R_CORE=1;
FOO=$tmp; fi; fi
SEDFLAGS=" -e '"
@ -440,7 +436,7 @@ if [ -n "`grep \"${MARK}\" ${SD_TARGET}.tmp`" ]; then
fi
done
mv ${SD_TARGET}.tmp ${SD_TARGET} && rm -f ${SD_TARGET}.tmp2
if [ $? = 1 ]; then echo Cannot write target file ; control_c ; fi
if [ ! $? = 0 ]; then echo Cannot write target file ; control_c ; fi
done
do_remove

View File

@ -4,11 +4,12 @@ LIBS_PFX=
FORCE_SOEXT=1
SAVED=test.js test2.js test3.js
.PHONY: bar all
bar: node_modules all
include ../rules.mk
# install deps
deps:
node_modules:
npm install
npm:

View File

@ -1,67 +0,0 @@
var FFI = require ("node-ffi");
var RAsmCode = FFI.Struct([
['int32', 'len']
, ['pointer', 'buf']
, ['string', 'buf_hex']
, ['string', 'buf_asm']
]);
var r = new FFI.Library ("libr_asm", {
"r_asm_new": [ "pointer", []]
, "r_asm_set_pc": ["int32", ["pointer","uint64"]]
, "r_asm_set_syntax": ["int32", ["pointer","int32"]]
, "r_asm_setup": ["int32", ["pointer","string","int32","int32"]]
, "r_asm_massemble": ["pointer", ["pointer","string"]]
, "r_asm_mdisassemble_hexstr": ["pointer", ["pointer","string"]]
});
var ra = new FFI.Library ("libr_asm", {
"r_asm_new": [ "pointer", []]
, "r_asm_set_pc": ["int32", ["pointer","uint64"]]
, "r_asm_set_syntax": ["int32", ["pointer","int32"]]
, "r_asm_setup": ["int32", ["pointer","string","int32","int32"]]
, "r_asm_massemble": ["pointer", ["pointer","string"], {"async": true}]
, "r_asm_mdisassemble_hexstr": ["pointer", ["pointer","string"], {"async": true}]
});
var async = true;
function RAsm() {
this.setup = function(use, bits, big_endian) {
return r.r_asm_setup (this.o, use, bits, big_endian);
}
if (async) {
this.o = ra.r_asm_new ();
this.asm = function(x, y) {
ra.r_asm_massemble (this.o, x)
.on ("success", function (ret) {
y (new RAsmCode (ret));
});
}
this.dasm = function(x) {
return new RAsmCode (r.r_asm_mdisassemble_hexstr(this.o, x));
}
} else {
this.o = r.r_asm_new ();
this.asm = function(x,y) {
return new RAsmCode (r.r_asm_massemble(this.o, x,y));
}
this.dasm = function(x,y) {
return new RAsmCode (r.r_asm_mdisassemble_hexstr(this.o, x,y));
}
}
this.set_pc = function(x) {
return r.r_asm_set_pc(this.o, x);
}
this.set_syntax = function(x) {
return r.r_asm_set_syntax(this.o, x);
}
this.Syntax = {
NONE : 0,
INTEL: 1,
ATT: 2
}
}
exports.RAsm = RAsm;

View File

@ -1,36 +0,0 @@
#!/usr/bin/env node
/* Hello World using nodejs-ffi bindings for r2's r_asm api */
var r = require ("./r_asm");
var a = new r.RAsm ();
a.setup ("x86", 32, false);
a.asm ("nop;mov eax,33", function(x) {
var c = new RAsmCode (x);
console.log ("done" + c.buf_hex);
});
console.log ("continue");
setTimeout(function() {
console.log("pepep");
}, 30);
var FFI = require ("node-ffi");
var libc = new FFI.Library("libc", {
"sleep": ["int32", ["int32"]]
});
libc.sleep (3);
process.exit (0);
console.log (a.asm ("nop;mov eax,33").buf_hex);
a.setup ("x86", 64, false);
console.log (a.asm ("nop;mov rax,33").buf_hex);
a.set_pc (33);
a.set_syntax (a.Syntax.ATT);
console.log (a.dasm ("9048c7c02100000090cd329090").buf_asm);
var r = 33;

View File

@ -1,75 +0,0 @@
var FFI = require("node-ffi");
var a = new FFI.Library ("libr_asm", {
"r_asm_new": [ "pointer" , []]
, "r_asm_free": [ "void" , ["pointer"]]
, "r_asm_use": [ "int" , [ "pointer", "string"]]
, "r_asm_set_bits": [ "int" , [ "pointer", "int"]]
, "r_asm_set_pc": [ "int" , [ "pointer", "uint64"]]
, "r_asm_mdisassemble_hexstr": [ "pointer", ["pointer", "string"] ]
, "r_asm_massemble": [ "pointer", ["pointer", "string"] ]
, "r_asm_assemble_file": [ "pointer", ["pointer", "string"] ]
, "r_asm_filter_input": [ "int", ["pointer", "string"] ]
, "r_asm_filter_output": [ "int", ["pointer", "string"] ]
});
var RAsmCode = FFI.Struct ([
['int32', 'len']
, ['string', 'buf']
, ['string', 'buf_hex']
, ['string', 'buf_asm']
, ['pointer', 'foo']
, ['int64', 'bar']
, ['int64', 'cow']
]);
// XXX wrong name?
var RAsm = FFI.Struct ([
['int', 'bits']
, ['int', 'big_endian']
, ['int', 'syntax']
// ...
])
/* libm
var FFI = require("node-ffi");
var libm = new FFI.Library("libm", { "ceil": [ "double", [ "double" ] ] });
libm.ceil(1.5); // 2
*/
var r2 = {
RAsm : function() {
/* lifecycle */
var p = a.r_asm_new ();
this.delete = function (x) {
a.r_asm_free (p);
}
/* methods */
this.use = function(x) {
return a.r_asm_use (p, x);
}
this.set_pc = function (x) {
return a.r_asm_set_pc (p, x);
}
this.set_bits = function (x) {
return a.r_asm_set_bits (p, x);
}
this.filter_input = function (x) {
return a.r_asm_filter_input (p, x);
}
this.filter_output = function (x) {
return a.r_asm_filter_output (p, x);
}
this.mdisassemble_hexstr = function (x) {
return new RAsmCode (a.r_asm_mdisassemble_hexstr (p, x));
}
this.massemble = function (x) {
return new RAsmCode (a.r_asm_massemble (p, x));
}
this.assemble_file = function (x) {
return new RAsmCode (a.r_asm_assemble_file (p, x));
}
}
}
module.exports = r2;

View File

@ -1,12 +0,0 @@
var FFI = require("node-ffi");
/* Example using r_util api */
var libr_util = new FFI.Library ("/usr/lib/libr_util", {
"r_str_rwx": [ "int" , ["string"]]
});
/*
var o = libr_util.r_str_rwx("rw");
console.log ("rw = "+o);
*/

View File

@ -1,28 +0,0 @@
const r2 = require ("r2/r_asm");
const print = console.log;
/* using the api */
function Assembler (arch, bits) {
var o = new r2.RAsm ();
o.use (arch);
o.set_bits (bits);
this.delete = function () {
o.delete ();
}
this.assemble = function (x) {
var ac = o.massemble (x);
return ac.buf_hex;
}
this.disassemble = function (x) {
var ac = o.mdisassemble_hexstr (x);
return ac.buf_asm;
}
}
var asm = new Assembler ("x86", 32);
print (asm.assemble ("int 0x80;mov eax,33;ret"));
print (asm.disassemble ("909090"));
asm.delete ();
process.exit (0);