From 6cb2fb15eb401a8ec523a332f60965e51e0dcf5a Mon Sep 17 00:00:00 2001 From: RigoLigo Date: Mon, 23 May 2022 01:34:38 +0800 Subject: [PATCH] Add hacks to make it build on MacOS 12.3 you need to install icu4c in brew --- RedPandaIDE/RedPandaIDE.pro | 6 ++++++ RedPandaIDE/qsynedit/SynEdit.cpp | 2 +- RedPandaIDE/settings.cpp | 5 +++++ RedPandaIDE/systemconsts.h | 17 ++++++++++++++++- RedPandaIDE/widgets/darkfusionstyle.cpp | 5 +++++ Red_Panda_CPP.pro | 2 +- consolepauser/consolepauser.pro | 9 +++++++-- consolepauser/main.unix.cpp | 4 +++- 8 files changed, 44 insertions(+), 6 deletions(-) diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 7afa864a..287b081d 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -13,7 +13,13 @@ isEmpty(APP_VERSION) { APP_VERSION=1.0.8 } +macos: { + # This package needs to be installed via homebrew before we can compile it + INCLUDEPATH += \ + /opt/homebrew/opt/icu4c/include + QT += gui-private +} win32: VERSION = $${APP_VERSION}.0 else: VERSION = $${APP_VERSION} diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index f408a50e..c675dad3 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -52,7 +52,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent), mPainting = false; #ifdef Q_OS_WIN mFontDummy = QFont("Consolas",12); -#elif defined(Q_OS_LINUX) +#elif defined(Q_OS_LINUX) || defined(Q_OS_MACOS) mFontDummy = QFont("terminal",14); #else #error "Not supported!" diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 14d73773..6326b218 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -185,15 +185,20 @@ QString Settings::Dirs::appResourceDir() const return appDir(); #elif defined(Q_OS_LINUX) return includeTrailingPathDelimiter(PREFIX)+"share/"+APP_NAME; +#elif defined(Q_OS_MACOS) + return ""; #endif } + QString Settings::Dirs::appLibexecDir() const { #ifdef Q_OS_WIN return appDir(); #elif defined(Q_OS_LINUX) return includeTrailingPathDelimiter(PREFIX)+"libexec/"+APP_NAME; +#elif defined(Q_OS_MACOS) + return ""; #endif } diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index a7c1ddec..8329f770 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -50,6 +50,21 @@ #define CLANG_PROGRAM "clang" #define CLANG_CPP_PROGRAM "clang++" #define LLDB_MI_PROGRAM "lldb-mi" +#elif defined(Q_OS_MACOS) +#define GCC_PROGRAM "gcc" +#define GPP_PROGRAM "g++" +#define GDB_PROGRAM "gdb" +#define GDB_SERVER_PROGRAM "gdbserver" +#define GDB32_PROGRAM "gdb32" +#define MAKE_PROGRAM "make" +#define WINDRES_PROGRAM "" +#define GPROF_PROGRAM "gprof" +#define CLEAN_PROGRAM "rm -rf" +#define CPP_PROGRAM "cpp" +#define GIT_PROGRAM "git" +#define CLANG_PROGRAM "clang" +#define CLANG_CPP_PROGRAM "clang++" +#define LLDB_MI_PROGRAM "lldb-mi" #else #error "Only support windows and linux now!" #endif @@ -85,7 +100,7 @@ # define DYNAMIC_LIB_EXT "dll" # define MAKEFILE_NAME "makefile.win" # define ALL_FILE_WILDCARD "*.*" -#elif defined(Q_OS_LINUX) +#elif defined(Q_OS_LINUX) || defined(Q_OS_MACOS) # define PATH_SENSITIVITY Qt::CaseSensitive # define PATH_SEPARATOR ":" # define LINE_BREAKER "\n" diff --git a/RedPandaIDE/widgets/darkfusionstyle.cpp b/RedPandaIDE/widgets/darkfusionstyle.cpp index 7618c9e3..9b38fb6f 100644 --- a/RedPandaIDE/widgets/darkfusionstyle.cpp +++ b/RedPandaIDE/widgets/darkfusionstyle.cpp @@ -27,6 +27,11 @@ #include #include "../settings.h" +#if defined(Q_OS_MACX) +#include +#include +#endif + #define BEGIN_STYLE_PIXMAPCACHE(a) \ QRect rect = option->rect; \ QPixmap internalPixmapCache; \ diff --git a/Red_Panda_CPP.pro b/Red_Panda_CPP.pro index b27d7261..042d4353 100644 --- a/Red_Panda_CPP.pro +++ b/Red_Panda_CPP.pro @@ -10,7 +10,7 @@ SUBDIRS += \ redpanda-win-git-askpass } -linux: { +macos,linux: { SUBDIRS += \ redpanda-git-askpass } diff --git a/consolepauser/consolepauser.pro b/consolepauser/consolepauser.pro index 0ab409f6..6fcf7b56 100644 --- a/consolepauser/consolepauser.pro +++ b/consolepauser/consolepauser.pro @@ -19,10 +19,15 @@ SOURCES += \ unix: { SOURCES += \ main.unix.cpp - LIBS+= \ - -lrt } +# macOS does not provide rt library, only use it for Linux +linux: { +LIBS+= \ + -lrt +} + + CONFIG += lrelease CONFIG += embed_translations diff --git a/consolepauser/main.unix.cpp b/consolepauser/main.unix.cpp index 9861261a..a8712f97 100644 --- a/consolepauser/main.unix.cpp +++ b/consolepauser/main.unix.cpp @@ -109,7 +109,9 @@ int ExecuteCommand(vector& command,bool reInp) { if (result) { printf("Failed to start command %s %s!\n",path_to_command.c_str(), file.c_str()); printf("errno %d: %s\n",errno,strerror(errno)); - printf("current dir: %s",get_current_dir_name()); + char* current_dir = getcwd(nullptr, 0); + printf("current dir: %s",current_dir); + free(current_dir); exit(-1); } } else {