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
}
isEmpty(PREFIX) {
PREFIX = /usr/local
}
DEFINES += PREFIX=\\\"$${PREFIX}\\\"
DEFINES += APP_NAME=\\\"$${APP_NAME}\\\"
DEFINES += REDPANDA_CPP_VERSION=\\\"beta.0.12.6\\\"
gcc {
QMAKE_CXXFLAGS_RELEASE += -Werror=return-type
QMAKE_CXXFLAGS_DEBUG += -Werror=return-type
@ -199,7 +207,6 @@ HEADERS += \
thememanager.h \
todoparser.h \
toolsmanager.h \
version.h \
widgets/aboutdialog.h \
widgets/bookmarkmodel.h \
widgets/classbrowser.h \
@ -343,10 +350,6 @@ linux: {
TRANSLATIONS += \
RedPandaIDE_zh_CN.ts
isEmpty(PREFIX) {
PREFIX = /usr/local
}
# Default rules for deployment.
qnx: 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 (redirectInput) {
newArguments = QString(" -e \"%1\" %2 \"%3\" \"%4\" %5")
.arg(includeTrailingPathDelimiter(pSettings->dirs().appDir())+"consolepauser")
.arg(includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"consolepauser")
.arg(consoleFlag)
.arg(redirectInputFilename)
.arg(localizePath(filename))
.arg(arguments);
} else {
newArguments = QString(" -e \"%1\" %2 \"%3\" %4")
.arg(includeTrailingPathDelimiter(pSettings->dirs().appDir())+"consolepauser")
.arg(includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"consolepauser")
.arg(consoleFlag)
.arg(localizePath(filename)).arg(arguments);
}

View File

@ -20,7 +20,6 @@
#include "../systemconsts.h"
#include "../platform.h"
#include "../editor.h"
#include "../version.h"
#include <QDir>
@ -125,7 +124,7 @@ void ProjectCompiler::newMakeFile(QFile& file)
void ProjectCompiler::writeMakeHeader(QFile &file)
{
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);
if (mOnlyCheckSyntax) {
writeln(file,"# This Makefile is written for syntax check!");

View File

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

View File

@ -172,18 +172,27 @@ QString Settings::Dirs::appDir() const
return QApplication::instance()->applicationDirPath();
}
QString Settings::Dirs::appLibDir() const
QString Settings::Dirs::appResourceDir() const
{
#ifdef Q_OS_WIN
return appDir();
#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
}
QString Settings::Dirs::templateDir() const
{
return includeTrailingPathDelimiter(appLibDir()) + "templates";
return includeTrailingPathDelimiter(appResourceDir()) + "templates";
}
QString Settings::Dirs::projectDir() const
@ -2834,7 +2843,7 @@ void Settings::Environment::doLoad()
mTerminalPath = stringValue("terminal_path","/usr/bin/konsole");
if (mTerminalPath.isEmpty())
mTerminalPath = stringValue("terminal_path","/usr/bin/x-terminal-emulator");
mAStylePath = includeTrailingPathDelimiter(pSettings->dirs().appDir())+"astyle";
mAStylePath = includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"astyle";
#endif
}

View File

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

View File

@ -37,7 +37,6 @@
#include "editorlist.h"
#include "editor.h"
#include "project.h"
#include "version.h"
#include "compiler/executablerunner.h"
#ifdef Q_OS_WIN
#include <windows.h>
@ -797,7 +796,7 @@ QString parseMacros(const QString &s)
result.replace("<DEFAULT>", localizePath(QDir::currentPath()));
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()));
QDate today = QDate::currentDate();
QDateTime now = QDateTime::currentDateTime();

View File

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

View File

@ -17,15 +17,13 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include "../systemconsts.h"
#include "../version.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
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__
ui->lblQt->setText(ui->lblQt->text()

View File

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

View File

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

View File

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