Adjust prefix handling due to rizin portable mode changes. (#2671)

This commit is contained in:
karliss 2021-04-20 06:34:52 +03:00 committed by GitHub
parent 1f129618e0
commit 4328f5df5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 10 deletions

2
.gitignore vendored
View File

@ -83,7 +83,7 @@ docs/source/_build
!/.vscode/extensions.json !/.vscode/extensions.json
# Visual Studio CMake # Visual Studio CMake
src/out /out
.vs .vs
# cutter-deps # cutter-deps

View File

@ -14,6 +14,10 @@ else()
set(MESON_OPTIONS "--prefix=${RIZIN_INSTALL_DIR}" --libdir=lib) set(MESON_OPTIONS "--prefix=${RIZIN_INSTALL_DIR}" --libdir=lib)
endif() endif()
if (CUTTER_ENABLE_PACKAGING)
list(APPEND MESON_OPTIONS "-Dportable=true")
endif()
find_program(MESON meson) find_program(MESON meson)
if(NOT MESON) if(NOT MESON)
message(FATAL_ERROR "Failed to find meson, which is required to build bundled rizin") message(FATAL_ERROR "Failed to find meson, which is required to build bundled rizin")

2
dist/CMakeLists.txt vendored
View File

@ -22,7 +22,7 @@ if(WIN32)
endif() endif()
if (CUTTER_PACKAGE_JSDEC AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS) if (CUTTER_PACKAGE_JSDEC AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
install(CODE " install(CODE "
set(ENV{RZ_ALT_SRC_DIR} 1) set(ENV{RZ_PREFIX} \"\${CMAKE_INSTALL_PREFIX}\")
set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\") set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\")
execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_jsdec.ps1\" \"\${CMAKE_INSTALL_PREFIX}\" execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_jsdec.ps1\" \"\${CMAKE_INSTALL_PREFIX}\"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}

View File

@ -522,6 +522,10 @@ if(APPLE AND CUTTER_ENABLE_PACKAGING AND CUTTER_USE_BUNDLED_RIZIN)
target_compile_definitions(Cutter PRIVATE MACOS_RZ_BUNDLED) target_compile_definitions(Cutter PRIVATE MACOS_RZ_BUNDLED)
endif() endif()
if(CUTTER_ENABLE_PACKAGING)
target_compile_definitions(Cutter PRIVATE CUTTER_ENABLE_PACKAGING)
endif()
include(Translations) include(Translations)
# Install files # Install files

View File

@ -109,11 +109,6 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
Python()->initialize(); Python()->initialize();
#endif #endif
#ifdef Q_OS_WIN
// Redefine rz_sys_prefix() behaviour
qputenv("RZ_ALT_SRC_DIR", "1");
#endif
Core()->initialize(clOptions.enableRizinPlugins); Core()->initialize(clOptions.enableRizinPlugins);
Core()->setSettings(); Core()->setSettings();
Config()->loadInitial(); Config()->loadInitial();
@ -193,7 +188,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
} }
#endif #endif
#ifdef Q_OS_WIN #if defined(Q_OS_WIN) && defined(CUTTER_ENABLE_PACKAGING)
{ {
# ifdef CUTTER_BUNDLE_JSDEC # ifdef CUTTER_BUNDLE_JSDEC
qputenv("JSDEC_HOME", "lib\\plugins\\jsdec"); qputenv("JSDEC_HOME", "lib\\plugins\\jsdec");

View File

@ -183,6 +183,13 @@ CutterCore *CutterCore::instance()
void CutterCore::initialize(bool loadPlugins) void CutterCore::initialize(bool loadPlugins)
{ {
auto prefix = QDir(QCoreApplication::applicationDirPath());
#if defined(CUTTER_ENABLE_PACKAGING) && defined(Q_OS_WIN)
auto prefixBytes = prefix.absolutePath().toUtf8();
rz_sys_prefix(prefixBytes.constData());
#endif
rz_cons_new(); // initialize console rz_cons_new(); // initialize console
core_ = rz_core_new(); core_ = rz_core_new();
rz_core_task_sync_begin(&core_->tasks); rz_core_task_sync_begin(&core_->tasks);
@ -192,7 +199,6 @@ void CutterCore::initialize(bool loadPlugins)
rz_event_hook(core_->analysis->ev, RZ_EVENT_ALL, cutterREventCallback, this); rz_event_hook(core_->analysis->ev, RZ_EVENT_ALL, cutterREventCallback, this);
#if defined(APPIMAGE) || defined(MACOS_RZ_BUNDLED) #if defined(APPIMAGE) || defined(MACOS_RZ_BUNDLED)
auto prefix = QDir(QCoreApplication::applicationDirPath());
# ifdef APPIMAGE # ifdef APPIMAGE
// Executable is in appdir/bin // Executable is in appdir/bin
prefix.cdUp(); prefix.cdUp();
@ -203,8 +209,8 @@ void CutterCore::initialize(bool loadPlugins)
prefix.cd("Resources"); prefix.cd("Resources");
qInfo() << "Setting Rizin prefix =" << prefix.absolutePath() qInfo() << "Setting Rizin prefix =" << prefix.absolutePath()
<< " for macOS Application Bundle."; << " for macOS Application Bundle.";
# endif
setConfig("dir.prefix", prefix.absolutePath()); setConfig("dir.prefix", prefix.absolutePath());
# endif
auto pluginsDir = prefix; auto pluginsDir = prefix;
if (pluginsDir.cd("share/rizin/plugins")) { if (pluginsDir.cd("share/rizin/plugins")) {