support PREFIX in qmake script

This commit is contained in:
Roy Qu 2022-01-05 09:08:44 +08:00
parent 1859558864
commit e3b9565b84
12 changed files with 50 additions and 41 deletions

View File

@ -9,6 +9,14 @@ isEmpty(APP_NAME) {
APP_NAME = RedPandaCPP APP_NAME = RedPandaCPP
} }
isEmpty(PREFIX) {
PREFIX = /usr/local
}
DEFINES += PREFIX=\\\"$${PREFIX}\\\"
DEFINES += APP_NAME=\\\"$${APP_NAME}\\\"
DEFINES += REDPANDA_CPP_VERSION=\\\"beta.0.12.6\\\"
gcc { gcc {
QMAKE_CXXFLAGS_RELEASE += -Werror=return-type QMAKE_CXXFLAGS_RELEASE += -Werror=return-type
QMAKE_CXXFLAGS_DEBUG += -Werror=return-type QMAKE_CXXFLAGS_DEBUG += -Werror=return-type
@ -199,7 +207,6 @@ HEADERS += \
thememanager.h \ thememanager.h \
todoparser.h \ todoparser.h \
toolsmanager.h \ toolsmanager.h \
version.h \
widgets/aboutdialog.h \ widgets/aboutdialog.h \
widgets/bookmarkmodel.h \ widgets/bookmarkmodel.h \
widgets/classbrowser.h \ widgets/classbrowser.h \
@ -343,10 +350,6 @@ linux: {
TRANSLATIONS += \ TRANSLATIONS += \
RedPandaIDE_zh_CN.ts RedPandaIDE_zh_CN.ts
isEmpty(PREFIX) {
PREFIX = /usr/local
}
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = $${PREFIX}/bin qnx: target.path = $${PREFIX}/bin
else: unix:!android: target.path = $${PREFIX}/bin else: unix:!android: target.path = $${PREFIX}/bin

View File

@ -250,14 +250,14 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
if (consoleFlag!=0) { if (consoleFlag!=0) {
if (redirectInput) { if (redirectInput) {
newArguments = QString(" -e \"%1\" %2 \"%3\" \"%4\" %5") newArguments = QString(" -e \"%1\" %2 \"%3\" \"%4\" %5")
.arg(includeTrailingPathDelimiter(pSettings->dirs().appDir())+"consolepauser") .arg(includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"consolepauser")
.arg(consoleFlag) .arg(consoleFlag)
.arg(redirectInputFilename) .arg(redirectInputFilename)
.arg(localizePath(filename)) .arg(localizePath(filename))
.arg(arguments); .arg(arguments);
} else { } else {
newArguments = QString(" -e \"%1\" %2 \"%3\" %4") newArguments = QString(" -e \"%1\" %2 \"%3\" %4")
.arg(includeTrailingPathDelimiter(pSettings->dirs().appDir())+"consolepauser") .arg(includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"consolepauser")
.arg(consoleFlag) .arg(consoleFlag)
.arg(localizePath(filename)).arg(arguments); .arg(localizePath(filename)).arg(arguments);
} }

View File

@ -20,7 +20,6 @@
#include "../systemconsts.h" #include "../systemconsts.h"
#include "../platform.h" #include "../platform.h"
#include "../editor.h" #include "../editor.h"
#include "../version.h"
#include <QDir> #include <QDir>
@ -125,7 +124,7 @@ void ProjectCompiler::newMakeFile(QFile& file)
void ProjectCompiler::writeMakeHeader(QFile &file) void ProjectCompiler::writeMakeHeader(QFile &file)
{ {
writeln(file,"# Project: " + mProject->name()); writeln(file,"# Project: " + mProject->name());
writeln(file,QString("# Makefile created by Red Panda C++ ") + DEVCPP_VERSION); writeln(file,QString("# Makefile created by Red Panda C++ ") + REDPANDA_CPP_VERSION);
writeln(file); writeln(file);
if (mOnlyCheckSyntax) { if (mOnlyCheckSyntax) {
writeln(file,"# This Makefile is written for syntax check!"); writeln(file,"# This Makefile is written for syntax check!");

View File

@ -36,7 +36,6 @@
#include "widgets/lightfusionstyle.h" #include "widgets/lightfusionstyle.h"
#include "problems/problemcasevalidator.h" #include "problems/problemcasevalidator.h"
#include "widgets/ojproblempropertywidget.h" #include "widgets/ojproblempropertywidget.h"
#include "version.h"
#include "iconsmanager.h" #include "iconsmanager.h"
#include <QCloseEvent> #include <QCloseEvent>
@ -698,22 +697,22 @@ void MainWindow::updateAppTitle()
str = e->filename(); str = e->filename();
if (mDebugger->executing()) { if (mDebugger->executing()) {
setWindowTitle(QString("%1 - [%2] - %3 %4") setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,tr("Debugging"),appName,DEVCPP_VERSION)); .arg(str,tr("Debugging"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Debugging"),appName)); .arg(str,tr("Debugging"),appName));
} else if (mCompilerManager->running()) { } else if (mCompilerManager->running()) {
setWindowTitle(QString("%1 - [%2] - %3 %4") setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,tr("Running"),appName,DEVCPP_VERSION)); .arg(str,tr("Running"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Running"),appName)); .arg(str,tr("Running"),appName));
} else if (mCompilerManager->compiling()) { } else if (mCompilerManager->compiling()) {
setWindowTitle(QString("%1 - [%2] - %3 %4") setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,tr("Compiling"),appName,DEVCPP_VERSION)); .arg(str,tr("Compiling"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Compiling"),appName)); .arg(str,tr("Compiling"),appName));
} else { } else {
this->setWindowTitle(QString("%1 - %2 %3") this->setWindowTitle(QString("%1 - %2 %3")
.arg(str,appName,DEVCPP_VERSION)); .arg(str,appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - %2") app->setApplicationName(QString("%1 - %2")
.arg(str,appName)); .arg(str,appName));
} }
@ -730,24 +729,24 @@ void MainWindow::updateAppTitle()
if (mDebugger->executing()) { if (mDebugger->executing()) {
setWindowTitle(QString("%1 - %2 [%3] - %4 %5") setWindowTitle(QString("%1 - %2 [%3] - %4 %5")
.arg(str,str2, .arg(str,str2,
tr("Debugging"),appName,DEVCPP_VERSION)); tr("Debugging"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Debugging"),appName)); .arg(str,tr("Debugging"),appName));
} else if (mCompilerManager->running()) { } else if (mCompilerManager->running()) {
setWindowTitle(QString("%1 - %2 [%3] - %4 %5") setWindowTitle(QString("%1 - %2 [%3] - %4 %5")
.arg(str,str2, .arg(str,str2,
tr("Running"),appName,DEVCPP_VERSION)); tr("Running"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Running"),appName)); .arg(str,tr("Running"),appName));
} else if (mCompilerManager->compiling()) { } else if (mCompilerManager->compiling()) {
setWindowTitle(QString("%1 - %2 [%3] - %4 %5") setWindowTitle(QString("%1 - %2 [%3] - %4 %5")
.arg(str,str2, .arg(str,str2,
tr("Compiling"),appName,DEVCPP_VERSION)); tr("Compiling"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Compiling"),appName)); .arg(str,tr("Compiling"),appName));
} else { } else {
setWindowTitle(QString("%1 - %2 %3") setWindowTitle(QString("%1 - %2 %3")
.arg(str,appName,DEVCPP_VERSION)); .arg(str,appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - %2") app->setApplicationName(QString("%1 - %2")
.arg(str,appName)); .arg(str,appName));
} }
@ -759,27 +758,27 @@ void MainWindow::updateAppTitle()
str = mProject->name(); str = mProject->name();
if (mDebugger->executing()) { if (mDebugger->executing()) {
setWindowTitle(QString("%1 - [%2] - %3 %4") setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,tr("Debugging"),appName,DEVCPP_VERSION)); .arg(str,tr("Debugging"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Debugging"),appName)); .arg(str,tr("Debugging"),appName));
} else if (mCompilerManager->running()) { } else if (mCompilerManager->running()) {
setWindowTitle(QString("%1 - [%2] - %3 %4") setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,tr("Running"),appName,DEVCPP_VERSION)); .arg(str,tr("Running"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Running"),appName)); .arg(str,tr("Running"),appName));
} else if (mCompilerManager->compiling()) { } else if (mCompilerManager->compiling()) {
setWindowTitle(QString("%1 - [%2] - %3 %4") setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,tr("Compiling"),appName,DEVCPP_VERSION)); .arg(str,tr("Compiling"),appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3") app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,tr("Compiling"),appName)); .arg(str,tr("Compiling"),appName));
} else { } else {
this->setWindowTitle(QString("%1 - %2 %3") this->setWindowTitle(QString("%1 - %2 %3")
.arg(str,appName,DEVCPP_VERSION)); .arg(str,appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1 - %2") app->setApplicationName(QString("%1 - %2")
.arg(str,appName)); .arg(str,appName));
} }
} else { } else {
setWindowTitle(QString("%1 %2").arg(appName,DEVCPP_VERSION)); setWindowTitle(QString("%1 %2").arg(appName,REDPANDA_CPP_VERSION));
app->setApplicationName(QString("%1").arg(appName)); app->setApplicationName(QString("%1").arg(appName));
} }
} }
@ -2042,7 +2041,7 @@ void MainWindow::updateTools()
file.close(); file.close();
if (item->pauseAfterExit) { if (item->pauseAfterExit) {
executeFile( executeFile(
includeTrailingPathDelimiter(pSettings->dirs().appDir())+"ConsolePauser.exe", includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"ConsolePauser.exe",
" 1 \""+localizePath(file.fileName())+"\" ", " 1 \""+localizePath(file.fileName())+"\" ",
workDir, file.fileName()); workDir, file.fileName());
} else { } else {
@ -2055,7 +2054,7 @@ void MainWindow::updateTools()
} else { } else {
if (item->pauseAfterExit) { if (item->pauseAfterExit) {
executeFile( executeFile(
includeTrailingPathDelimiter(pSettings->dirs().appDir())+"ConsolePauser.exe", includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"ConsolePauser.exe",
" 1 \""+program+"\" "+params, " 1 \""+program+"\" "+params,
workDir, ""); workDir, "");
} else { } else {

View File

@ -172,18 +172,27 @@ QString Settings::Dirs::appDir() const
return QApplication::instance()->applicationDirPath(); return QApplication::instance()->applicationDirPath();
} }
QString Settings::Dirs::appLibDir() const QString Settings::Dirs::appResourceDir() const
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
return appDir(); return appDir();
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
return QFileInfo(includeTrailingPathDelimiter(appDir())+"../lib").absolutePath(); return includeTrailingPathDelimiter(PREFIX)+"share/"+APP_NAME;
#endif
}
QString Settings::Dirs::appLibexecDir() const
{
#ifdef Q_OS_WIN
return appDir();
#elif defined(Q_OS_LINUX)
return includeTrailingPathDelimiter(PREFIX)+"libexec/"+APP_NAME;
#endif #endif
} }
QString Settings::Dirs::templateDir() const QString Settings::Dirs::templateDir() const
{ {
return includeTrailingPathDelimiter(appLibDir()) + "templates"; return includeTrailingPathDelimiter(appResourceDir()) + "templates";
} }
QString Settings::Dirs::projectDir() const QString Settings::Dirs::projectDir() const
@ -2834,7 +2843,7 @@ void Settings::Environment::doLoad()
mTerminalPath = stringValue("terminal_path","/usr/bin/konsole"); mTerminalPath = stringValue("terminal_path","/usr/bin/konsole");
if (mTerminalPath.isEmpty()) if (mTerminalPath.isEmpty())
mTerminalPath = stringValue("terminal_path","/usr/bin/x-terminal-emulator"); mTerminalPath = stringValue("terminal_path","/usr/bin/x-terminal-emulator");
mAStylePath = includeTrailingPathDelimiter(pSettings->dirs().appDir())+"astyle"; mAStylePath = includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"astyle";
#endif #endif
} }

View File

@ -106,7 +106,8 @@ public:
}; };
explicit Dirs(Settings * settings); explicit Dirs(Settings * settings);
QString appDir() const; QString appDir() const;
QString appLibDir() const; QString appResourceDir() const;
QString appLibexecDir() const;
QString templateDir() const; QString templateDir() const;
QString projectDir() const; QString projectDir() const;
QString data(DataType dataType = DataType::None) const; QString data(DataType dataType = DataType::None) const;

View File

@ -37,7 +37,6 @@
#include "editorlist.h" #include "editorlist.h"
#include "editor.h" #include "editor.h"
#include "project.h" #include "project.h"
#include "version.h"
#include "compiler/executablerunner.h" #include "compiler/executablerunner.h"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <windows.h> #include <windows.h>
@ -797,7 +796,7 @@ QString parseMacros(const QString &s)
result.replace("<DEFAULT>", localizePath(QDir::currentPath())); result.replace("<DEFAULT>", localizePath(QDir::currentPath()));
result.replace("<DEVCPP>", localizePath(pSettings->dirs().executable())); result.replace("<DEVCPP>", localizePath(pSettings->dirs().executable()));
result.replace("<DEVCPPVERSION>", DEVCPP_VERSION); result.replace("<DEVCPPVERSION>", REDPANDA_CPP_VERSION);
result.replace("<EXECPATH>", localizePath(pSettings->dirs().appDir())); result.replace("<EXECPATH>", localizePath(pSettings->dirs().appDir()));
QDate today = QDate::currentDate(); QDate today = QDate::currentDate();
QDateTime now = QDateTime::currentDateTime(); QDateTime now = QDateTime::currentDateTime();

View File

@ -19,6 +19,7 @@
#include <QObject> #include <QObject>
#define DEVCPP_VERSION "beta.0.12.6" #define PREFIX "$${PREFIX}"
#define RED_PANDA_CPP_VERSION "$${PREFIX}"
#endif // VERSION_H #endif // VERSION_H

View File

@ -17,15 +17,13 @@
#include "aboutdialog.h" #include "aboutdialog.h"
#include "ui_aboutdialog.h" #include "ui_aboutdialog.h"
#include "../systemconsts.h" #include "../systemconsts.h"
#include "../version.h"
AboutDialog::AboutDialog(QWidget *parent) : AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::AboutDialog) ui(new Ui::AboutDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lblTitle->setText(ui->lblTitle->text() + tr("Version: ") + DEVCPP_VERSION); ui->lblTitle->setText(ui->lblTitle->text() + tr("Version: ") + REDPANDA_CPP_VERSION);
#ifdef __GNUC__ #ifdef __GNUC__
ui->lblQt->setText(ui->lblQt->text() ui->lblQt->setText(ui->lblQt->text()

View File

@ -17,7 +17,7 @@ linux: {
resources.files += linux/templates resources.files += linux/templates
INSTALLS += resources INSTALLS += resources
docs.path = $${PREFIX}/share/docs/$${APP_NAME} docs.path = $${PREFIX}/share/doc/$${APP_NAME}
docs.files += README.md docs.files += README.md
docs.files += NEWS.md docs.files += NEWS.md
docs.files += LICENSE docs.files += LICENSE
@ -25,6 +25,6 @@ linux: {
pixmaps.path = $${PREFIX}/share/pixmaps pixmaps.path = $${PREFIX}/share/pixmaps
pixmaps.files += linux/redpandaide.png pixmaps.files += linux/redpandaide.png
INSTALLS += pixmaps
} }

View File

@ -31,6 +31,6 @@ isEmpty(PREFIX) {
} }
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${PREFIX}/libexec/$${APP_NAME} qnx: target.path = $${PREFIX}/libexec/$${APP_NAME}
else: unix:!android: target.path = /usr/$${PREFIX}/libexec/$${APP_NAME} else: unix:!android: target.path = $${PREFIX}/libexec/$${APP_NAME}
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
echo Copying desktop files... echo Copying desktop files...
sudo cp -f redpandaide.desktop /usr/share/applications sudo cp -f /opt/RedPandaIDE/redpandaide.desktop /usr/share/applications
echo Done! echo Done!