From 3166843dff30f4dd8e77b0836ce481bb54b67e51 Mon Sep 17 00:00:00 2001 From: Giovanni <561184+wargio@users.noreply.github.com> Date: Tue, 11 Apr 2023 11:35:52 +0800 Subject: [PATCH] Add rz-silhouette to cutter builds (#3161) --- .github/workflows/ci.yml | 3 +++ .woodpecker/macos-arm64.yml | 1 + CMakeLists.txt | 2 ++ dist/CMakeLists.txt | 24 ++++++++++++++++++++++++ dist/bundle_rz_silhouette.ps1 | 17 +++++++++++++++++ scripts/rz-silhouette.sh | 17 +++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 dist/bundle_rz_silhouette.ps1 create mode 100755 scripts/rz-silhouette.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 757189d2..983d2b5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,6 +155,7 @@ jobs: -DCUTTER_PACKAGE_JSDEC=ON \ -DCUTTER_PACKAGE_RZ_LIBSWIFT=ON \ -DCUTTER_PACKAGE_RZ_LIBYARA=ON \ + -DCUTTER_PACKAGE_RZ_SILHOUETTE=ON \ -DCMAKE_INSTALL_PREFIX=appdir/usr \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \ .. @@ -227,6 +228,7 @@ jobs: -DCUTTER_PACKAGE_JSDEC=ON \ -DCUTTER_PACKAGE_RZ_LIBSWIFT=ON \ -DCUTTER_PACKAGE_RZ_LIBYARA=ON \ + -DCUTTER_PACKAGE_RZ_SILHOUETTE=ON \ -DCPACK_PACKAGE_FILE_NAME="$PACKAGE_NAME" \ -DCPACK_BUNDLE_APPLE_CERT_APP="-" \ .. && \ @@ -266,6 +268,7 @@ jobs: -DCUTTER_PACKAGE_RZ_GHIDRA=ON ^ -DCUTTER_PACKAGE_RZ_LIBSWIFT=ON ^ -DCUTTER_PACKAGE_RZ_LIBYARA=ON ^ + -DCUTTER_PACKAGE_RZ_SILHOUETTE=ON ^ -DCUTTER_PACKAGE_JSDEC=ON ^ -DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON ^ -DCMAKE_PREFIX_PATH="%CUTTER_DEPS%\pyside" ^ diff --git a/.woodpecker/macos-arm64.yml b/.woodpecker/macos-arm64.yml index bbff7e68..e2690181 100644 --- a/.woodpecker/macos-arm64.yml +++ b/.woodpecker/macos-arm64.yml @@ -28,6 +28,7 @@ pipeline: -DCUTTER_PACKAGE_JSDEC=ON -DCUTTER_PACKAGE_RZ_LIBSWIFT=ON -DCUTTER_PACKAGE_RZ_LIBYARA=ON + -DCUTTER_PACKAGE_RZ_SILHOUETTE=ON -DCPACK_PACKAGE_FILE_NAME="$$PACKAGE_NAME" -DCPACK_BUNDLE_APPLE_CERT_APP="-" - ninja -C build diff --git a/CMakeLists.txt b/CMakeLists.txt index 8645b267..60cd6c53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ option(CUTTER_PACKAGE_DEPENDENCIES "During install step include the third party 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_RZ_LIBYARA "Compile and install rz-libyara during the install step." OFF) +option(CUTTER_PACKAGE_RZ_SILHOUETTE "Compile and install rz-silhouette during the install step." OFF) option(CUTTER_PACKAGE_JSDEC "Compile and install jsdec during install step." OFF) OPTION(CUTTER_QT6 "Use QT6" OFF) @@ -161,6 +162,7 @@ message(STATUS "- Package Dependencies: ${CUTTER_PACKAGE_DEPENDENCIES}") message(STATUS "- Package RzGhidra: ${CUTTER_PACKAGE_RZ_GHIDRA}") message(STATUS "- Package RzLibSwift: ${CUTTER_PACKAGE_RZ_LIBSWIFT}") message(STATUS "- Package RzLibYara: ${CUTTER_PACKAGE_RZ_LIBYARA}") +message(STATUS "- Package RzSilhouette: ${CUTTER_PACKAGE_RZ_SILHOUETTE}") message(STATUS "- Package JSDec: ${CUTTER_PACKAGE_JSDEC}") message(STATUS "- QT6: ${CUTTER_QT6}") message(STATUS "") diff --git a/dist/CMakeLists.txt b/dist/CMakeLists.txt index 956fbd18..822942fd 100644 --- a/dist/CMakeLists.txt +++ b/dist/CMakeLists.txt @@ -59,6 +59,18 @@ if(WIN32) endif() ") endif() + if (CUTTER_PACKAGE_RZ_SILHOUETTE 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_silhouette.ps1\" \"\${CMAKE_INSTALL_PREFIX}\" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE SCRIPT_RESULT) + if (SCRIPT_RESULT) + message(FATAL_ERROR \"Failed to package rz-silhouette (returned \${SCRIPT_RESULT})\") + endif() + ") + endif() endif() ################################################ @@ -150,6 +162,18 @@ if(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS AND (NOT WIN32)) endif() ") endif() + if (CUTTER_PACKAGE_RZ_SILHOUETTE) + install(CODE " + execute_process(COMMAND + \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/rz-silhouette.sh\" + \"\${CMAKE_INSTALL_PREFIX}\" \"${YARA_PLUGIN_OPTIONS}\" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE SCRIPT_RESULT) + if (SCRIPT_RESULT) + message(FATAL_ERROR \"Failed to package rz-silhouette (returned \${SCRIPT_RESULT})\") + endif() + ") + endif() endif() ################################################ diff --git a/dist/bundle_rz_silhouette.ps1 b/dist/bundle_rz_silhouette.ps1 new file mode 100644 index 00000000..4aeeb2b9 --- /dev/null +++ b/dist/bundle_rz_silhouette.ps1 @@ -0,0 +1,17 @@ +$dist = $args[0] +$cmake_opts = $args[1] +$python = Split-Path((Get-Command python.exe).Path) + +if (-not (Test-Path -Path 'rz-silhouette' -PathType Container)) { + git clone https://github.com/rizinorg/rz-silhouette.git --depth 1 rz-silhouette +} +cd rz-silhouette +& meson.exe --buildtype=release --prefix=$dist build +ninja -C build install +$pathdll = "$dist/lib/plugins/rz_silhouette.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/rz_silhouette.lib diff --git a/scripts/rz-silhouette.sh b/scripts/rz-silhouette.sh new file mode 100755 index 00000000..f2f595e5 --- /dev/null +++ b/scripts/rz-silhouette.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +SCRIPTPATH=$(realpath "$(dirname "${BASH_SOURCE[0]}")") +INSTALL_PREFIX="$1" +EXTRA_CMAKE_OPTS="$2" + +cd "$SCRIPTPATH/.." + +if [[ ! -d rz-silhouette ]]; then + git clone https://github.com/rizinorg/rz-silhouette.git --depth 1 rz-silhouette +fi + +cd rz-silhouette + +meson --buildtype=release --pkg-config-path="$INSTALL_PREFIX/lib/pkgconfig" --prefix="$INSTALL_PREFIX" build +ninja -C build install