From dedbabde564ed688961cdc06828e39d6ca030e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 6 Dec 2020 19:00:13 +0100 Subject: [PATCH] Add macOS Packaging in CMake (#7) --- .appveyor.yml | 2 +- cmake/BundledRizin.cmake | 17 +- dist/CMakeLists.txt | 183 +++++++++++------- dist/MacOSBundlePython.cmake.in | 20 ++ dist/MacOSSetupBundle.cmake.in | 69 +++++++ {scripts => dist}/appbundle_embed_python.sh | 0 dist/macos/Cutter.sh | 9 + .../Info.plist => dist/macos/Info.plist.in | 2 +- {src/img => dist/macos}/cutter.icns | Bin {src => dist}/macos/cutter_mac_app.png | Bin src/CMakeLists.txt | 9 +- src/Cutter.pro | 2 +- src/CutterApplication.cpp | 24 +-- src/core/Cutter.cpp | 9 +- src/macos/Cutter.sh | 8 - 15 files changed, 250 insertions(+), 104 deletions(-) create mode 100644 dist/MacOSBundlePython.cmake.in create mode 100644 dist/MacOSSetupBundle.cmake.in rename {scripts => dist}/appbundle_embed_python.sh (100%) create mode 100755 dist/macos/Cutter.sh rename src/macos/Info.plist => dist/macos/Info.plist.in (98%) rename {src/img => dist/macos}/cutter.icns (100%) rename {src => dist}/macos/cutter_mac_app.png (100%) delete mode 100755 src/macos/Cutter.sh diff --git a/.appveyor.yml b/.appveyor.yml index 3e7b9d3b..67212e6f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -50,7 +50,7 @@ build_script: -DCUTTER_ENABLE_PYTHON_BINDINGS=ON -DCUTTER_ENABLE_PACKAGING=ON -DCUTTER_PACKAGE_DEPENDENCIES=ON - -DCUTTER_PACKAGE_R2GHIDRA=ON + -DCUTTER_PACKAGE_RZ_GHIDRA=ON -DCUTTER_PACKAGE_R2DEC=OFF -DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON -DCUTTER_ENABLE_CRASH_REPORTS=ON diff --git a/cmake/BundledRizin.cmake b/cmake/BundledRizin.cmake index 92fed4d4..8694d893 100644 --- a/cmake/BundledRizin.cmake +++ b/cmake/BundledRizin.cmake @@ -42,26 +42,27 @@ else() link_directories("${RIZIN_INSTALL_DIR}/lib") endif() -set (R2_LIBS rz_core rz_config rz_cons rz_io rz_util rz_flag rz_asm rz_debug +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_anal rz_parse rz_bp rz_egg rz_reg rz_search rz_syscall rz_socket rz_magic rz_crypto) -set (R2_EXTRA_LIBS rz_main) -set (R2_BIN rz-agent rz-bin rizin rz-diff rz-find rz-gg rz-hash rz-run rz-asm rz-ax) +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) target_link_libraries(Rizin INTERFACE - ${R2_LIBS}) + ${RZ_LIBS}) target_include_directories(Rizin INTERFACE "$" "$") install(TARGETS Rizin EXPORT CutterTargets) if (APPLE) + install(DIRECTORY "${RIZIN_INSTALL_DIR}/" DESTINATION ".") elseif (WIN32) - foreach(_lib ${R2_LIBS} ${R2_EXTRA_LIBS}) - install(FILES "${RIZIN_INSTALL_DIR}/${R2_INSTALL_BINPATH}/${_lib}.dll" DESTINATION "${CMAKE_INSTALL_BINDIR}") + foreach(_lib ${RZ_LIBS} ${RZ_EXTRA_LIBS}) + install(FILES "${RIZIN_INSTALL_DIR}/${RZ_INSTALL_BINPATH}/${_lib}.dll" DESTINATION "${CMAKE_INSTALL_BINDIR}") endforeach() - foreach(_exe ${R2_BIN}) - install(FILES "${RIZIN_INSTALL_DIR}/${R2_INSTALL_BINPATH}/${_exe}.exe" DESTINATION "${CMAKE_INSTALL_BINDIR}") + foreach(_exe ${RZ_BIN}) + install(FILES "${RIZIN_INSTALL_DIR}/${RZ_INSTALL_BINPATH}/${_exe}.exe" DESTINATION "${CMAKE_INSTALL_BINDIR}") endforeach() install(DIRECTORY "${RIZIN_INSTALL_DIR}/share" DESTINATION ".") install(DIRECTORY "${RIZIN_INSTALL_DIR}/include" DESTINATION "." diff --git a/dist/CMakeLists.txt b/dist/CMakeLists.txt index 5b7fa243..1321d33e 100644 --- a/dist/CMakeLists.txt +++ b/dist/CMakeLists.txt @@ -1,69 +1,122 @@ set(CUTTER_DEPS "${CMAKE_CURRENT_SOURCE_DIR}/../cutter-deps") -if(WIN32) - set(CPACK_GENERATOR "ZIP") +unset(RZ_GHIDRA_PREFIX_PATH) - if (CUTTER_PACKAGE_DEPENDENCIES) - if (CUTTER_ENABLE_PYTHON) - if (CUTTER_ENABLE_DEPENDENCY_DOWNLOADS) - set(CPACK_INSTALL_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/WindowsBundlePython.cmake) - endif() - find_package(PythonInterp REQUIRED) - install(DIRECTORY ${CUTTER_DEPS}/pyside/lib/site-packages DESTINATION "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - install(FILES ${CUTTER_DEPS}/pyside/bin/shiboken2.abi3.dll ${CUTTER_DEPS}/pyside/bin/pyside2.abi3.dll DESTINATION .) - endif() - install(SCRIPT WindowsBundleQt.cmake) - endif() - if (CUTTER_PACKAGE_RZ_GHIDRA) - if (CUTTER_ENABLE_DEPENDENCY_DOWNLOADS) - # Currently using external project only for downloading source - # It neeeds to link against compiled cutter so for now build it using custom install script. - # That way rz-ghidra build process is the same as with any other external plugin built against - # installed Cutter. - ExternalProject_Add(rz-ghidra - GIT_REPOSITORY git@github.com:rizinorg/rz-ghidra - GIT_TAG master - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - ) - endif() - install(CODE " - execute_process( - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/rz-ghidra-prefix/src/rz-ghidra-build - RESULT_VARIABLE SCRIPT_RESULT - COMMAND \${CMAKE_COMMAND} - ../rz-ghidra - -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=\"\${CMAKE_INSTALL_PREFIX}\;\${CMAKE_INSTALL_PREFIX}/include/librz\;\${CMAKE_INSTALL_PREFIX}/include/librz/sdb\" - -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} - -DRIZIN_INSTALL_PLUGDIR=\${CMAKE_INSTALL_PREFIX}/lib/plugins - -DCUTTER_INSTALL_PLUGDIR=plugins/native - -DBUILD_CUTTER_PLUGIN=ON - -DBUILD_SLEIGH_PLUGIN=OFF - -G Ninja - ) - if (SCRIPT_RESULT) - message(FATAL_ERROR \"Failed to configure rz-ghidra\") - endif() - execute_process(WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/rz-ghidra-prefix/src/rz-ghidra-build - RESULT_VARIABLE SCRIPT_RESULT - COMMAND \${CMAKE_COMMAND} --build . --target install - ) - if (SCRIPT_RESULT) - message(FATAL_ERROR \"Failed to install rz-ghidra plugin\") - endif() - ") - endif() - if (CUTTER_PACKAGE_R2DEC AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS) - install(CODE " - set(ENV{R_ALT_SRC_DIR} 1) - set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\") - execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_r2dec.ps1\" \"\${CMAKE_INSTALL_PREFIX}\" - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE SCRIPT_RESULT) - if (SCRIPT_RESULT) - message(FATAL_ERROR \"Failed to package r2dec\") - endif() - ") - endif() +################################################ +# Windows +################################################ + +if(WIN32) + set(CPACK_GENERATOR "ZIP") + set(RIZIN_INSTALL_PLUGDIR "lib/plugins") + + if (CUTTER_PACKAGE_DEPENDENCIES) + if (CUTTER_ENABLE_PYTHON) + if (CUTTER_ENABLE_DEPENDENCY_DOWNLOADS) + set(CPACK_INSTALL_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/WindowsBundlePython.cmake) + endif() + find_package(PythonInterp REQUIRED) + install(DIRECTORY ${CUTTER_DEPS}/pyside/lib/site-packages DESTINATION "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") + install(FILES ${CUTTER_DEPS}/pyside/bin/shiboken2.abi3.dll ${CUTTER_DEPS}/pyside/bin/pyside2.abi3.dll DESTINATION .) + endif() + install(SCRIPT WindowsBundleQt.cmake) + endif() + if (CUTTER_PACKAGE_R2DEC AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS) + install(CODE " + set(ENV{R_ALT_SRC_DIR} 1) + set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\") + execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_r2dec.ps1\" \"\${CMAKE_INSTALL_PREFIX}\" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE SCRIPT_RESULT) + if (SCRIPT_RESULT) + message(FATAL_ERROR \"Failed to package r2dec\") + endif() + ") + endif() endif() + +################################################ +# macOS +################################################ + +if(APPLE) + set(CPACK_GENERATOR "Bundle") + set(CPACK_BUNDLE_NAME "Cutter") + set(ICON "Cutter") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist.in" "${CMAKE_CURRENT_BINARY_DIR}/macos/Info.plist") + set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/macos/Info.plist") + set(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/macos/cutter.icns") + + find_program(MACDEPLOYQT_PATH macdeployqt HINTS "${Qt5_DIR}/../../../bin") + if(NOT MACDEPLOYQT_PATH) + message(FATAL_ERROR "Failed to find macdeployqt") + endif() + set(CUTTER_SH_PATH "${CMAKE_CURRENT_SOURCE_DIR}/macos/Cutter.sh") + unset(ADJUST_RIZIN_LIBS) + foreach(_lib ${RZ_LIBS}) + list(APPEND ADJUST_RIZIN_LIBS "${RIZIN_INSTALL_DIR}/lib/lib${_lib}.dylib") + endforeach() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/MacOSSetupBundle.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/MacOSSetupBundle.cmake" @ONLY) + install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/MacOSSetupBundle.cmake") + + get_filename_component(QT_PREFIX "${MACDEPLOYQT_PATH}/../.." ABSOLUTE) + list(APPEND RZ_GHIDRA_PREFIX_PATH "${QT_PREFIX}") + set(RIZIN_INSTALL_PLUGDIR "share/rizin/plugins") # escaped backslash on purpose, should be evaluated later + + if(CUTTER_ENABLE_PYTHON) + set(EMBED_PYTHON_SH "${CMAKE_CURRENT_SOURCE_DIR}/appbundle_embed_python.sh") + set(PYTHON_FRAMEWORK_DIR "${CUTTER_DEPS}/python/Python.framework") + set(PYSIDE_PREFIX "${CUTTER_DEPS}/pyside") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/MacOSBundlePython.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/MacOSBundlePython.cmake" @ONLY) + install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/MacOSBundlePython.cmake") + endif() +endif() + +################################################ +# rz-ghidra +################################################ + +if(CUTTER_PACKAGE_RZ_GHIDRA) + if(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS) + # Currently using external project only for downloading source + # It neeeds to link against compiled cutter so for now build it using custom install script. + # That way rz-ghidra build process is the same as with any other external plugin built against + # installed Cutter. + ExternalProject_Add(rz-ghidra + GIT_REPOSITORY git@github.com:rizinorg/rz-ghidra + GIT_TAG master + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) + endif() + install(CODE " + execute_process( + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/rz-ghidra-prefix/src/rz-ghidra-build + RESULT_VARIABLE SCRIPT_RESULT + COMMAND \${CMAKE_COMMAND} + ../rz-ghidra + -DCMAKE_BUILD_TYPE=Release + \"-DCMAKE_PREFIX_PATH=\${CMAKE_INSTALL_PREFIX};\${CMAKE_INSTALL_PREFIX}/include/librz;\${CMAKE_INSTALL_PREFIX}/include/librz/sdb;${RZ_GHIDRA_PREFIX_PATH}\" + -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} + \"-DRIZIN_INSTALL_PLUGDIR=\${CMAKE_INSTALL_PREFIX}/${RIZIN_INSTALL_PLUGDIR}\" + -DCUTTER_INSTALL_PLUGDIR=plugins/native + -DBUILD_CUTTER_PLUGIN=ON + -DBUILD_SLEIGH_PLUGIN=OFF + -G Ninja + ) + if (SCRIPT_RESULT) + message(FATAL_ERROR \"Failed to configure rz-ghidra\") + endif() + execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/rz-ghidra-prefix/src/rz-ghidra-build + RESULT_VARIABLE SCRIPT_RESULT + COMMAND \${CMAKE_COMMAND} --build . --target install + ) + if (SCRIPT_RESULT) + message(FATAL_ERROR \"Failed to install rz-ghidra plugin\") + endif() + ") +endif() + include(CPack) diff --git a/dist/MacOSBundlePython.cmake.in b/dist/MacOSBundlePython.cmake.in new file mode 100644 index 00000000..09ddb5fe --- /dev/null +++ b/dist/MacOSBundlePython.cmake.in @@ -0,0 +1,20 @@ + +set(EMBED_PYTHON_SH "@EMBED_PYTHON_SH@") +set(PYTHON_FRAMEWORK_DIR "@PYTHON_FRAMEWORK_DIR@") +set(PYSIDE_PREFIX "@PYSIDE_PREFIX@") + +get_filename_component(BUNDLE_PATH "${CMAKE_INSTALL_PREFIX}/../.." ABSOLUTE) + +set(ENV{PKG_CONFIG_PATH} "${PYSIDE_PREFIX}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") + +# TODO: instead of calling a shellscript, implement the whole thing in cmake +execute_process(COMMAND + "${EMBED_PYTHON_SH}" + "${PYTHON_FRAMEWORK_DIR}" + "${BUNDLE_PATH}" + "${BUNDLE_PATH}/MacOS/Cutter.bin" + RESULT_VARIABLE SCRIPT_RESULT) +if(SCRIPT_RESULT) + message(FATAL_ERROR "Failed to bundle python") +endif() + diff --git a/dist/MacOSSetupBundle.cmake.in b/dist/MacOSSetupBundle.cmake.in new file mode 100644 index 00000000..ed2d6c71 --- /dev/null +++ b/dist/MacOSSetupBundle.cmake.in @@ -0,0 +1,69 @@ + +set(MACDEPLOYQT_PATH "@MACDEPLOYQT_PATH@") +set(INFO_PLIST_PATH "@CPACK_BUNDLE_PLIST@") +set(CUTTER_SH_PATH "@CUTTER_SH_PATH@") +set(ADJUST_RIZIN_LIBS "@ADJUST_RIZIN_LIBS@") + +macro(run_or_die) + execute_process(${ARGV} RESULT_VARIABLE PROC_RESULT) + if(PROC_RESULT) + message(FATAL_ERROR "Failed to run ${ARGV}") + endif() +endmacro() + +get_filename_component(BUNDLE_PATH "${CMAKE_INSTALL_PREFIX}/../.." ABSOLUTE) +set(EXECUTABLE_DIR "${BUNDLE_PATH}/Contents/MacOS") +file(MAKE_DIRECTORY "${EXECUTABLE_DIR}") +# Move the executable from Resources/bin/Cutter to MacOS/Cutter +# macdeployqt can't handle anything else +file(RENAME "${CMAKE_INSTALL_PREFIX}/bin/Cutter" "${EXECUTABLE_DIR}/Cutter") +# Make a symlink from the original location so CutterConfig.cmake won't be broken +run_or_die(COMMAND ${CMAKE_COMMAND} -E create_symlink "../../MacOS/Cutter.bin" "${CMAKE_INSTALL_PREFIX}/bin/Cutter") + +# Copying the Info.plist will be done later again by CPack but we need it a bit earlier +# so macdeployqt has enough info. +file(COPY "${INFO_PLIST_PATH}" DESTINATION "${BUNDLE_PATH}/Contents") + +# macdeployqt would put the rz libraries into Contents/Frameworks by default, but we want to have them +# only in the prefix, so we fix the paths manually. +foreach(_lib ${ADJUST_RIZIN_LIBS}) + get_filename_component(_lib "${_lib}" REALPATH) + get_filename_component(_name "${_lib}" NAME) + run_or_die(COMMAND install_name_tool + -change "${_lib}" "@rpath/${_name}" + "${EXECUTABLE_DIR}/Cutter") + # Fix every lib for every lib too + foreach(_lib2 ${ADJUST_RIZIN_LIBS}) + get_filename_component(_lib2 "${_lib2}" REALPATH) + get_filename_component(_name2 "${_lib2}" NAME) + run_or_die(COMMAND install_name_tool + -change "${_lib2}" "@rpath/${_name2}" + "${CMAKE_INSTALL_PREFIX}/lib/${_name}") + endforeach() +endforeach() + +# Add rpaths because macdeployqt fails to do that properly +run_or_die(COMMAND install_name_tool + -add_rpath "@executable_path/../Frameworks" + "${EXECUTABLE_DIR}/Cutter") +run_or_die(COMMAND install_name_tool + -add_rpath "@executable_path/../Resources/lib" + "${EXECUTABLE_DIR}/Cutter") + +set(MACDEPLOYQT_COMMAND "${MACDEPLOYQT_PATH}" "${BUNDLE_PATH}" "-libpath=${CMAKE_INSTALL_PREFIX}/lib") +message("Running macdeployqt \"${MACDEPLOYQT_COMMAND}\"") +run_or_die(COMMAND ${MACDEPLOYQT_COMMAND}) +run_or_die(COMMAND ${MACDEPLOYQT_COMMAND}) + +# Clean up the mess that macdeployqt made (duplicate rz libs, we only want the ones in the prefix) +foreach(_lib ${ADJUST_RIZIN_LIBS}) + get_filename_component(_lib "${_lib}" REALPATH) + get_filename_component(_name "${_lib}" NAME) + file(REMOVE "${BUNDLE_PATH}/Contents/Frameworks/${_name}") +endforeach() + +# Replace main executable by Cutter.sh +file(RENAME "${EXECUTABLE_DIR}/Cutter" "${EXECUTABLE_DIR}/Cutter.bin") +file(COPY "${CUTTER_SH_PATH}" DESTINATION "${EXECUTABLE_DIR}") +file(RENAME "${EXECUTABLE_DIR}/Cutter.sh" "${EXECUTABLE_DIR}/Cutter") + diff --git a/scripts/appbundle_embed_python.sh b/dist/appbundle_embed_python.sh similarity index 100% rename from scripts/appbundle_embed_python.sh rename to dist/appbundle_embed_python.sh diff --git a/dist/macos/Cutter.sh b/dist/macos/Cutter.sh new file mode 100755 index 00000000..8a536594 --- /dev/null +++ b/dist/macos/Cutter.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Cutter Launch Script for macOS 🥞" + +HERE=$(dirname "$0") +PREFIX=$HERE/../Resources +export DYLD_LIBRARY_PATH="$PREFIX/lib" +export DYLD_FRAMEWORK_PATH="$PREFIX/lib" +"$HERE/Cutter.bin" "$@" diff --git a/src/macos/Info.plist b/dist/macos/Info.plist.in similarity index 98% rename from src/macos/Info.plist rename to dist/macos/Info.plist.in index d8a1b377..632c03db 100644 --- a/src/macos/Info.plist +++ b/dist/macos/Info.plist.in @@ -15,7 +15,7 @@ CFBundleIconFile @ICON@ CFBundleIdentifier - org.radare.cutter + re.rizin.cutter CFBundlePackageType APPL NSPrincipalClass diff --git a/src/img/cutter.icns b/dist/macos/cutter.icns similarity index 100% rename from src/img/cutter.icns rename to dist/macos/cutter.icns diff --git a/src/macos/cutter_mac_app.png b/dist/macos/cutter_mac_app.png similarity index 100% rename from src/macos/cutter_mac_app.png rename to dist/macos/cutter_mac_app.png diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 015108b9..0c056094 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,13 +47,12 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" endif() -add_executable(Cutter MACOSX_BUNDLE ${UI_FILES} ${QRC_FILES} ${PLATFORM_RESOURCES} ${SOURCE_FILES} ${HEADER_FILES} ${BINDINGS_SOURCE}) +add_executable(Cutter ${UI_FILES} ${QRC_FILES} ${PLATFORM_RESOURCES} ${SOURCE_FILES} ${HEADER_FILES} ${BINDINGS_SOURCE}) set_target_properties(Cutter PROPERTIES RUNTIME_OUTPUT_DIRECTORY .. PDB_OUTPUT_DIRECTORY .. ENABLE_EXPORTS ON - CXX_VISIBILITY_PRESET hidden - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist") + CXX_VISIBILITY_PRESET hidden) target_compile_definitions(Cutter PRIVATE CUTTER_SOURCE_BUILD) set(CUTTER_INCLUDE_DIRECTORIES core widgets common plugins menus .) @@ -146,6 +145,10 @@ if (CUTTER_PACKAGE_R2DEC) target_compile_definitions(Cutter PRIVATE CUTTER_APPVEYOR_R2DEC) endif() +if(APPLE AND CUTTER_ENABLE_PACKAGING AND CUTTER_USE_BUNDLED_RIZIN) + target_compile_definitions(Cutter PRIVATE MACOS_RZ_BUNDLED) +endif() + include(Translations) # Install files diff --git a/src/Cutter.pro b/src/Cutter.pro index f0af400a..71ec2535 100644 --- a/src/Cutter.pro +++ b/src/Cutter.pro @@ -280,7 +280,7 @@ QMAKE_CXXFLAGS += -g macx:CUTTER_BUNDLE_R2_APPBUNDLE { message("Using r2 rom AppBundle") - DEFINES += MACOS_R2_BUNDLED + DEFINES += MACOS_RZ_BUNDLED } CUTTER_APPVEYOR_R2DEC { diff --git a/src/CutterApplication.cpp b/src/CutterApplication.cpp index 5fbf2de8..ffbd787d 100644 --- a/src/CutterApplication.cpp +++ b/src/CutterApplication.cpp @@ -74,17 +74,17 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc std::exit(1); } - // Check r2 version - QString r2version = rz_core_version(); + // Check rizin version + QString rzversion = rz_core_version(); QString localVersion = "" RZ_GITTAP; - if (r2version != localVersion) { + if (rzversion != localVersion) { QMessageBox msg; msg.setIcon(QMessageBox::Critical); msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msg.setWindowTitle(QObject::tr("Version mismatch!")); msg.setText(QString( - QObject::tr("The version used to compile Cutter (%1) does not match the binary version of radare2 (%2). This could result in unexpected behaviour. Are you sure you want to continue?")).arg( - localVersion, r2version)); + QObject::tr("The version used to compile Cutter (%1) does not match the binary version of rizin (%2). This could result in unexpected behaviour. Are you sure you want to continue?")).arg( + localVersion, rzversion)); if (msg.exec() == QMessageBox::No) { std::exit(1); } @@ -151,11 +151,11 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc appdir.cdUp(); // appdir auto sleighHome = appdir; - sleighHome.cd("share/radare2/plugins/rz_ghidra_sleigh"); // appdir/share/radare2/plugins/rz_ghidra_sleigh + sleighHome.cd("share/rizin/plugins/rz_ghidra_sleigh"); // appdir/share/rizin/plugins/rz_ghidra_sleigh Core()->setConfig("ghidra.sleighhome", sleighHome.absolutePath()); auto r2decHome = appdir; - r2decHome.cd("share/radare2/plugins/r2dec-js"); // appdir/share/radare2/plugins/r2dec-js + r2decHome.cd("share/rizin/plugins/r2dec-js"); // appdir/share/rizin/plugins/r2dec-js qputenv("R2DEC_HOME", r2decHome.absolutePath().toLocal8Bit()); } #endif @@ -164,14 +164,14 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc { auto rzprefix = QDir(QCoreApplication::applicationDirPath()); // Contents/MacOS rzprefix.cdUp(); // Contents - rzprefix.cd("Resources/r2"); // Contents/Resources/r2 + rzprefix.cd("Resources"); // Contents/Resources/r2 auto sleighHome = rzprefix; - sleighHome.cd("share/radare2/plugins/rz_ghidra_sleigh"); // Contents/Resources/r2/share/radare2/plugins/rz_ghidra_sleigh + sleighHome.cd("share/rizin/plugins/rz_ghidra_sleigh"); // Contents/Resources/r2/share/rizin/plugins/rz_ghidra_sleigh Core()->setConfig("ghidra.sleighhome", sleighHome.absolutePath()); auto r2decHome = rzprefix; - r2decHome.cd("share/radare2/plugins/r2dec-js"); // Contents/Resources/r2/share/radare2/plugins/r2dec-js + r2decHome.cd("share/rizin/plugins/r2dec-js"); // Contents/Resources/r2/share/rizin/plugins/r2dec-js qputenv("R2DEC_HOME", r2decHome.absolutePath().toLocal8Bit()); } #endif @@ -299,7 +299,7 @@ bool CutterApplication::parseCommandLineOptions() QCommandLineParser cmd_parser; cmd_parser.setApplicationDescription( - QObject::tr("A Qt and C++ GUI for radare2 reverse engineering framework")); + QObject::tr("A Qt and C++ GUI for rizin reverse engineering framework")); cmd_parser.addHelpOption(); cmd_parser.addVersionOption(); cmd_parser.addPositionalArgument("filename", QObject::tr("Filename to open.")); @@ -352,7 +352,7 @@ bool CutterApplication::parseCommandLineOptions() cmd_parser.addOption(disableCutterPlugins); QCommandLineOption disableR2Plugins("no-r2-plugins", - QObject::tr("Do not load radare2 plugins")); + QObject::tr("Do not load rizin plugins")); cmd_parser.addOption(disableR2Plugins); cmd_parser.process(*this); diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 3f72e7a2..bb0ec7f8 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -189,27 +189,26 @@ void CutterCore::initialize(bool loadPlugins) rz_event_hook(core_->anal->ev, RZ_EVENT_ALL, cutterREventCallback, this); -#if defined(APPIMAGE) || defined(MACOS_R2_BUNDLED) +#if defined(APPIMAGE) || defined(MACOS_RZ_BUNDLED) auto prefix = QDir(QCoreApplication::applicationDirPath()); #ifdef APPIMAGE // Executable is in appdir/bin prefix.cdUp(); qInfo() << "Setting r2 prefix =" << prefix.absolutePath() << " for AppImage."; -#else // MACOS_R2_BUNDLED +#else // MACOS_RZ_BUNDLED // Executable is in Contents/MacOS, prefix is Contents/Resources/r2 prefix.cdUp(); prefix.cd("Resources"); - prefix.cd("r2"); qInfo() << "Setting r2 prefix =" << prefix.absolutePath() << " for macOS Application Bundle."; #endif setConfig("dir.prefix", prefix.absolutePath()); auto pluginsDir = prefix; - if (pluginsDir.cd("share/radare2/plugins")) { + if (pluginsDir.cd("share/rizin/plugins")) { qInfo() << "Setting r2 plugins dir =" << pluginsDir.absolutePath(); setConfig("dir.plugins", pluginsDir.absolutePath()); } else { - qInfo() << "r2 plugins dir =" << pluginsDir.absolutePath() << "does not exist!"; + qInfo() << "r2 plugins dir under" << pluginsDir.absolutePath() << "does not exist!"; } #endif diff --git a/src/macos/Cutter.sh b/src/macos/Cutter.sh deleted file mode 100755 index 2a6aecc8..00000000 --- a/src/macos/Cutter.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -echo "Cutter Launch Script for macOS 🥞" - -EXECDIR=$(dirname "$0") -export DYLD_LIBRARY_PATH="$EXECDIR/../Frameworks" -export DYLD_FRAMEWORK_PATH="$EXECDIR/../Frameworks" -"$EXECDIR/Cutter.bin" "$@"