Enable support for building rz-libswift on cutter (#2841)

This commit is contained in:
Giovanni 2022-01-15 21:02:01 +01:00 committed by GitHub
parent 239343bb20
commit 75c334596e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 1 deletions

View File

@ -121,6 +121,7 @@ jobs:
-DCUTTER_ENABLE_PACKAGING=ON \ -DCUTTER_ENABLE_PACKAGING=ON \
-DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON \ -DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON \
-DCUTTER_PACKAGE_RZ_GHIDRA=ON \ -DCUTTER_PACKAGE_RZ_GHIDRA=ON \
-DCUTTER_PACKAGE_RZ_LIBSWIFT=ON \
-DCMAKE_INSTALL_PREFIX=appdir/usr \ -DCMAKE_INSTALL_PREFIX=appdir/usr \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
.. ..
@ -187,6 +188,7 @@ jobs:
-DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON \ -DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON \
-DCUTTER_PACKAGE_RZ_GHIDRA=ON \ -DCUTTER_PACKAGE_RZ_GHIDRA=ON \
-DCUTTER_PACKAGE_JSDEC=ON \ -DCUTTER_PACKAGE_JSDEC=ON \
-DCUTTER_PACKAGE_RZ_LIBSWIFT=ON \
-DCPACK_PACKAGE_FILE_NAME="$PACKAGE_NAME" \ -DCPACK_PACKAGE_FILE_NAME="$PACKAGE_NAME" \
-DCMAKE_FRAMEWORK_PATH="$BREAKPAD_FRAMEWORK_DIR" \ -DCMAKE_FRAMEWORK_PATH="$BREAKPAD_FRAMEWORK_DIR" \
-DCPACK_BUNDLE_APPLE_CERT_APP="-" \ -DCPACK_BUNDLE_APPLE_CERT_APP="-" \
@ -224,6 +226,7 @@ jobs:
-DCUTTER_ENABLE_PACKAGING=ON ^ -DCUTTER_ENABLE_PACKAGING=ON ^
-DCUTTER_PACKAGE_DEPENDENCIES=ON ^ -DCUTTER_PACKAGE_DEPENDENCIES=ON ^
-DCUTTER_PACKAGE_RZ_GHIDRA=ON ^ -DCUTTER_PACKAGE_RZ_GHIDRA=ON ^
-DCUTTER_PACKAGE_RZ_LIBSWIFT=ON ^
-DCUTTER_PACKAGE_JSDEC=ON ^ -DCUTTER_PACKAGE_JSDEC=ON ^
-DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON ^ -DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON ^
-DCUTTER_ENABLE_CRASH_REPORTS=ON ^ -DCUTTER_ENABLE_CRASH_REPORTS=ON ^

View File

@ -25,6 +25,7 @@ option(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS "Enable downloading of dependencies. S
option(CUTTER_ENABLE_PACKAGING "Enable building platform-specific packages for distributing" OFF) option(CUTTER_ENABLE_PACKAGING "Enable building platform-specific packages for distributing" OFF)
option(CUTTER_PACKAGE_DEPENDENCIES "During install step include the third party dependencies." OFF) option(CUTTER_PACKAGE_DEPENDENCIES "During install step include the third party dependencies." OFF)
option(CUTTER_PACKAGE_RZ_GHIDRA "Compile and install rz-ghidra during install step." OFF) option(CUTTER_PACKAGE_RZ_GHIDRA "Compile and install rz-ghidra during install step." OFF)
option(CUTTER_PACKAGE_RZ_LIBSWIFT, "Compile and install rz-libswift demangler during the install step." OFF)
option(CUTTER_PACKAGE_JSDEC "Compile and install jsdec during install step." OFF) option(CUTTER_PACKAGE_JSDEC "Compile and install jsdec during install step." OFF)
OPTION(CUTTER_QT6 "Use QT6" OFF) OPTION(CUTTER_QT6 "Use QT6" OFF)

23
dist/CMakeLists.txt vendored
View File

@ -32,6 +32,18 @@ if(WIN32)
endif() endif()
") ")
endif() endif()
if (CUTTER_PACKAGE_RZ_LIBSWIFT AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
install(CODE "
set(ENV{RZ_PREFIX} \"\${CMAKE_INSTALL_PREFIX}\")
set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\")
execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_rz_libswift.ps1\" \"\${CMAKE_INSTALL_PREFIX}\"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE SCRIPT_RESULT)
if (SCRIPT_RESULT)
message(FATAL_ERROR \"Failed to package rz-libswift\")
endif()
")
endif()
endif() endif()
################################################ ################################################
@ -93,6 +105,17 @@ if(APPLE)
") ")
endif() endif()
if (CUTTER_PACKAGE_RZ_LIBSWIFT AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
install(CODE "
execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/rz-libswift.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)
message(FATAL_ERROR \"Failed to package rz-libswift\")
endif()
")
endif()
endif() endif()
################################################ ################################################

16
dist/bundle_rz_libswift.ps1 vendored Normal file
View File

@ -0,0 +1,16 @@
$dist = $args[0]
$python = Split-Path((Get-Command python.exe).Path)
if (-not (Test-Path -Path 'libswift' -PathType Container)) {
git clone https://github.com/rizinorg/rz-libswift.git --depth 1 libswift
}
cd libswift
& meson.exe --buildtype=release --prefix=$dist build
ninja -C build install
$pathdll = "$dist/lib/plugins/swift.dll"
if(![System.IO.File]::Exists($pathdll)) {
type build/meson-logs/meson-log.txt
ls "$dist/lib/plugins/"
throw (New-Object System.IO.FileNotFoundException("File not found: $pathdll", $pathdll))
}
Remove-Item -Recurse -Force $dist/lib/plugins/libswift.lib

19
scripts/rz-libswift.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -e
SCRIPTPATH=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
cd "$SCRIPTPATH/.."
if [[ ! -d libswift ]]; then
git clone https://github.com/rizinorg/rz-libswift.git --depth 1 libswift
fi
cd libswift
rm -rf build || sleep 0
mkdir build && cd build
meson --buildtype=release "$@" ..
ninja
ninja install

View File

@ -564,7 +564,7 @@ void DecompilerContextMenu::updateTargetMenuActions()
RzCoreLocked core = Core()->core(); RzCoreLocked core = Core()->core();
if (isReference()) { if (isReference()) {
QString name; QString name;
QMenu *menu; QMenu *menu = nullptr;
if (annotationHere->type == RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE if (annotationHere->type == RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE
|| annotationHere->type == RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE) { || annotationHere->type == RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE) {
menu = mainWindow->createShowInMenu(this, annotationHere->reference.offset, menu = mainWindow->createShowInMenu(this, annotationHere->reference.offset,