Initial work supporting emscripten compilation
This commit is contained in:
parent
da5bf8db45
commit
7855f4952f
|
@ -0,0 +1,101 @@
|
|||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=false" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>rax2</title>
|
||||
<style>
|
||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
||||
textarea.emscripten { font-family: monospace; width: 90%; height:320px; background-color:black; color:white; }
|
||||
div.emscripten { text-align: center; }
|
||||
div.emscripten_border { border: 1px solid black; }
|
||||
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
|
||||
canvas.emscripten { border: 0px none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<center>
|
||||
<script>
|
||||
function doin () {
|
||||
var input=document.getElementById('input');
|
||||
if (false) {
|
||||
window.location.href = "#"+input.value;
|
||||
location.reload();
|
||||
} else {
|
||||
Module.arguments = input.value.split (' ');
|
||||
Module.run();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<a href="http://www.radare.org/" target="_blank">rax2</a>
|
||||
<input type=text id="input">
|
||||
<input type=submit onclick="doin()">
|
||||
</center>
|
||||
<hr>
|
||||
<textarea readonly class="emscripten" id="output" rows="8"></textarea>
|
||||
<hr>
|
||||
<div class="emscripten" id="status">Downloading...</div>
|
||||
<div class="emscripten">
|
||||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
||||
</div>
|
||||
<script type='text/javascript'>
|
||||
// connect to canvas
|
||||
var Module = {
|
||||
arguments: document.location.hash.substring(1).split(' '),
|
||||
noExitRuntime: true,
|
||||
preRun: [],
|
||||
postRun: [],
|
||||
print: (function() {
|
||||
var element = document.getElementById('output');
|
||||
element.value = ''; // clear browser cache
|
||||
return function(text) {
|
||||
text = Array.prototype.slice.call(arguments).join(' ');
|
||||
// These replacements are necessary if you render to raw HTML
|
||||
//text = text.replace(/&/g, "&");
|
||||
//text = text.replace(/</g, "<");
|
||||
//text = text.replace(/>/g, ">");
|
||||
//text = text.replace('\n', '<br>', 'g');
|
||||
element.value += text + "\n";
|
||||
element.scrollTop = 99999; // focus on bottom
|
||||
};
|
||||
})(),
|
||||
printErr: function(text) {
|
||||
text = Array.prototype.slice.call(arguments).join(' ');
|
||||
if (0) { // XXX disabled for safety typeof dump == 'function') {
|
||||
dump(text + '\n'); // fast, straight to the real console
|
||||
} else {
|
||||
console.log(text);
|
||||
}
|
||||
},
|
||||
//canvas: document.getElementById('canvas'),
|
||||
setStatus: function(text) {
|
||||
if (Module.setStatus.interval) clearInterval(Module.setStatus.interval);
|
||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
||||
var statusElement = document.getElementById('status');
|
||||
var progressElement = document.getElementById('progress');
|
||||
if (m) {
|
||||
text = m[1];
|
||||
progressElement.value = parseInt(m[2])*100;
|
||||
progressElement.max = parseInt(m[4])*100;
|
||||
progressElement.hidden = false;
|
||||
} else {
|
||||
progressElement.value = null;
|
||||
progressElement.max = null;
|
||||
progressElement.hidden = true;
|
||||
}
|
||||
statusElement.innerHTML = text;
|
||||
},
|
||||
totalDependencies: 0,
|
||||
monitorRunDependencies: function(left) {
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
||||
}
|
||||
};
|
||||
Module.setStatus('Downloading...');
|
||||
</script>
|
||||
<script type='text/javascript' src="rax2.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -6,6 +6,9 @@ CFLAGS+=-DR2_BIRTH=\"`date +%Y-%m-%d`\"
|
|||
CFLAGS+=-DR2_GITTIP=\"$(GIT_TIP)\"
|
||||
CFLAGS+=-DR2_GITTAP=\"$(GIT_TAP)\"
|
||||
|
||||
ifeq (${COMPILER},emscripten)
|
||||
EXT_EXE=.js
|
||||
endif
|
||||
|
||||
ifeq ($(USE_RPATH),1)
|
||||
LDFLAGS+=-Wl,-R${PREFIX}/lib
|
||||
|
|
|
@ -1,15 +1,34 @@
|
|||
Building for the browser
|
||||
========================
|
||||
|
||||
$ git clone git://github.com/kripken/emscripten.git
|
||||
$ export PATH=/path/to/emscripten:$PATH
|
||||
# Install emscripten:
|
||||
|
||||
git clone git://github.com/kripken/emscripten.git
|
||||
export PATH=/path/to/emscripten:$PATH
|
||||
make clean
|
||||
|
||||
|
||||
# Build radare
|
||||
|
||||
export CC="emcc --ignore-dynamic-linking"
|
||||
./configure --prefix=/usr --disable-shared --enable-static --disable-debugger --with-compiler=emscripten --without-ewf --without-pic --with-nonpic --without-gmp
|
||||
make -j4
|
||||
|
||||
|
||||
|
||||
--- random notes ---
|
||||
|
||||
$ ./configure --without-ewf --without-gmp --with-nonpic --without-pic
|
||||
$ emmake make
|
||||
|
||||
cd binr/radare2
|
||||
emcc ../../libr/*/*.o radare2.c -I ../../libr/include/ -DR2_BIRTH=\"pop\" -DR2_GITTIP=\"123\" ../../libr/db/sdb/src/*.o
|
||||
|
||||
make clean
|
||||
export CC="emcc --ignore-dynamic-linking"
|
||||
./configure --prefix=/usr --disable-shared --enable-static --disable-debugger
|
||||
make
|
||||
|
||||
binr/rax2/rax2.js:
|
||||
|
||||
emcc -O2 rax2.o ../../libr/util/libr_util.a -o rax2.js
|
||||
|
||||
binr/rasm2/rasm2.js:
|
||||
|
||||
emcc -O2 -L.. -o rasm2.js ../../shlr/sdb/src/libsdb.a ../../libr/fs/p/grub/libgrubfs.a -lm $A/util/libr_util.a $A/asm/libr_asm.a rasm2.o ../../libr/util/libr_util.a ../../libr/parse/libr_parse.a ../../libr/db/libr_db.a ../../libr/syscall/libr_syscall.a ../../libr/asm/libr_asm.a ../../libr/lib/libr_lib.a ../../libr/db/libr_db.a ../../shlr/sdb/src/libsdb.a ../../libr/util/libr_util.a
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
include ../global.mk
|
||||
include config.mk
|
||||
include ../mk/${COMPILER}.mk
|
||||
|
||||
PREFIX?=${PWD}/../prefix
|
||||
PFX=${DESTDIR}/${PREFIX}
|
||||
|
@ -41,7 +42,7 @@ libr.a: $(shell ls */libr_*.a 2>/dev/null)
|
|||
for a in */libr_*.a ; do echo ADDLIB $$a >> libr.m ; done
|
||||
echo SAVE >> libr.m
|
||||
# ar -M is a gnu-ism .. try to find a proper portable way to do that
|
||||
${AR} -M < libr.m
|
||||
${CC_AR} -M < libr.m
|
||||
rm -f libr.m
|
||||
|
||||
$(LIBS):
|
||||
|
|
|
@ -100,6 +100,7 @@ static void cmd_debug_pid(RCore *core, const char *input) {
|
|||
int pid, sig;
|
||||
switch (input[1]) {
|
||||
case 'k':
|
||||
/* stop, print, pass -- just use flags*/
|
||||
/* XXX: not for threads? signal is for a whole process!! */
|
||||
/* XXX: but we want fine-grained access to process resources */
|
||||
pid = atoi (input+2);
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#if DEBUGGER
|
||||
|
||||
#if __UNIX__
|
||||
#include <errno.h>
|
||||
#include <sys/ptrace.h>
|
||||
|
@ -15,7 +18,6 @@
|
|||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#if DEBUGGER
|
||||
static int r_debug_native_continue(RDebug *dbg, int pid, int tid, int sig);
|
||||
static int r_debug_native_reg_read(RDebug *dbg, int type, ut8 *buf, int size);
|
||||
static int r_debug_native_reg_write(RDebug *dbg, int type, const ut8* buf, int size);
|
||||
|
|
|
@ -2,6 +2,7 @@ ifeq ($(_INCLUDE_RULES_MK_),)
|
|||
_INCLUDE_RULES_MK_=
|
||||
|
||||
-include $(LTOP)/config.mk
|
||||
-include $(LTOP)/../mk/compiler.mk
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
export NOSTRIP=1
|
||||
|
|
|
@ -40,7 +40,7 @@ R_API int r_cache_set(RCache *c, ut64 addr, const ut8 *buf, int len) {
|
|||
if (addr < c->base) {
|
||||
ut8 *b;
|
||||
int baselen = (c->base - addr);
|
||||
int newlen = baselen + (len > c->len)? len: c->base;
|
||||
int newlen = baselen + ((len > c->len)? len: c->base);
|
||||
// XXX expensive heap usage. must simplify
|
||||
b = malloc (newlen);
|
||||
if (!b) return 0;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
ifeq (${_INCLUDE_MK_GCC_},)
|
||||
_INCLUDE_MK_GCC_=1
|
||||
EXT_EXE=.js
|
||||
CC=emcc
|
||||
AR=emar
|
||||
LINK=
|
||||
RANLIB=emranlib
|
||||
ONELIB=0
|
||||
CC_AR=emar q ${LIBAR}
|
||||
PIC_CFLAGS=-fPIC
|
||||
CFLAGS+=-MD
|
||||
CFLAGS_INCLUDE=-I
|
||||
LDFLAGS_LINK=-l
|
||||
LDFLAGS_LINKPATH=-L
|
||||
CFLAGS_OPT0=-O0
|
||||
CFLAGS_OPT1=-O1
|
||||
CFLAGS_OPT2=-O2
|
||||
CFLAGS_OPT3=-O3
|
||||
CFLAGS_DEBUG=-g
|
||||
|
||||
ifeq ($(OSTYPE),auto)
|
||||
OSTYPE=$(shell uname | tr 'A-Z' 'a-z')
|
||||
endif
|
||||
LDFLAGS_LIB=-shared
|
||||
LDFLAGS_SONAME=-Wl,-soname=
|
||||
|
||||
CC_LIB=${CC} ${LDFLAGS_LIB} -o ${LIBSO}
|
||||
endif
|
|
@ -20,15 +20,17 @@ clean mrproper:
|
|||
|
||||
$(SDBLIB) sdb/sdb:
|
||||
cd sdb ; ${MAKE} src/sdb-version.h
|
||||
cd sdb ; ${MAKE} clean
|
||||
cd sdb ; \
|
||||
${MAKE} clean && \
|
||||
${MAKE} CC=${HOST_CC} && \
|
||||
cp -f src/sdb sdb
|
||||
cp -f src/sdb src/.sdb
|
||||
cd sdb ; ${MAKE} clean
|
||||
cd sdb ; ${MAKE} src/sdb-version.h
|
||||
cd sdb/src ; ${MAKE} ARCH=xxx RANLIB="${RANLIB}" CFLAGS_SHARED=-fPIC \
|
||||
CC="${CC}" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" libsdb.a
|
||||
CC="${CC}" AR="${AR}" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" libsdb.a
|
||||
${RANLIB} sdb/src/libsdb.a
|
||||
cp -f sdb/src/.sdb sdb/sdb
|
||||
|
||||
|
||||
.PHONY: sdb-sync sync-sdb sdbclean
|
||||
|
|
|
@ -28,7 +28,7 @@ ifneq ($(SILENT),)
|
|||
@echo AR libsdb.a
|
||||
endif
|
||||
rm -f libsdb.a
|
||||
${AR} -r libsdb.a ${OBJ}
|
||||
${AR} q libsdb.a ${OBJ}
|
||||
${RANLIB} libsdb.a
|
||||
|
||||
libsdb.${SOVER}: ${SOBJ}
|
||||
|
|
Loading…
Reference in New Issue