From 83cd7e86986879704db5269b678e3642e3060d11 Mon Sep 17 00:00:00 2001 From: yossizap Date: Thu, 13 Aug 2020 14:08:39 +0000 Subject: [PATCH] Update R2 submodule (#2378) * Handle r2 sdb include path changes. --- .gitignore | 1 + meson.py | 22 ++++++++++++---------- prepare_r2.bat | 2 +- radare2 | 2 +- scripts/appveyor_r2ghidra.sh | 2 +- src/Cutter.pro | 7 +++++-- src/cmake/BundledRadare2.cmake | 6 ++++-- src/cmake/FindRadare2.cmake | 8 ++++++++ src/lib_radare2.pri | 5 +++++ 9 files changed, 38 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index fe7a1c71..c28933e8 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ src/CMakeFiles/* ninja.exe r2_dist_x86/ r2_dist_x64/ +r2_dist/ *.pdb # Mesonbuild diff --git a/meson.py b/meson.py index f34decf9..e158c945 100644 --- a/meson.py +++ b/meson.py @@ -32,16 +32,13 @@ def set_global_vars(): r2_meson_mod.set_global_variables() def win_dist(args): - build = os.path.join(ROOT, args.dir) - dist = os.path.join(ROOT, args.dist) - os.makedirs(dist) - r2_meson_mod.copy(os.path.join(build, 'Cutter.exe'), dist) + os.makedirs(args.dist) + r2_meson_mod.copy(os.path.join(args.dir, 'Cutter.exe'), args.dist) log.debug('Deploying Qt5') - subprocess.call(['windeployqt', '--release', os.path.join(dist, 'Cutter.exe')]) + subprocess.call(['windeployqt', '--release', os.path.join(args.dist, 'Cutter.exe')]) log.debug('Deploying libr2') r2_meson_mod.PATH_FMT.update(r2_meson_mod.R2_PATH) - r2_meson_mod.win_dist_libr2(DIST=dist, BUILDDIR=os.path.join(build, 'subprojects', 'radare2'), - R2_DATDIR=r'radare2\share', R2_INCDIR=r'radare2\include') + r2_meson_mod.meson('install', options=[['-C', '{}'.format(args.dir)], '--no-rebuild']) def build(args): cutter_builddir = os.path.join(ROOT, args.dir) @@ -53,8 +50,8 @@ def build(args): defines.append('-Dradare2:r2_libdir=radare2/lib') defines.append('-Dradare2:r2_datdir=radare2/share') defines.append('-Dc_args=-D_UNICODE -DUNICODE') - r2_meson_mod.meson(os.path.join(ROOT, 'src'), cutter_builddir, - prefix=cutter_builddir, backend=args.backend, + r2_meson_mod.meson('setup', rootdir=os.path.join(ROOT, 'src'), builddir=args.dir, + prefix=os.path.abspath(args.dist), backend=args.backend, release=args.release, shared=False, options=defines) if not args.nobuild: log.info('Building cutter') @@ -84,6 +81,11 @@ def main(): parser.add_argument('--dist', help='dist directory') args = parser.parse_args() + if os.name == 'nt' and not args.dist: + args.dist = args.dir + args.dist = os.path.abspath(args.dist) + args.dir = os.path.abspath(args.dir) + if hasattr(args, 'dist') and args.dist and os.path.exists(args.dist): log.error('%s already exists', args.dist) sys.exit(1) @@ -92,7 +94,7 @@ def main(): build(args) - if hasattr(args, 'dist') and args.dist: + if os.name == 'nt' and hasattr(args, 'dist') and args.dist: win_dist(args) import_r2_meson_mod() diff --git a/prepare_r2.bat b/prepare_r2.bat index 4d3db8c3..770834c8 100644 --- a/prepare_r2.bat +++ b/prepare_r2.bat @@ -16,7 +16,7 @@ ECHO Building radare2 (%PLATFORM%) CD radare2 git clean -xfd RMDIR /S /Q ..\%R2DIST% -rem python sys\meson.py --release --shared --install=..\%R2DIST% --options "r2_datdir=radare2/share" "r2_libdir=radare2/lib" #"c_args=-D_UNICODE -DUNICODE" +rem python sys\meson.py --release --shared --install --prefix=%CD%\..\%R2DIST% --options "r2_datdir=radare2/share" "r2_libdir=radare2/lib" #"c_args=-D_UNICODE -DUNICODE" meson.exe r2_builddir --buildtype=release --prefix=%CD%\..\%R2DIST% || EXIT /B 1 ninja -C r2_builddir install || EXIT /B 1 IF !ERRORLEVEL! NEQ 0 EXIT /B 1 diff --git a/radare2 b/radare2 index 9d7eda5e..68a1db44 160000 --- a/radare2 +++ b/radare2 @@ -1 +1 @@ -Subproject commit 9d7eda5ec7367d1682e489e92d1be8e37e459296 +Subproject commit 68a1db448d9007fb8548b8806cbea6698acc2066 diff --git a/scripts/appveyor_r2ghidra.sh b/scripts/appveyor_r2ghidra.sh index b54fab1d..b7721fac 100755 --- a/scripts/appveyor_r2ghidra.sh +++ b/scripts/appveyor_r2ghidra.sh @@ -3,6 +3,6 @@ scripts/r2ghidra.sh \ -DCMAKE_C_COMPILER=cl \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="$APPVEYOR_BUILD_FOLDER/r2_dist;$APPVEYOR_BUILD_FOLDER/r2_dist/include/libr;$QT64PATH" \ + -DCMAKE_PREFIX_PATH="$APPVEYOR_BUILD_FOLDER/r2_dist;$APPVEYOR_BUILD_FOLDER/r2_dist/include/libr;$APPVEYOR_BUILD_FOLDER/r2_dist/include/libr/sdb;$QT64PATH" \ -DCMAKE_INSTALL_PREFIX="$APPVEYOR_BUILD_FOLDER/r2_dist" \ -DRADARE2_INSTALL_PLUGDIR="$APPVEYOR_BUILD_FOLDER/r2_dist/lib/plugins" \ No newline at end of file diff --git a/src/Cutter.pro b/src/Cutter.pro index 114a7c61..bb86c765 100644 --- a/src/Cutter.pro +++ b/src/Cutter.pro @@ -112,6 +112,7 @@ macx { unix:exists(/usr/local/include/libr)|bsd:exists(/usr/local/include/libr) { INCLUDEPATH += /usr/local/include/libr + INCLUDEPATH += /usr/local/include/libr/sdb } unix { QMAKE_LFLAGS += -rdynamic # Export dynamic symbols for plugins @@ -166,8 +167,10 @@ CUTTER_ENABLE_PYTHON { BINDINGS_INCLUDE_DIRS = "$$[QT_INSTALL_HEADERS]" \ "$$[QT_INSTALL_HEADERS]/QtCore" \ "$$[QT_INSTALL_HEADERS]/QtWidgets" \ - "$$[QT_INSTALL_HEADERS]/QtGui" \ - "$$R2_INCLUDEPATH" + "$$[QT_INSTALL_HEADERS]/QtGui" + for (path, R2_INCLUDEPATH) { + BINDINGS_INCLUDE_DIRS += "$$path" + } for(path, INCLUDEPATH) { BINDINGS_INCLUDE_DIRS += $$absolute_path("$$path") } diff --git a/src/cmake/BundledRadare2.cmake b/src/cmake/BundledRadare2.cmake index d3ec0d95..877b6f67 100644 --- a/src/cmake/BundledRadare2.cmake +++ b/src/cmake/BundledRadare2.cmake @@ -30,7 +30,7 @@ ExternalProject_Add(Radare2-Bundled BUILD_COMMAND "${NINJA}" INSTALL_COMMAND "${NINJA}" install) -set(Radare2_INCLUDE_DIRS "${RADARE2_INSTALL_DIR}/include/libr") +set(Radare2_INCLUDE_DIRS "${RADARE2_INSTALL_DIR}/include/libr" "${RADARE2_INSTALL_DIR}/include/libr/sdb") add_library(Radare2 INTERFACE) add_dependencies(Radare2 Radare2-Bundled) @@ -50,7 +50,9 @@ set (R2_BIN r2agent rabin2 radare2 radiff2 rafind2 ragg2 rahash2 rarun2 rasm2 ra target_link_libraries(Radare2 INTERFACE ${R2_LIBS}) -target_include_directories(Radare2 INTERFACE $ $) +target_include_directories(Radare2 INTERFACE + "$" + "$") install(TARGETS Radare2 EXPORT CutterTargets) if (APPLE) diff --git a/src/cmake/FindRadare2.cmake b/src/cmake/FindRadare2.cmake index ec897124..19b92e4d 100644 --- a/src/cmake/FindRadare2.cmake +++ b/src/cmake/FindRadare2.cmake @@ -22,6 +22,14 @@ if(WIN32) "$ENV{HOME}/bin/prefix/radare2/include/libr" /usr/local/include/libr /usr/include/libr) + find_path(SDB_INCLUDE_DIR + NAMES sdb.h sdbht.h sdb_version.h + HINTS + "$ENV{HOME}/bin/prefix/radare2/include/libr/sdb" + /usr/local/include/libr/sdb + /usr/include/libr/sdb) + + list(APPEND Radare2_INCLUDE_DIRS ${SDB_INCLUDE_DIR}) set(Radare2_LIBRARY_NAMES core diff --git a/src/lib_radare2.pri b/src/lib_radare2.pri index 8b61d2c2..8117b11a 100644 --- a/src/lib_radare2.pri +++ b/src/lib_radare2.pri @@ -3,6 +3,7 @@ win32 { DEFINES += _CRT_SECURE_NO_WARNINGS LIBS += -L"$$PWD/../r2_dist/lib" R2_INCLUDEPATH += "$$PWD/../r2_dist/include/libr" + R2_INCLUDEPATH += "$$PWD/../r2_dist/include/libr/sdb" INCLUDEPATH += $$R2_INCLUDEPATH LIBS += \ @@ -46,18 +47,21 @@ win32 { } else { LIBS += -L$$R2PREFIX/lib R2_INCLUDEPATH += $$R2PREFIX/include/libr + R2_INCLUDEPATH += $$R2PREFIX/include/libr/sdb USE_PKGCONFIG = 0 } } macx { LIBS += -L$$R2PREFIX/lib R2_INCLUDEPATH += $$R2PREFIX/include/libr + R2_INCLUDEPATH += $$R2PREFIX/include/libr/sdb USE_PKGCONFIG = 0 } bsd { !exists($$PKG_CONFIG_PATH/r_core.pc) { LIBS += -L$$R2PREFIX/lib R2_INCLUDEPATH += $$R2PREFIX/include/libr + R2_INCLUDEPATH += $$R2PREFIX/include/libr/sdb USE_PKGCONFIG = 0 } } @@ -70,6 +74,7 @@ win32 { CONFIG += link_pkgconfig PKGCONFIG += r_core R2_INCLUDEPATH = "$$system("pkg-config --variable=includedir r_core")/libr" + R2_INCLUDEPATH += "$$system("pkg-config --variable=includedir r_core")/libr/sdb" } else { LIBS += \ -lr_core \