Use cutter-deps on macOS (#1238)

* Update deps scripts for macOS

* Update deps

* Update appbundle_embed_python.sh

* Use cutter-deps for macOS

* Remove qt from Brewfile

* Fix .travis.yml

* Disable Homebrew update

* Fix llvm for macOS

* Fix regex in update_deps.py

* Fix PYTHON_FRAMEWORK_DIR

* Some debug output in travis

* Enable Python Bindings for cmake on macOS

* QMake debug

* Update deps

* Hopefully fix pkg-config

* QMake hack for shiboken2 and pyside2

* Deploy on deps-test

* Update deps

* Fix call to appbundle_embed_python.sh

* Update deps

* Fix Python for cmake on macOS

* Update deps

* Fix appbundle_embed_python.sh

* Copy pyside libs in appbundle_embed_python.sh

* Fix includes for CMake on macOS

* Copy PySide2 and Shiboke2 libs to Frameworks dir

* Manually deploy QtDBus and QtPrintSupport

* Print plugins dir

* Fix appbundle_embed_python.sh

* Update deps

* Remove some debug output

* Use last release of linuxdeployqt
This commit is contained in:
Florian Märkl 2019-03-09 00:01:24 +01:00 committed by GitHub
parent 7ea1f0b281
commit 732f2d8cde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 157 additions and 51 deletions

View File

@ -8,6 +8,7 @@ branches:
- debug
- /^v\d.*$/
- deploy-test
- deps-test
matrix:
include:
@ -27,18 +28,14 @@ dist: xenial
addons:
homebrew:
update: true
brewfile: scripts/Brewfile
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/qt/bin:$PATH" ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source scripts/prepare_python_macos.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
scripts/fetch_deps.sh &&
source cutter-deps/env.sh &&
export LD_LIBRARY_PATH="`llvm-config --libdir`:$LD_LIBRARY_PATH" &&
python3 -m pip install -r scripts/pip_requirements.txt
; fi
- scripts/fetch_deps.sh
- source cutter-deps/env.sh
- python3 -m pip install -r scripts/pip_requirements.txt
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=/usr/local/opt/llvm/bin:$PATH; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export LD_LIBRARY_PATH="`llvm-config --libdir`:$LD_LIBRARY_PATH"; fi
before_script:
- git submodule init ; git submodule update
@ -55,7 +52,15 @@ script:
- cd build
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
if [[ "$BUILD_SYSTEM" == "qmake" ]]; then
qmake CUTTER_ENABLE_PYTHON=true CUTTER_ENABLE_PYTHON_BINDINGS=true CUTTER_ENABLE_JUPYTER=true CUTTER_ENABLE_QTWEBENGINE=false PREFIX=/usr APPIMAGE=1 ../src && make -j4;
qmake
CUTTER_ENABLE_PYTHON=true
CUTTER_ENABLE_PYTHON_BINDINGS=true
CUTTER_ENABLE_JUPYTER=true
CUTTER_ENABLE_QTWEBENGINE=false
PREFIX=/usr
APPIMAGE=1
../src &&
make -j4;
elif [[ "$BUILD_SYSTEM" == "cmake" ]]; then
cmake
-DCMAKE_BUILD_TYPE=Release
@ -71,10 +76,27 @@ script:
fi
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
if [[ "$BUILD_SYSTEM" == "qmake" ]]; then
qmake CUTTER_ENABLE_PYTHON=true CUTTER_ENABLE_PYTHON_BINDINGS=false CUTTER_ENABLE_JUPYTER=true CUTTER_ENABLE_QTWEBENGINE=false CUTTER_BUNDLE_R2_APPBUNDLE=true PYTHON_FRAMEWORK_DIR=$PYTHON_FRAMEWORK_DIR ../src &&
qmake
CUTTER_ENABLE_PYTHON=true
CUTTER_ENABLE_PYTHON_BINDINGS=true
CUTTER_ENABLE_JUPYTER=true
CUTTER_ENABLE_QTWEBENGINE=false
CUTTER_BUNDLE_R2_APPBUNDLE=true
PYTHON_FRAMEWORK_DIR=$CUTTER_DEPS_PYTHON_FRAMEWORK_DIR
../src &&
make -j4;
elif [[ "$BUILD_SYSTEM" == "cmake" ]]; then
cmake -DCUTTER_ENABLE_PYTHON=ON -DCUTTER_ENABLE_PYTHON_BINDINGS=OFF -DCUTTER_ENABLE_JUPYTER=ON -DCUTTER_ENABLE_QTWEBENGINE=OFF ../src && make -j4;
cmake
-DCMAKE_BUILD_TYPE=Release
-DPYTHON_LIBRARY="$CUTTER_DEPS_PYTHON_PREFIX/lib/libpython3.6m.dylib"
-DPYTHON_INCLUDE_DIR="$CUTTER_DEPS_PYTHON_PREFIX/include/python3.6m"
-DPYTHON_EXECUTABLE="$CUTTER_DEPS_PYTHON_PREFIX/bin/python3"
-DCUTTER_ENABLE_PYTHON=ON
-DCUTTER_ENABLE_PYTHON_BINDINGS=ON
-DCUTTER_ENABLE_JUPYTER=ON
-DCUTTER_ENABLE_QTWEBENGINE=OFF
../src &&
make -j4;
fi
fi
@ -86,7 +108,8 @@ after_success:
cp ../src/translations/*.qm Cutter.app/Contents/Resources/translations/ &&
macdeployqt Cutter.app -executable=Cutter.app/Contents/MacOS/Cutter -libpath="../Frameworks" &&
macdeployqt Cutter.app -executable=Cutter.app/Contents/MacOS/Cutter -libpath="../Frameworks" &&
"$TRAVIS_BUILD_DIR/scripts/appbundle_embed_python.sh" "$PYTHON_FRAMEWORK_DIR/Python.framework" Cutter.app Cutter.app/Contents/MacOS/Cutter &&
cp -a "$QTDIR/lib/QtDBus.framework" "$QTDIR/lib/QtPrintSupport.framework" Cutter.app/Contents/Frameworks &&
"$TRAVIS_BUILD_DIR/scripts/appbundle_embed_python.sh" "$CUTTER_DEPS_PYTHON_FRAMEWORK_DIR/Python.framework" Cutter.app Cutter.app/Contents/MacOS/Cutter &&
mkdir -p Cutter.app/Contents/Resources/r2/share &&
cp -a /usr/local/share/radare2 Cutter.app/Contents/Resources/r2/share/ &&
mkdir image && cp -a Cutter.app image/ &&
@ -109,7 +132,7 @@ after_success:
mkdir -p appdir/usr/bin/translations &&
cp ../src/translations/*.qm appdir/usr/bin/translations/ &&
"$TRAVIS_BUILD_DIR/scripts/appimage_embed_python.sh" appdir &&
wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" &&
wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/6/linuxdeployqt-6-x86_64.AppImage" &&
chmod a+x linuxdeployqt*.AppImage &&
./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -bundle-non-qt-libs -no-strip -exclude-libs=libnss3.so,libnssutil3.so -ignore-glob=usr/lib/python3.6/** -verbose=2 &&
./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -appimage -no-strip -exclude-libs=libnss3.so,libnssutil3.so -ignore-glob=usr/lib/python3.6/** -verbose=2 &&

View File

@ -1,5 +1,5 @@
brew "p7zip"
brew "ccache"
brew "qt5"
brew "openssl"
brew "xz"
brew "llvm"

View File

@ -5,6 +5,8 @@ if ! [[ $# -eq 3 ]]; then
exit 1
fi
python_version=python3.6
py_framework=$1
appbundle=$2
executable=$3
@ -22,3 +24,17 @@ cd "$appbundle/Contents/Frameworks/Python.framework" || exit 1
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf || exit 1
rm -r Versions/Current/Resources/* Versions/Current/lib/python3.6/test Versions/Current/lib/python3.6/idlelib Versions/Current/lib/python3.6/curses Versions/Current/lib/python3.6/lib2to3 || exit 1
echo "Checking if PySide2 is available"
pyside_prefix=$(pkg-config --variable=prefix pyside2)
if [ $? -ne 0 ]; then
echo "PySide2 is not available, ignoring."
exit 0
fi
echo "PySide is at $pyside_prefix"
cp -va "$pyside_prefix/lib/$python_version/" "Versions/Current/lib/$python_version" || exit 1
cd .. # $appbundle/Contents/Frameworks
cp -va "$pyside_prefix/lib/"*.dylib . || exit 1

View File

@ -3,12 +3,41 @@
cd $(dirname "${BASH_SOURCE[0]}")/..
mkdir -p cutter-deps && cd cutter-deps
FILE=cutter-deps.tar.gz
MD5=0805fa6a1626ce787f952b300e2b321d
URL=https://github.com/radareorg/cutter-deps/releases/download/v2/cutter-deps.tar.gz
LINUX_FILE="cutter-deps-linux.tar.gz"
LINUX_MD5=b52ab4f06cb9e4b92372022c37920bf1
LINUX_URL=https://github.com/radareorg/cutter-deps/releases/download/v6/cutter-deps-linux.tar.gz
MACOS_FILE="cutter-deps-macos.tar.gz"
MACOS_MD5=85b663ea73b80663a532dfafe998905d
MACOS_URL=https://github.com/radareorg/cutter-deps/releases/download/v6/cutter-deps-macos.tar.gz
UNAME_S="$(uname -s)"
if [ "$UNAME_S" == "Linux" ]; then
FILE="${LINUX_FILE}"
MD5="${LINUX_MD5}"
URL="${LINUX_URL}"
elif [ "$UNAME_S" == "Darwin" ]; then
FILE="${MACOS_FILE}"
MD5="${MACOS_MD5}"
URL="${MACOS_URL}"
else
echo "Unsupported Platform: $UNAME_S"
exit 1
fi
curl -L "$URL" -o "$FILE" || exit 1
echo "$MD5 $FILE" | md5sum -c - || exit 1
if [ "$UNAME_S" == "Darwin" ]; then
if [ "$(md5 -r "$FILE")" != "$MD5 $FILE" ]; then \
echo "MD5 mismatch for file $FILE"; \
exit 1; \
else \
echo "$FILE OK"; \
fi
else
echo "$MD5 $FILE" | md5sum -c - || exit 1
fi
tar -xf "$FILE" || exit 1
./relocate.sh || exit 1

View File

@ -5,28 +5,42 @@ import requests
import re
import subprocess
platforms = ["linux", "macos", "win"]
if sys.platform == "darwin":
md5sum_cmd = ["md5", "-r"]
else:
md5sum_cmd = ["md5sum"]
fetch_deps_path = os.path.join(os.path.dirname(sys.argv[0]), "fetch_deps.sh")
print("Fetching latest release")
json = requests.get("https://api.github.com/repos/radareorg/cutter-deps/releases/latest").json()
release_url = json["assets"][0]["browser_download_url"]
print(f"Getting MD5 for {release_url}")
curl = subprocess.Popen(["curl", "-L", release_url], stdout=subprocess.PIPE)
md5sum = subprocess.run(["md5sum"], stdin=curl.stdout, capture_output=True, encoding="utf-8").stdout
curl.wait()
md5sum = re.match("([a-zA-Z0-9]+) ", md5sum).group(1)
print(f"MD5: {md5sum}")
for platform in platforms:
release_url = release_url.replace(platform, "${PLATFORM}")
with open(fetch_deps_path) as f:
fetch_deps = f.read()
fetch_deps = re.sub("^URL=.*$", f"URL={release_url}".replace("\\", r"\\"), fetch_deps, flags=re.MULTILINE)
fetch_deps = re.sub("^MD5=.*$", f"MD5={md5sum}".replace("\\", r"\\"), fetch_deps, flags=re.MULTILINE)
md5 = {}
for platform in platforms:
platform_url = release_url.replace("${PLATFORM}", platform)
print(f"Getting MD5 for {platform_url}")
curl = subprocess.Popen(["curl", "-fL", platform_url], stdout=subprocess.PIPE)
md5sum = subprocess.run(md5sum_cmd, stdin=curl.stdout, capture_output=True, encoding="utf-8").stdout
curl.wait()
if curl.returncode != 0:
print(f"Failed to download {platform_url}, skipping.")
continue
md5sum = re.fullmatch("([a-zA-Z0-9]+)( +-)?\n?", md5sum).group(1)
print(f"MD5: {md5sum}")
fetch_deps = re.sub(f"^{platform.upper()}_URL=.*$", f"{platform.upper()}_URL={platform_url}".replace("\\", r"\\"), fetch_deps, flags=re.MULTILINE)
fetch_deps = re.sub(f"^{platform.upper()}_MD5=.*$", f"{platform.upper()}_MD5={md5sum}".replace("\\", r"\\"), fetch_deps, flags=re.MULTILINE)
with open(fetch_deps_path, "w") as f:
f.write(fetch_deps)

View File

@ -191,7 +191,14 @@ if(CUTTER_ENABLE_PYTHON)
target_link_libraries(Cutter ${SHIBOKEN_LIBRARY} ${PYSIDE_LIBRARY})
get_target_property(BINDINGS_INCLUDE_DIRS Cutter INCLUDE_DIRECTORIES)
list(APPEND BINDINGS_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}")
if(APPLE AND _qt5Core_install_prefix)
list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include")
list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtCore")
list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtGui")
list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtWidgets")
endif()
list(APPEND BINDINGS_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS})
list(APPEND BINDINGS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
string(REPLACE ";" ":" BINDINGS_INCLUDE_DIRS "${BINDINGS_INCLUDE_DIRS}")
qmake_configure_file("${BINDINGS_SRC_DIR}/bindings.txt.in" "${BINDINGS_BUILD_DIR}/bindings.txt")
@ -201,3 +208,4 @@ endif()
if(CUTTER_ENABLE_PYTHON AND CUTTER_ENABLE_JUPYTER AND CUTTER_ENABLE_QTWEBENGINE)
target_link_libraries(Cutter Qt5::WebEngineWidgets)
endif()

View File

@ -118,6 +118,10 @@ unix {
# Libraries
include(lib_radare2.pri)
!win32 {
CONFIG += link_pkgconfig
}
CUTTER_ENABLE_PYTHON {
win32 {
PYTHON_EXECUTABLE = $$quote($$system("where python"))
@ -135,7 +139,6 @@ CUTTER_ENABLE_PYTHON {
LIBS += -F$$PYTHON_FRAMEWORK_DIR -framework Python
DEFINES += MACOS_PYTHON_FRAMEWORK_BUNDLED
} else {
CONFIG += link_pkgconfig
!packagesExist(python3) {
error("ERROR: Python 3 could not be found. Make sure it is available to pkg-config.")
}
@ -177,7 +180,13 @@ CUTTER_ENABLE_PYTHON {
GENERATED_SOURCES += $${BINDINGS_SOURCE}
INCLUDEPATH += "$${BINDINGS_BUILD_DIR}/CutterBindings"
PRE_TARGETDEPS += bindings_target
macx {
# Hack needed because with regular PKGCONFIG qmake will mess up everything
QMAKE_CXXFLAGS += $$system("pkg-config --cflags shiboken2 pyside2")
LIBS += $$system("pkg-config --libs shiboken2 pyside2")
} else {
PKGCONFIG += shiboken2 pyside2
}
INCLUDEPATH += "$$PYSIDE_INCLUDEDIR/QtCore" "$$PYSIDE_INCLUDEDIR/QtWidgets" "$$PYSIDE_INCLUDEDIR/QtGui"
}
}

View File

@ -6,7 +6,7 @@
#define CUTTERCORE_H
#include "r_core.h"
#include <QtCore/QtCore>
#include <QString>
// Workaround for compile errors on Windows
#ifdef _WIN32

View File

@ -5,6 +5,11 @@
#ifndef DESCRIPTIONS_H
#define DESCRIPTIONS_H
#include <QString>
#include <QList>
#include <QStringList>
#include <QMetaType>
struct FunctionDescription {
RVA offset;
RVA size;

View File

@ -42,6 +42,8 @@ void PluginManager::loadPlugins()
QDir pluginsDir(locations.first());
pluginsDir.mkpath(".");
qInfo() << "Plugins are loaded from" << pluginsDir.absolutePath();
pluginsDir.mkdir("plugins");
if (!pluginsDir.cd("plugins")) {
return;