mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
Do not compile radare2-shell-parser by default (#15769)
Last release (4.1.0) did compile it by default, but the build requires internet access to download the repositories. For now, since the feature is anyway very experimental, we disable it at compile time so that distributions can just compile their packages without internet access. In the future we may want to use submodules or augment the release tarball to include the tree-sitter and radare2-shell-parser archives.
This commit is contained in:
parent
8bcd898200
commit
46e0a8d169
24
configure
vendored
24
configure
vendored
@ -22,6 +22,7 @@ DEBUGGER=1
|
||||
USE_MAGIC=0
|
||||
CSNEXT=0
|
||||
LOADLIBS=1
|
||||
USE_TREESITTER=0
|
||||
HAVE_FORK=1
|
||||
WANT_PTRACE_WRAP=1
|
||||
WITH_LIBR=0
|
||||
@ -167,12 +168,12 @@ System types:
|
||||
--target=TARGET configure for building compilers for TARGET [HOST]
|
||||
EOF2
|
||||
|
||||
printf "
|
||||
Optional Features:
|
||||
printf "\nOptional Features:
|
||||
--disable-debugger disable native debugger features
|
||||
--with-sysmagic force to use system's magic
|
||||
--with-capstone5 build next branch of the capstone repository
|
||||
--disable-loadlibs disable loading plugins
|
||||
--with-shell-parser Compile with radare2-shell-parser experimental support
|
||||
--without-fork disable fork
|
||||
--without-ptrace-wrap disable ptrace-wrap build
|
||||
--with-libr build libr.a and libr.dylib
|
||||
@ -187,10 +188,8 @@ Optional Features:
|
||||
--with-ostype Choose OS type ( gnulinux windows darwin haiku ) (USEROSTYPE=auto)
|
||||
--with-libversion specify different libversion (LIBVERSION=xxx)
|
||||
--without-jemalloc build without jemalloc
|
||||
--with-checks-level value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL) (R_CHECKS_LEVEL=2)
|
||||
"
|
||||
printf "
|
||||
Some influential environment variables:
|
||||
--with-checks-level value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL) (R_CHECKS_LEVEL=2)\n"
|
||||
printf "\nSome influential environment variables:
|
||||
CC C compiler command
|
||||
CFLAGS C compiler flags
|
||||
CPPFLAGS C preprocessor flags
|
||||
@ -198,10 +197,8 @@ Some influential environment variables:
|
||||
nonstandard directory <lib dir>
|
||||
CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
|
||||
headers in a nonstandard directory <include dir>
|
||||
CPP C preprocessor
|
||||
"
|
||||
printf "
|
||||
Report bugs to: pancake <pancake@nopcode.org>"
|
||||
CPP C preprocessor\n"
|
||||
printf "\nReport bugs to: pancake <pancake@nopcode.org>"
|
||||
echo ""
|
||||
exit 0
|
||||
}
|
||||
@ -243,7 +240,7 @@ echo "LANGS: c"
|
||||
echo "REQUIRED: libdl"
|
||||
echo "OPTIONAL: libmagic libz libzip libxxhash libssl liblibuv>=1.0.0"
|
||||
echo "PKG-CONFIG: capstone openssl libuv"
|
||||
echo "FLAGS: --disable-debugger --with-sysmagic --with-capstone5 --disable-loadlibs --without-fork --without-ptrace-wrap --with-libr --with-syscapstone --with-syszip --with-sysxxhash --without-gpl --with-openssl --without-libuv --with-rpath --with-compiler=gcc --with-ostype=auto --with-libversion=xxx --without-jemalloc --with-checks-level=2"
|
||||
echo "FLAGS: --disable-debugger --with-sysmagic --with-capstone5 --disable-loadlibs --with-shell-parser --without-fork --without-ptrace-wrap --with-libr --with-syscapstone --with-syszip --with-sysxxhash --without-gpl --with-openssl --without-libuv --with-rpath --with-compiler=gcc --with-ostype=auto --with-libversion=xxx --without-jemalloc --with-checks-level=2"
|
||||
exit 0
|
||||
;;
|
||||
--cache-file)
|
||||
@ -293,6 +290,7 @@ echo "FLAGS: --disable-debugger --with-sysmagic --with-capstone5 --disable-l
|
||||
"--with-sysmagic") USE_MAGIC="1"; ;;
|
||||
"--with-capstone5") CSNEXT="1"; ;;
|
||||
"--disable-loadlibs") LOADLIBS="0"; ;;
|
||||
"--with-shell-parser") USE_TREESITTER="1"; ;;
|
||||
"--without-fork") HAVE_FORK="0"; ;;
|
||||
"--without-ptrace-wrap") WANT_PTRACE_WRAP="0"; ;;
|
||||
"--with-libr") WITH_LIBR="1"; ;;
|
||||
@ -325,7 +323,7 @@ parse_options "$1"
|
||||
shift
|
||||
done
|
||||
|
||||
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR DOCDIR 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 DEBUGGER HAVE_LIB_DL DL_LIBS HAVE_PATCH PATCH HAVE_GIT GIT HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC CSNEXT LOADLIBS HAVE_FORK WANT_PTRACE_WRAP WITH_LIBR WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL"
|
||||
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR DOCDIR 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 DEBUGGER HAVE_LIB_DL DL_LIBS HAVE_PATCH PATCH HAVE_GIT GIT HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC CSNEXT LOADLIBS USE_TREESITTER HAVE_FORK WANT_PTRACE_WRAP WITH_LIBR WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL"
|
||||
|
||||
create_environ
|
||||
|
||||
@ -693,7 +691,7 @@ done
|
||||
do_remove
|
||||
echo
|
||||
echo "Final report:"
|
||||
for A in R_CHECKS_LEVEL PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET USEROSTYPE LIBVERSION BUILD HOST TARGET ; do # REPORT
|
||||
for A in R_CHECKS_LEVEL PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK USE_TREESITTER VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET USEROSTYPE LIBVERSION BUILD HOST TARGET ; do # REPORT
|
||||
eval VAL="\$${A}"
|
||||
[ -z "${VAL}" ] && VAL="(null)"
|
||||
echo " - ${A} = ${VAL}"
|
||||
|
@ -26,6 +26,8 @@ ARG_WITH CSNEXT capstone5 build next branch of the capstone repository ;
|
||||
(( useful for static builds . see sys/static.sh ))
|
||||
ARG_DISABLE LOADLIBS loadlibs disable loading plugins ;
|
||||
|
||||
ARG_WITH USE_TREESITTER shell-parser Compile with radare2-shell-parser experimental support ;
|
||||
|
||||
ARG_WITHOUT HAVE_FORK fork disable fork ;
|
||||
ARG_WITHOUT WANT_PTRACE_WRAP ptrace-wrap disable ptrace-wrap build ;
|
||||
|
||||
@ -214,7 +216,7 @@ IFEQ WANT_PTRACE_WRAP 0 ; {
|
||||
ARG_WITH R_CHECKS_LEVEL=2 checks-level value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL) ;
|
||||
|
||||
REPORT R_CHECKS_LEVEL PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK
|
||||
VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM
|
||||
USE_TREESITTER VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM
|
||||
HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET USEROSTYPE LIBVERSION BUILD HOST TARGET ;
|
||||
|
||||
(( TODO: Add the rest of .pc files here.. add a rule for acr? ))
|
||||
|
@ -14,7 +14,9 @@ OBJS+=task.o panels.o pseudo.o vmarks.o anal_tp.o anal_objc.o blaze.o cundo.o
|
||||
OBJS+=esil_data_flow.o
|
||||
|
||||
CFLAGS+=-I../../shlr/heap/include
|
||||
ifeq ($(USE_TREESITTER),1)
|
||||
CFLAGS+=-I../../shlr/tree-sitter/lib/include -I../../shlr/radare2-shell-parser/src/tree_parser
|
||||
endif
|
||||
CFLAGS+=-DR2_PLUGIN_INCORE -I../../shlr
|
||||
LDFLAGS+=${DL_LIBS}
|
||||
|
||||
@ -42,7 +44,9 @@ OBJS+=$(STATIC_OBJS)
|
||||
#STATIC_OBJS=$(subst ..,p/..,$(subst core_,p/core_,$(STATIC_OBJ)))
|
||||
|
||||
include $(TOP)/shlr/gdb/deps.mk
|
||||
ifeq ($(USE_TREESITTER),1)
|
||||
include $(TOP)/shlr/radare2-shell-parser-deps.mk
|
||||
endif
|
||||
include $(LTOP)/rules.mk
|
||||
|
||||
# include plugins
|
||||
|
@ -21,14 +21,16 @@
|
||||
#include <r_cmd.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <tree_sitter/api.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#if __UNIX__
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#if USE_TREESITTER
|
||||
#include <tree_sitter/api.h>
|
||||
TSLanguage *tree_sitter_r2cmd ();
|
||||
#endif
|
||||
|
||||
R_API void r_save_panels_layout(RCore *core, const char *_name);
|
||||
R_API void r_load_panels_layout(RCore *core, const char *_name);
|
||||
@ -4351,6 +4353,7 @@ R_API void run_pending_anal(RCore *core) {
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_TREESITTER
|
||||
static inline bool is_ts_commands(TSNode node) {
|
||||
return strcmp (ts_node_type (node), "commands") == 0;
|
||||
}
|
||||
@ -4475,10 +4478,15 @@ static bool core_cmd_tsr2cmd(RCore *core, const char *cstr, bool log) {
|
||||
ts_parser_delete (parser);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
R_API int r_core_cmd(RCore *core, const char *cstr, int log) {
|
||||
if (core->use_tree_sitter_r2cmd) {
|
||||
#if USE_TREESITTER
|
||||
return core_cmd_tsr2cmd (core, cstr, log)? 0: 1;
|
||||
#else
|
||||
R_LOG_WARN ("No compilation support for radare2-shell-parser\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
char *cmd, *ocmd, *ptr, *rcmd;
|
||||
|
@ -98,6 +98,8 @@
|
||||
#define USE_PTRACE_WRAP @USE_PTRACE_WRAP@
|
||||
#define HAVE_FORK @HAVE_FORK@
|
||||
|
||||
#define USE_TREESITTER @USE_TREESITTER@
|
||||
|
||||
#define WITH_GPL @WITH_GPL@
|
||||
|
||||
#if __APPLE__ && __POWERPC__
|
||||
|
@ -334,6 +334,7 @@ userconf.set10('HAVE_FORK', true)
|
||||
userconf.set10('HAVE_PTRACE', have_ptrace)
|
||||
userconf.set10('USE_PTRACE_WRAP', use_ptrace_wrap)
|
||||
userconf.set10('WITH_GPL', true)
|
||||
userconf.set10('USE_TREESITTER', get_option('use_treesitter'))
|
||||
ok = cc.has_header_symbol('sys/personality.h', 'ADDR_NO_RANDOMIZE')
|
||||
userconf.set10('HAVE_DECL_ADDR_NO_RANDOMIZE', ok)
|
||||
|
||||
|
@ -27,6 +27,7 @@ option('use_sys_lz4', type: 'boolean', value: false)
|
||||
option('use_sys_xxhash', type: 'boolean', value: false)
|
||||
option('use_sys_openssl', type: 'boolean', value: false)
|
||||
option('use_libuv', type: 'boolean', value: true)
|
||||
option('use_treesitter', type: 'boolean', value: false)
|
||||
option('debugger', type: 'boolean', value: true)
|
||||
|
||||
option('use_webui', type: 'boolean', value: false, description: 'install different WebUIs for radare2')
|
||||
|
@ -329,6 +329,7 @@ else
|
||||
cd ../../radare2-webui/www/m && git pull ; npm i ; $(MAKE) release
|
||||
endif
|
||||
|
||||
ifeq ($(USE_TREESITTER),1)
|
||||
tree-sitter-build: tree-sitter/libtree-sitter.$(EXT_AR)
|
||||
|
||||
tree-sitter/libtree-sitter.$(EXT_AR): tree-sitter/lib/src/lib.o
|
||||
@ -353,6 +354,12 @@ radare2-shell-parser/src/parser.o: radare2-shell-parser-sync
|
||||
radare2-shell-parser-sync: tree-sitter-sync
|
||||
"$(SHELL)" clone_3rd_repo.sh radare2-shell-parser "${SHELLPARSER_URL}" "${SHELLPARSER_BRA}" "${SHELLPARSER_TIP}"
|
||||
|
||||
SHLRS+=tree-sitter/libtree-sitter.a
|
||||
SHLRS+=radare2-shell-parser/libshell-parser.a
|
||||
else
|
||||
tree-sitter-build:
|
||||
radare2-shell-parser-build:
|
||||
endif
|
||||
|
||||
www-sync-m sync-www-m: ../../radare2-webui/dist/m
|
||||
cp -rf ../../radare2-webui/dist/m www/m.tmp
|
||||
@ -394,8 +401,6 @@ SHLRS+=grub/libgrubfs.a
|
||||
SHLRS+=java/libr_java.a
|
||||
SHLRS+=lz4/liblz4.a
|
||||
SHLRS+=qnx/lib/libqnxr.a
|
||||
SHLRS+=tree-sitter/libtree-sitter.a
|
||||
SHLRS+=radare2-shell-parser/libshell-parser.a
|
||||
#SHLRS+=sdb/src/libsdb.a
|
||||
#SHLRS+=tcc/libr_tcc.a
|
||||
SHLRS+=windbg/libr_windbg.a
|
||||
|
191
shlr/meson.build
191
shlr/meson.build
@ -233,101 +233,106 @@ sdb_gen_cmd = [
|
||||
]
|
||||
|
||||
|
||||
# handle tree-sitter dependency
|
||||
if get_option('tree_sitter_in_builddir')
|
||||
tree_sitter_path = join_paths(meson.current_build_dir(), 'tree-sitter')
|
||||
if get_option('use_treesitter')
|
||||
# handle tree-sitter dependency
|
||||
if get_option('tree_sitter_in_builddir')
|
||||
tree_sitter_path = join_paths(meson.current_build_dir(), 'tree-sitter')
|
||||
else
|
||||
tree_sitter_path = join_paths(meson.current_source_dir(), 'tree-sitter')
|
||||
endif
|
||||
res = run_command(py3_exe, '-c', '__import__("sys").exit(__import__("os").path.exists("@0@"))'.format(tree_sitter_path))
|
||||
if res.returncode() == 0
|
||||
if not git_exe.found()
|
||||
error('Cannot load tree-sitter library. Either provide tree-sitter in ./shlr/tree-sitter or install git, so it can be downloaded')
|
||||
endif
|
||||
|
||||
# NOTE: when you update TS_TIP or TS_BRA, also update them in shlr/Makefile
|
||||
TS_TIP = '9f77afcd1ff050855259f83fcf50056ad842a790'
|
||||
TS_BRA = 'master'
|
||||
|
||||
message('Cloning tree-sitter ' + TS_BRA + ' branch, commit ' + TS_TIP + ', into ' + tree_sitter_path)
|
||||
git_cmd = 'clone -b @0@ https://github.com/tree-sitter/tree-sitter.git @1@'.format(TS_BRA, tree_sitter_path)
|
||||
clone_cmd = run_command(git_exe, git_cmd.split())
|
||||
if clone_cmd.returncode() != 0
|
||||
error('Cannot execute git clone command')
|
||||
endif
|
||||
|
||||
reset_cmd_str = '-C @0@ reset --hard @1@'.format(tree_sitter_path, TS_TIP)
|
||||
reset_cmd = run_command(git_exe, reset_cmd_str.split())
|
||||
if reset_cmd.returncode() != 0
|
||||
error('Cannot execute git reset command')
|
||||
endif
|
||||
endif
|
||||
|
||||
tree_sitter_files = [
|
||||
join_paths(tree_sitter_path, 'lib/src/lib.c'),
|
||||
]
|
||||
|
||||
tree_sitter_inc = [platform_inc, include_directories('tree-sitter/lib/src'), include_directories('tree-sitter/lib/include')]
|
||||
|
||||
libtree_sitter = static_library('tree_sitter', tree_sitter_files,
|
||||
include_directories: tree_sitter_inc,
|
||||
implicit_include_directories: false,
|
||||
c_args: ['-std=c99']
|
||||
)
|
||||
|
||||
tree_sitter_dep = declare_dependency(
|
||||
link_with: libtree_sitter,
|
||||
include_directories: tree_sitter_inc
|
||||
)
|
||||
|
||||
|
||||
# handle radare2-shell-parser dependency
|
||||
if get_option('shell_parser_in_builddir')
|
||||
shell_parser_path = join_paths(meson.current_build_dir(), 'radare2-shell-parser')
|
||||
else
|
||||
shell_parser_path = join_paths(meson.current_source_dir(), 'radare2-shell-parser')
|
||||
endif
|
||||
res = run_command(py3_exe, '-c', '__import__("sys").exit(__import__("os").path.exists("@0@"))'.format(shell_parser_path))
|
||||
if res.returncode() == 0
|
||||
if not git_exe.found()
|
||||
error('Cannot load radare2-shell-parser library. Either provide radare2-shell-parser in ./shlr/radare2-shell-parser or install git, so it can be downloaded')
|
||||
endif
|
||||
|
||||
# NOTE: when you update SHELLPARSER_TIP or SHELLPARSER_BRA, also update them in shlr/Makefile
|
||||
SHELLPARSER_TIP = 'dfb12492f4052b5a6c64fc626e9bf65ccb7b5522'
|
||||
SHELLPARSER_BRA = 'master'
|
||||
shell_parser_user = 'ret2libc'
|
||||
|
||||
message('Cloning radare2-shell-parser ' + SHELLPARSER_BRA + ' branch, commit ' + SHELLPARSER_TIP + ', into ' + shell_parser_path)
|
||||
git_cmd = 'clone -b @0@ https://github.com/@1@/radare2-shell-parser.git @2@'.format(SHELLPARSER_BRA, shell_parser_user, shell_parser_path)
|
||||
clone_cmd = run_command(git_exe, git_cmd.split())
|
||||
if clone_cmd.returncode() != 0
|
||||
error('Cannot execute git clone command')
|
||||
endif
|
||||
|
||||
reset_cmd_str = '-C @0@ reset --hard @1@'.format(shell_parser_path, SHELLPARSER_TIP)
|
||||
reset_cmd = run_command(git_exe, reset_cmd_str.split())
|
||||
if reset_cmd.returncode() != 0
|
||||
error('Cannot execute git reset command')
|
||||
endif
|
||||
endif
|
||||
|
||||
shell_parser_files = [
|
||||
join_paths(shell_parser_path, 'src/parser.c'),
|
||||
]
|
||||
|
||||
shell_parser_inc = [platform_inc, include_directories('radare2-shell-parser/src/tree_sitter')]
|
||||
|
||||
libshell_parser = static_library('shell_parser', shell_parser_files,
|
||||
include_directories: shell_parser_inc + tree_sitter_inc,
|
||||
implicit_include_directories: true
|
||||
)
|
||||
|
||||
shell_parser_dep = declare_dependency(
|
||||
link_with: libshell_parser,
|
||||
include_directories: shell_parser_inc,
|
||||
dependencies: tree_sitter_dep
|
||||
)
|
||||
else
|
||||
tree_sitter_path = join_paths(meson.current_source_dir(), 'tree-sitter')
|
||||
shell_parser_dep = []
|
||||
tree_sitter_dep = []
|
||||
endif
|
||||
res = run_command(py3_exe, '-c', '__import__("sys").exit(__import__("os").path.exists("@0@"))'.format(tree_sitter_path))
|
||||
if res.returncode() == 0
|
||||
if not git_exe.found()
|
||||
error('Cannot load tree-sitter library. Either provide tree-sitter in ./shlr/tree-sitter or install git, so it can be downloaded')
|
||||
endif
|
||||
|
||||
# NOTE: when you update TS_TIP or TS_BRA, also update them in shlr/Makefile
|
||||
TS_TIP = '9f77afcd1ff050855259f83fcf50056ad842a790'
|
||||
TS_BRA = 'master'
|
||||
|
||||
message('Cloning tree-sitter ' + TS_BRA + ' branch, commit ' + TS_TIP + ', into ' + tree_sitter_path)
|
||||
git_cmd = 'clone -b @0@ https://github.com/tree-sitter/tree-sitter.git @1@'.format(TS_BRA, tree_sitter_path)
|
||||
clone_cmd = run_command(git_exe, git_cmd.split())
|
||||
if clone_cmd.returncode() != 0
|
||||
error('Cannot execute git clone command')
|
||||
endif
|
||||
|
||||
reset_cmd_str = '-C @0@ reset --hard @1@'.format(tree_sitter_path, TS_TIP)
|
||||
reset_cmd = run_command(git_exe, reset_cmd_str.split())
|
||||
if reset_cmd.returncode() != 0
|
||||
error('Cannot execute git reset command')
|
||||
endif
|
||||
endif
|
||||
|
||||
tree_sitter_files = [
|
||||
join_paths(tree_sitter_path, 'lib/src/lib.c'),
|
||||
]
|
||||
|
||||
tree_sitter_inc = [platform_inc, include_directories('tree-sitter/lib/src'), include_directories('tree-sitter/lib/include')]
|
||||
|
||||
libtree_sitter = static_library('tree_sitter', tree_sitter_files,
|
||||
include_directories: tree_sitter_inc,
|
||||
implicit_include_directories: false,
|
||||
c_args: ['-std=c99']
|
||||
)
|
||||
|
||||
tree_sitter_dep = declare_dependency(
|
||||
link_with: libtree_sitter,
|
||||
include_directories: tree_sitter_inc
|
||||
)
|
||||
|
||||
|
||||
# handle radare2-shell-parser dependency
|
||||
if get_option('shell_parser_in_builddir')
|
||||
shell_parser_path = join_paths(meson.current_build_dir(), 'radare2-shell-parser')
|
||||
else
|
||||
shell_parser_path = join_paths(meson.current_source_dir(), 'radare2-shell-parser')
|
||||
endif
|
||||
res = run_command(py3_exe, '-c', '__import__("sys").exit(__import__("os").path.exists("@0@"))'.format(shell_parser_path))
|
||||
if res.returncode() == 0
|
||||
if not git_exe.found()
|
||||
error('Cannot load radare2-shell-parser library. Either provide radare2-shell-parser in ./shlr/radare2-shell-parser or install git, so it can be downloaded')
|
||||
endif
|
||||
|
||||
# NOTE: when you update SHELLPARSER_TIP or SHELLPARSER_BRA, also update them in shlr/Makefile
|
||||
SHELLPARSER_TIP = 'dfb12492f4052b5a6c64fc626e9bf65ccb7b5522'
|
||||
SHELLPARSER_BRA = 'master'
|
||||
shell_parser_user = 'ret2libc'
|
||||
|
||||
message('Cloning radare2-shell-parser ' + SHELLPARSER_BRA + ' branch, commit ' + SHELLPARSER_TIP + ', into ' + shell_parser_path)
|
||||
git_cmd = 'clone -b @0@ https://github.com/@1@/radare2-shell-parser.git @2@'.format(SHELLPARSER_BRA, shell_parser_user, shell_parser_path)
|
||||
clone_cmd = run_command(git_exe, git_cmd.split())
|
||||
if clone_cmd.returncode() != 0
|
||||
error('Cannot execute git clone command')
|
||||
endif
|
||||
|
||||
reset_cmd_str = '-C @0@ reset --hard @1@'.format(shell_parser_path, SHELLPARSER_TIP)
|
||||
reset_cmd = run_command(git_exe, reset_cmd_str.split())
|
||||
if reset_cmd.returncode() != 0
|
||||
error('Cannot execute git reset command')
|
||||
endif
|
||||
endif
|
||||
|
||||
shell_parser_files = [
|
||||
join_paths(shell_parser_path, 'src/parser.c'),
|
||||
]
|
||||
|
||||
shell_parser_inc = [platform_inc, include_directories('radare2-shell-parser/src/tree_sitter')]
|
||||
|
||||
libshell_parser = static_library('shell_parser', shell_parser_files,
|
||||
include_directories: shell_parser_inc + tree_sitter_inc,
|
||||
implicit_include_directories: true
|
||||
)
|
||||
|
||||
shell_parser_dep = declare_dependency(
|
||||
link_with: libshell_parser,
|
||||
include_directories: shell_parser_inc,
|
||||
dependencies: tree_sitter_dep
|
||||
)
|
||||
|
||||
|
||||
# handle bochs dependency
|
||||
|
Loading…
Reference in New Issue
Block a user