mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
Add macOS Packaging in CMake (#7)
This commit is contained in:
parent
68e2d603a7
commit
dedbabde56
@ -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
|
||||
|
@ -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
|
||||
"$<BUILD_INTERFACE:${Rizin_INCLUDE_DIRS}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/librz>")
|
||||
|
||||
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 "."
|
||||
|
183
dist/CMakeLists.txt
vendored
183
dist/CMakeLists.txt
vendored
@ -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)
|
||||
|
20
dist/MacOSBundlePython.cmake.in
vendored
Normal file
20
dist/MacOSBundlePython.cmake.in
vendored
Normal file
@ -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()
|
||||
|
69
dist/MacOSSetupBundle.cmake.in
vendored
Normal file
69
dist/MacOSSetupBundle.cmake.in
vendored
Normal file
@ -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")
|
||||
|
9
dist/macos/Cutter.sh
vendored
Executable file
9
dist/macos/Cutter.sh
vendored
Executable file
@ -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" "$@"
|
@ -15,7 +15,7 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>@ICON@</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.radare.cutter</string>
|
||||
<string>re.rizin.cutter</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>NSPrincipalClass</key>
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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" "$@"
|
Loading…
Reference in New Issue
Block a user