Update Rizin to dev and use CMake config files (#2855)

API usage has been adjusted.
There are now also cmake config files directly installed by Rizin itself, so we don't need to keep a custom FindRizin.cmake file in Cutter. This remove that file and just uses `find_package(Rizin COMPONENTS Core)`, which will use the cmake files installed on the system.
This commit is contained in:
Riccardo Schirone 2021-12-22 09:57:58 +01:00 committed by Anton Kochkov
parent f5a7a79ee8
commit 98411b4dbf
12 changed files with 40 additions and 156 deletions

View File

@ -48,8 +48,8 @@ if(CUTTER_USE_BUNDLED_RIZIN)
include(BundledRizin)
set(RIZIN_TARGET Rizin)
else()
find_package(Rizin REQUIRED)
set(RIZIN_TARGET Rizin::librz)
find_package(Rizin COMPONENTS Core REQUIRED)
set(RIZIN_TARGET Rizin::Core)
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)

View File

@ -47,8 +47,8 @@ else()
endif()
set (RZ_LIBS rz_core rz_config rz_cons rz_io rz_util rz_flag rz_asm rz_debug
rz_hash rz_bin rz_lang rz_io rz_analysis rz_parse rz_bp rz_egg rz_reg
rz_search rz_syscall rz_socket rz_magic rz_crypto rz_type rz_diff)
rz_hash rz_bin rz_lang rz_il rz_analysis rz_parse rz_bp rz_egg rz_reg
rz_search rz_syscall rz_socket rz_magic rz_crypto rz_type rz_diff rz_sign)
set (RZ_EXTRA_LIBS rz_main)
set (RZ_BIN rz-agent rz-bin rizin rz-diff rz-find rz-gg rz-hash rz-run rz-asm rz-ax)

View File

@ -1,117 +0,0 @@
# - Find Rizin (librz)
#
# This module provides the following imported targets, if found:
#
# Rizin::librz
#
# This will define the following variables:
# (but don't use them if you don't know what you are doing, use Rizin::librz)
#
# Rizin_FOUND - True if librz has been found.
# Rizin_INCLUDE_DIRS - librz include directory
# Rizin_LIBRARIES - List of libraries when using librz.
# Rizin_LIBRARY_DIRS - librz library directories
#
# If librz was found using find_library and not pkg-config, the following variables will also be set:
# Rizin_LIBRARY_<name> - Path to library rz_<name>
if(WIN32)
find_path(Rizin_INCLUDE_DIRS
NAMES rz_core.h rz_bin.h rz_util.h
HINTS
"$ENV{HOME}/bin/prefix/rizin/include/librz"
/usr/local/include/libr
/usr/include/librz)
find_path(SDB_INCLUDE_DIR
NAMES sdb.h sdbht.h sdb_version.h
HINTS
"$ENV{HOME}/bin/prefix/rizin/include/librz/sdb"
/usr/local/include/librz/sdb
/usr/include/librz/sdb)
list(APPEND Rizin_INCLUDE_DIRS ${SDB_INCLUDE_DIR})
set(Rizin_LIBRARY_NAMES
core
config
cons
io
util
flag
asm
debug
hash
bin
lang
io
analysis
parse
bp
egg
reg
search
syscall
socket
magic
crypto
type)
set(Rizin_LIBRARIES "")
set(Rizin_LIBRARIES_VARS "")
foreach(libname ${Rizin_LIBRARY_NAMES})
find_library(Rizin_LIBRARY_${libname}
rz_${libname}
HINTS
"$ENV{HOME}/bin/prefix/rizin/lib"
/usr/local/lib
/usr/lib)
list(APPEND Rizin_LIBRARIES ${Rizin_LIBRARY_${libname}})
list(APPEND Rizin_LIBRARIES_VARS "Rizin_LIBRARY_${libname}")
endforeach()
set(Rizin_LIBRARY_DIRS "")
add_library(Rizin::librz UNKNOWN IMPORTED)
set_target_properties(Rizin::librz PROPERTIES
IMPORTED_LOCATION "${Rizin_LIBRARY_core}"
IMPORTED_LINK_INTERFACE_LIBRARIES "${Rizin_LIBRARIES}"
INTERFACE_LINK_DIRECTORIES "${Rizin_LIBRARY_DIRS}"
INTERFACE_INCLUDE_DIRECTORIES "${Rizin_INCLUDE_DIRS}")
set(Rizin_TARGET Rizin::librz)
else()
# support installation locations used by rizin scripts like sys/user.sh and sys/install.sh
if(CUTTER_USE_ADDITIONAL_RIZIN_PATHS)
set(Rizin_CMAKE_PREFIX_PATH_TEMP ${CMAKE_PREFIX_PATH})
list(APPEND CMAKE_PREFIX_PATH "$ENV{HOME}/bin/prefix/rizin") # sys/user.sh
list(APPEND CMAKE_PREFIX_PATH "/usr/local") # sys/install.sh
endif()
find_package(PkgConfig REQUIRED)
if(CMAKE_VERSION VERSION_LESS "3.6")
pkg_search_module(Rizin REQUIRED rz_core)
else()
pkg_search_module(Rizin IMPORTED_TARGET REQUIRED rz_core)
endif()
# reset CMAKE_PREFIX_PATH
if(CUTTER_USE_ADDITIONAL_RIZIN_PATHS)
set(CMAKE_PREFIX_PATH ${Rizin_CMAKE_PREFIX_PATH_TEMP})
endif()
if((TARGET PkgConfig::Rizin) AND (NOT CMAKE_VERSION VERSION_LESS "3.11.0"))
set_target_properties(PkgConfig::Rizin PROPERTIES IMPORTED_GLOBAL ON)
add_library(Rizin::librz ALIAS PkgConfig::Rizin)
set(Rizin_TARGET Rizin::librz)
elseif(Rizin_FOUND)
add_library(Rizin::librz INTERFACE IMPORTED)
set_target_properties(Rizin::librz PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Rizin_INCLUDE_DIRS}")
set_target_properties(Rizin::librz PROPERTIES
INTERFACE_LINK_LIBRARIES "${Rizin_LIBRARIES}")
set(Rizin_TARGET Rizin::librz)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Rizin REQUIRED_VARS Rizin_TARGET Rizin_LIBRARIES Rizin_INCLUDE_DIRS)

8
dist/CMakeLists.txt vendored
View File

@ -84,9 +84,7 @@ if(APPLE)
if (CUTTER_PACKAGE_JSDEC AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
install(CODE "
execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/jsdec.sh\" --prefix=\${CMAKE_INSTALL_PREFIX}
\"-Drizin_incdir=\${CMAKE_INSTALL_PREFIX}/include/librz\"
\"-Drizin_libdir=\${CMAKE_INSTALL_PREFIX}/lib\"
execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/jsdec.sh\" --pkg-config-path=\${CMAKE_INSTALL_PREFIX}/lib/pkgconfig --prefix=\${CMAKE_INSTALL_PREFIX}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE SCRIPT_RESULT)
if (SCRIPT_RESULT)
@ -109,9 +107,9 @@ if(CUTTER_PACKAGE_RZ_GHIDRA)
# installed Cutter.
ExternalProject_Add(rz-ghidra
GIT_REPOSITORY https://github.com/rizinorg/rz-ghidra
GIT_TAG v0.3.0
#GIT_TAG v0.3.0
#GIT_TAG c7a50a2e7c0a95cd52b167c9ee0fa1805223f08e
#GIT_TAG dev
GIT_TAG dev
#GIT_SHALLOW ON # disable this line when using commit hash
CONFIGURE_COMMAND ""
BUILD_COMMAND ""

View File

@ -25,7 +25,6 @@ file(COPY "${INFO_PLIST_PATH}" DESTINATION "${BUNDLE_PATH}/Contents")
# replace absolute path from build directory in rizin pkgconfig files with relative ones
file(GLOB RZ_PCFILES "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/rz_*.pc")
list(APPEND RZ_PCFILES "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/librz.pc")
foreach (_pcfile ${RZ_PCFILES})
file(READ "${_pcfile}" _text)
string(REGEX REPLACE "^prefix=[^\n]*\n" "prefix=\${pcfiledir}/../..\n" _text "${_text}")

View File

@ -2,10 +2,10 @@ $dist = $args[0]
$python = Split-Path((Get-Command python.exe).Path)
if (-not (Test-Path -Path 'jsdec' -PathType Container)) {
git clone https://github.com/rizinorg/jsdec.git --depth 1 --branch v0.3.1
git clone https://github.com/rizinorg/jsdec.git --depth 1 --branch master
}
cd jsdec
& meson.exe --buildtype=release -Dc_args=-DDUK_USE_DATE_NOW_WINDOWS -Djsc_folder=".." -Drizin_plugdir=lib\plugins --prefix=$dist --libdir=lib\plugins --datadir=lib\plugins p build
& meson.exe --buildtype=release -Dc_args=-DDUK_USE_DATE_NOW_WINDOWS -Djsc_folder=".." --prefix=$dist p build
ninja -C build install
$ErrorActionPreference = 'Stop'
$pathdll = "$dist\lib\plugins\core_pdd.dll"

View File

@ -7,13 +7,13 @@ SCRIPTPATH=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
cd "$SCRIPTPATH/.."
if [[ ! -d jsdec ]]; then
git clone https://github.com/rizinorg/jsdec.git --depth 1 --branch v0.3.1
git clone https://github.com/rizinorg/jsdec.git --depth 2 --branch master
fi
cd jsdec
rm -rf build
mkdir build && cd build
meson --buildtype=release -Drizin_plugdir=share/rizin/plugins -Djsc_folder="../" --libdir=share/rizin/plugins --datadir=share/rizin/plugins "$@" ../p
meson --buildtype=release -Djsc_folder="../" "$@" ../p
ninja
ninja install

View File

@ -6,6 +6,7 @@
#include <QJsonArray>
#include <QStandardPaths>
#include <QRegularExpression>
#include <rz_util/rz_path.h>
#include "common/Configuration.h"
@ -29,7 +30,7 @@ const QStringList ColorThemeWorker::rizinUnusedOptions = {
ColorThemeWorker::ColorThemeWorker(QObject *parent) : QObject(parent)
{
char *szThemes = rz_str_home(RZ_HOME_THEMES);
char *szThemes = rz_path_home_prefix(RZ_THEMES);
customRzThemesLocationPath = szThemes;
rz_mem_free(szThemes);
if (!QDir(customRzThemesLocationPath).exists()) {
@ -37,7 +38,7 @@ ColorThemeWorker::ColorThemeWorker(QObject *parent) : QObject(parent)
}
QDir currDir {
QStringLiteral("%1%2%3").arg(rz_sys_prefix(nullptr)).arg(RZ_SYS_DIR).arg(RZ_THEMES)
QStringLiteral("%1%2%3").arg(rz_path_prefix(nullptr)).arg(RZ_SYS_DIR).arg(RZ_THEMES)
};
if (currDir.exists()) {
standardRzThemesLocationPath = currDir.absolutePath();
@ -132,9 +133,9 @@ QJsonDocument ColorThemeWorker::getTheme(const QString &themeName) const
if (themeName != curr) {
RzCoreLocked core(Core());
rz_core_load_theme(core, themeName.toUtf8().constData());
rz_core_theme_load(core, themeName.toUtf8().constData());
theme = Core()->cmdj("ecj").object().toVariantMap();
rz_core_load_theme(core, curr.toUtf8().constData());
rz_core_theme_load(core, curr.toUtf8().constData());
} else {
theme = Core()->cmdj("ecj").object().toVariantMap();
}

View File

@ -530,7 +530,7 @@ void Configuration::setColorTheme(const QString &theme)
Core()->cmdRaw("ecd");
s.setValue("theme", "default");
} else {
rz_core_load_theme(Core()->core(), theme.toUtf8().constData());
rz_core_theme_load(Core()->core(), theme.toUtf8().constData());
s.setValue("theme", theme);
}

View File

@ -187,7 +187,7 @@ void CutterCore::initialize(bool loadPlugins)
#if defined(CUTTER_ENABLE_PACKAGING) && defined(Q_OS_WIN)
auto prefixBytes = prefix.absolutePath().toUtf8();
rz_sys_prefix(prefixBytes.constData());
rz_path_prefix(prefixBytes.constData());
#endif
rz_cons_new(); // initialize console
@ -225,7 +225,7 @@ void CutterCore::initialize(bool loadPlugins)
setConfig("cfg.plugins", 0);
}
if (getConfigi("cfg.plugins")) {
rz_core_loadlibs(this->core_, RZ_CORE_LOADLIBS_ALL, nullptr);
rz_core_loadlibs(this->core_, RZ_CORE_LOADLIBS_ALL);
}
// IMPLICIT rz_bin_iobind (core_->bin, core_->io);
@ -2416,7 +2416,7 @@ void CutterCore::addBreakpoint(const BreakpointDescription &config)
RzBreakpointItem *breakpoint = nullptr;
int watchpoint_prot = 0;
if (config.hw) {
watchpoint_prot = config.permission & ~(RZ_BP_PROT_EXEC);
watchpoint_prot = config.permission & ~(RZ_PERM_X);
}
auto address = config.addr;
@ -3003,7 +3003,7 @@ QList<CommentDescription> CutterCore::getAllComments(const QString &filterType)
CORE_LOCK();
QList<CommentDescription> ret;
QJsonArray commentsArray = cmdj("CCj").array();
QJsonArray commentsArray = cmdj("CClj").array();
for (const QJsonValue &value : commentsArray) {
QJsonObject commentObject = value.toObject();
@ -3153,13 +3153,16 @@ QList<SectionDescription> CutterCore::getAllSections()
section.paddr = sect->paddr;
section.size = sect->size;
section.perm = rz_str_rwx_i(sect->perm);
HtPP *digests = rz_core_bin_section_digests(core, sect, hashnames);
if (sect->size > 0) {
HtPP *digests = rz_core_bin_create_digests(core, sect->paddr, sect->size, hashnames);
if (!digests) {
continue;
}
const char *entropy = (const char *)ht_pp_find(digests, "entropy", NULL);
section.entropy = rz_str_get(entropy);
ht_pp_free(digests);
}
section.entropy = "";
sections << section;
}

View File

@ -86,9 +86,9 @@ BreakpointsDialog::BreakpointsDialog(const BreakpointDescription &breakpoint, QW
ui->breakpointCondition->setEditText(breakpoint.condition);
if (breakpoint.hw) {
ui->radioHardware->setChecked(true);
ui->hwRead->setChecked(breakpoint.permission & RZ_BP_PROT_READ);
ui->hwWrite->setChecked(breakpoint.permission & RZ_BP_PROT_WRITE);
ui->hwExecute->setChecked(breakpoint.permission & RZ_BP_PROT_EXEC);
ui->hwRead->setChecked(breakpoint.permission & RZ_PERM_R);
ui->hwWrite->setChecked(breakpoint.permission & RZ_PERM_W);
ui->hwExecute->setChecked(breakpoint.permission & RZ_PERM_X);
ui->breakpointSize->setCurrentText(QString::number(breakpoint.size));
} else {
ui->radioSoftware->setChecked(true);
@ -204,13 +204,13 @@ int BreakpointsDialog::getHwPermissions()
{
int result = 0;
if (ui->hwRead->isChecked()) {
result |= RZ_BP_PROT_READ;
result |= RZ_PERM_R;
}
if (ui->hwWrite->isChecked()) {
result |= RZ_BP_PROT_WRITE;
result |= RZ_PERM_W;
}
if (ui->hwExecute->isChecked()) {
result |= RZ_BP_PROT_EXEC;
result |= RZ_PERM_X;
}
return result;
}

View File

@ -32,13 +32,13 @@ int BreakpointModel::columnCount(const QModelIndex &) const
static QString formatHwBreakpoint(int permission)
{
char data[] = "rwx";
if ((permission & (RZ_BP_PROT_READ | RZ_BP_PROT_ACCESS)) == 0) {
if ((permission & (RZ_PERM_R | RZ_PERM_RW)) == 0) {
data[0] = '-';
}
if ((permission & (RZ_BP_PROT_WRITE | RZ_BP_PROT_ACCESS)) == 0) {
if ((permission & (RZ_PERM_W | RZ_PERM_RW)) == 0) {
data[1] = '-';
}
if ((permission & RZ_BP_PROT_EXEC) == 0) {
if ((permission & RZ_PERM_X) == 0) {
data[2] = '-';
}
return data;