mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-20 21:56:06 +00:00
Use r_sys_prefix() for AppImage and macOS AppBundle (Fix #432)
This commit is contained in:
parent
853f10df50
commit
1e81aafb37
@ -58,13 +58,13 @@ script:
|
||||
- cd build
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
||||
if [[ "$BUILD_SYSTEM" == "qmake" ]]; then
|
||||
PKG_CONFIG_PATH="$CUSTOM_PYTHON_PREFIX/lib/pkgconfig" qmake CONFIG+=CUTTER_ENABLE_JUPYTER CONFIG+=CUTTER_ENABLE_QTWEBENGINE PREFIX=/usr APPIMAGE=1 ../src && make -j4;
|
||||
PKG_CONFIG_PATH="$CUSTOM_PYTHON_PREFIX/lib/pkgconfig" qmake CUTTER_ENABLE_JUPYTER=true CUTTER_ENABLE_QTWEBENGINE=true PREFIX=/usr APPIMAGE=1 ../src && make -j4;
|
||||
elif [[ "$BUILD_SYSTEM" == "qmake" ]]; then
|
||||
cmake ../src && make -j4;
|
||||
fi
|
||||
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
if [[ "$BUILD_SYSTEM" == "qmake" ]]; then
|
||||
qmake CONFIG+=CUTTER_ENABLE_JUPYTER CONFIG+=CUTTER_ENABLE_QTWEBENGINE PYTHON_FRAMEWORK_DIR=$PYTHON_FRAMEWORK_DIR ../src &&
|
||||
qmake CUTTER_ENABLE_JUPYTER=true CUTTER_ENABLE_QTWEBENGINE=true CUTTER_BUNDLE_R2_APPBUNDLE=true PYTHON_FRAMEWORK_DIR=$PYTHON_FRAMEWORK_DIR ../src &&
|
||||
make -j4;
|
||||
elif [[ "$BUILD_SYSTEM" == "qmake" ]]; then
|
||||
cmake ../src && make -j4;
|
||||
@ -76,6 +76,8 @@ after_success:
|
||||
macdeployqt Cutter.app &&
|
||||
"$TRAVIS_BUILD_DIR/scripts/appbundle_patch_qtwebengine.sh" Cutter.app &&
|
||||
"$TRAVIS_BUILD_DIR/scripts/appbundle_embed_python.sh" "$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/ &&
|
||||
hdiutil create -srcfolder image -volname Cutter -fs HFS+ Cutter.dmg &&
|
||||
export FILE_TO_UPLOAD="Cutter.dmg"
|
||||
|
@ -1,7 +1,10 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QRegularExpression>
|
||||
#include <utils/TempConfig.h>
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "utils/TempConfig.h"
|
||||
#include "utils/Configuration.h"
|
||||
#include "Cutter.h"
|
||||
#include "sdb.h"
|
||||
@ -52,6 +55,23 @@ CutterCore::CutterCore(QObject *parent) :
|
||||
|
||||
// Otherwise r2 may ask the user for input and Cutter would freeze
|
||||
setConfig("scr.interactive", false);
|
||||
|
||||
#if defined(APPIMAGE) || defined(MACOS_R2_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
|
||||
// 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());
|
||||
#endif
|
||||
|
||||
|
||||
default_bits = 0;
|
||||
}
|
||||
|
@ -11,14 +11,17 @@ QT += core gui widgets svg
|
||||
QT_CONFIG -= no-pkg-config
|
||||
CONFIG += c++11
|
||||
|
||||
!defined(CUTTER_ENABLE_JUPYTER, var) CUTTER_ENABLE_JUPYTER=true
|
||||
equals(CUTTER_ENABLE_JUPYTER, true) CONFIG += CUTTER_ENABLE_JUPYTER
|
||||
!defined(CUTTER_ENABLE_JUPYTER, var) CUTTER_ENABLE_JUPYTER=true
|
||||
equals(CUTTER_ENABLE_JUPYTER, true) CONFIG += CUTTER_ENABLE_JUPYTER
|
||||
|
||||
!defined(CUTTER_ENABLE_QTWEBENGINE, var) CUTTER_ENABLE_QTWEBENGINE=true
|
||||
!defined(CUTTER_ENABLE_QTWEBENGINE, var) CUTTER_ENABLE_QTWEBENGINE=true
|
||||
equals(CUTTER_ENABLE_JUPYTER, true) {
|
||||
equals(CUTTER_ENABLE_QTWEBENGINE, true) CONFIG += CUTTER_ENABLE_QTWEBENGINE
|
||||
}
|
||||
|
||||
!defined(CUTTER_BUNDLE_R2_APPBUNDLE, var) CUTTER_BUNDLE_R2_APPBUNDLE=false
|
||||
equals(CUTTER_BUNDLE_R2_APPBUNDLE, true) CONFIG += CUTTER_BUNDLE_R2_APPBUNDLE
|
||||
|
||||
# Define the preprocessor macro to get the application version in our application.
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
CUTTER_ENABLE_JUPYTER {
|
||||
@ -79,6 +82,11 @@ unix:CUTTER_ENABLE_JUPYTER|macx:CUTTER_ENABLE_JUPYTER {
|
||||
}
|
||||
}
|
||||
|
||||
macx:CUTTER_BUNDLE_R2_APPBUNDLE {
|
||||
message("Using r2 rom AppBundle")
|
||||
DEFINES += MACOS_R2_BUNDLED
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
Main.cpp \
|
||||
Cutter.cpp \
|
||||
|
33
src/Main.cpp
33
src/Main.cpp
@ -1,43 +1,12 @@
|
||||
|
||||
#include "CutterApplication.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
#ifdef APPIMAGE
|
||||
#define PREFIX "/tmp/.cutter_usr"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
void set_appimage_symlink()
|
||||
{
|
||||
char *path = realpath("/proc/self/exe", NULL);
|
||||
char *i = strrchr(path, '/');
|
||||
*(i + 1) = '\0';
|
||||
char *dest = strcat(path, "../");
|
||||
struct stat buf;
|
||||
if (lstat(PREFIX, &buf) == 0 && S_ISLNK(buf.st_mode)) {
|
||||
remove(PREFIX);
|
||||
}
|
||||
symlink(dest, PREFIX);
|
||||
printf("'%s' '%s' '%s'\n", path, i, dest);
|
||||
free(path);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Hack to make it work with AppImage
|
||||
#ifdef APPIMAGE
|
||||
set_appimage_symlink();
|
||||
#endif
|
||||
|
||||
CutterApplication a(argc, argv);
|
||||
|
||||
int ret = a.exec();
|
||||
|
||||
#ifdef APPIMAGE
|
||||
remove(PREFIX);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user