diff --git a/configure b/configure index 776b4bf87c..760afaea0b 100755 --- a/configure +++ b/configure @@ -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 CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory - CPP C preprocessor -" -printf " -Report bugs to: pancake " + CPP C preprocessor\n" +printf "\nReport bugs to: pancake " 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}" diff --git a/configure.acr b/configure.acr index a7f001aa22..7c902c09d5 100644 --- a/configure.acr +++ b/configure.acr @@ -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? )) diff --git a/libr/core/Makefile b/libr/core/Makefile index c63df67e01..54f24530fc 100644 --- a/libr/core/Makefile +++ b/libr/core/Makefile @@ -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 diff --git a/libr/core/cmd.c b/libr/core/cmd.c index 9c1b75104e..a20c9728dd 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -21,14 +21,16 @@ #include #include #include -#include #include #include #if __UNIX__ #include #endif +#if USE_TREESITTER +#include 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; diff --git a/libr/include/r_userconf.h.acr b/libr/include/r_userconf.h.acr index e68c68a2b6..e3cfaf18dd 100644 --- a/libr/include/r_userconf.h.acr +++ b/libr/include/r_userconf.h.acr @@ -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__ diff --git a/meson.build b/meson.build index 6c7434f09c..ba4c5e9ed7 100644 --- a/meson.build +++ b/meson.build @@ -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) diff --git a/meson_options.txt b/meson_options.txt index d8076d16f7..6c2e2fad8c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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') diff --git a/shlr/Makefile b/shlr/Makefile index f8535b7dc0..79d53123d5 100644 --- a/shlr/Makefile +++ b/shlr/Makefile @@ -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 diff --git a/shlr/meson.build b/shlr/meson.build index 6780b40eee..97f83a9e31 100644 --- a/shlr/meson.build +++ b/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