- fix: path in macros should use system's path separator
This commit is contained in:
parent
64ea9aad7e
commit
319c26902c
|
@ -219,7 +219,7 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
|
||||||
if (consoleFlag!=0) {
|
if (consoleFlag!=0) {
|
||||||
QString newArguments = QString(" %1 \"%2\" %3")
|
QString newArguments = QString(" %1 \"%2\" %3")
|
||||||
.arg(consoleFlag)
|
.arg(consoleFlag)
|
||||||
.arg(toLocalPath(filename)).arg(arguments);
|
.arg(localizePath(filename)).arg(arguments);
|
||||||
execRunner = new ExecutableRunner(includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe",newArguments,workDir);
|
execRunner = new ExecutableRunner(includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe",newArguments,workDir);
|
||||||
} else {
|
} else {
|
||||||
execRunner = new ExecutableRunner(filename,arguments,workDir);
|
execRunner = new ExecutableRunner(filename,arguments,workDir);
|
||||||
|
|
|
@ -1802,18 +1802,20 @@ void MainWindow::updateTools()
|
||||||
foreach (const PToolItem& item, mToolsManager->tools()) {
|
foreach (const PToolItem& item, mToolsManager->tools()) {
|
||||||
QAction* action = new QAction(item->title,ui->menuTools);
|
QAction* action = new QAction(item->title,ui->menuTools);
|
||||||
connect(action, &QAction::triggered,
|
connect(action, &QAction::triggered,
|
||||||
[item,this] (){
|
[item] (){
|
||||||
QString params = parseMacros(item->parameters);
|
if (item->pauseAfterExit
|
||||||
params.replace("/",QDir::separator());
|
&& programHasConsole(parseMacros(item->program))) {
|
||||||
QByteArray newContent = runAndGetOutput(
|
executeFile(
|
||||||
|
includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe",
|
||||||
|
" 0 \""+parseMacros(item->program)+"\" "+parseMacros(item->parameters),
|
||||||
|
parseMacros(item->workingDirectory));
|
||||||
|
} else {
|
||||||
|
executeFile(
|
||||||
parseMacros(item->program),
|
parseMacros(item->program),
|
||||||
parseMacros(item->workingDirectory),
|
parseMacros(item->parameters),
|
||||||
QProcess::splitCommand(params),
|
parseMacros(item->workingDirectory));
|
||||||
QByteArray(),
|
|
||||||
true
|
}
|
||||||
);
|
|
||||||
qDebug()<<"running"<<item->program;
|
|
||||||
ui->txtCompilerOutput->appendPlainText(QString::fromLocal8Bit(newContent));
|
|
||||||
});
|
});
|
||||||
ui->menuTools->addAction(action);
|
ui->menuTools->addAction(action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,13 +293,6 @@ bool programHasConsole(const QString &filename)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString toLocalPath(const QString &filename)
|
|
||||||
{
|
|
||||||
QString newPath {filename};
|
|
||||||
newPath.replace("/",QDir::separator());
|
|
||||||
return newPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList textToLines(const QString &text)
|
QStringList textToLines(const QString &text)
|
||||||
{
|
{
|
||||||
QTextStream stream(&((QString&)text),QIODevice::ReadOnly);
|
QTextStream stream(&((QString&)text),QIODevice::ReadOnly);
|
||||||
|
@ -767,10 +760,10 @@ QString parseMacros(const QString &s)
|
||||||
QString result = s;
|
QString result = s;
|
||||||
Editor *e = pMainWindow->editorList()->getEditor();
|
Editor *e = pMainWindow->editorList()->getEditor();
|
||||||
|
|
||||||
result.replace("<DEFAULT>", QDir::currentPath());
|
result.replace("<DEFAULT>", localizePath(QDir::currentPath()));
|
||||||
result.replace("<DEVCPP>", pSettings->dirs().executable());
|
result.replace("<DEVCPP>", localizePath(pSettings->dirs().executable()));
|
||||||
result.replace("<DEVCPPVERSION>", DEVCPP_VERSION);
|
result.replace("<DEVCPPVERSION>", DEVCPP_VERSION);
|
||||||
result.replace("<EXECPATH>", pSettings->dirs().app());
|
result.replace("<EXECPATH>", localizePath(pSettings->dirs().app()));
|
||||||
QDate today = QDate::currentDate();
|
QDate today = QDate::currentDate();
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
@ -781,30 +774,34 @@ QString parseMacros(const QString &s)
|
||||||
if (compilerSet) {
|
if (compilerSet) {
|
||||||
// Only provide the first cpp include dir
|
// Only provide the first cpp include dir
|
||||||
if (compilerSet->defaultCppIncludeDirs().count()>0)
|
if (compilerSet->defaultCppIncludeDirs().count()>0)
|
||||||
result.replace("<INCLUDE>", compilerSet->defaultCppIncludeDirs().front());
|
result.replace("<INCLUDE>", localizePath(compilerSet->defaultCppIncludeDirs().front()));
|
||||||
else
|
else
|
||||||
result.replace("<INCLUDE>","");
|
result.replace("<INCLUDE>","");
|
||||||
|
|
||||||
// Only provide the first lib dir
|
// Only provide the first lib dir
|
||||||
if (compilerSet->defaultLibDirs().count()>0)
|
if (compilerSet->defaultLibDirs().count()>0)
|
||||||
result.replace("<LIB>", compilerSet->defaultCppIncludeDirs().front());
|
result.replace("<LIB>", localizePath(compilerSet->defaultCppIncludeDirs().front()));
|
||||||
else
|
else
|
||||||
result.replace("<LIB>","");
|
result.replace("<LIB>","");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Project-dependent macros
|
// Project-dependent macros
|
||||||
if (pMainWindow->project()) {
|
if (pMainWindow->project()) {
|
||||||
result.replace("<EXENAME>", pMainWindow->project()->executable());
|
result.replace("<EXENAME>", extractFileName(pMainWindow->project()->executable()));
|
||||||
|
result.replace("<EXEFILE>", localizePath(pMainWindow->project()->executable()));
|
||||||
result.replace("<PROJECTNAME>", pMainWindow->project()->name());
|
result.replace("<PROJECTNAME>", pMainWindow->project()->name());
|
||||||
result.replace("<PROJECTFILE>", pMainWindow->project()->filename());
|
result.replace("<PROJECTFILE>", localizePath(pMainWindow->project()->filename()));
|
||||||
result.replace("<PROJECTPATH>", pMainWindow->project()->directory());
|
result.replace("<PROJECTFILENAME>", extractFileName(pMainWindow->project()->filename()));
|
||||||
|
result.replace("<PROJECTPATH>", localizePath(pMainWindow->project()->directory()));
|
||||||
// result.replace("<SOURCESPCLIST>', MainForm.Project.ListUnitStr(' '));
|
// result.replace("<SOURCESPCLIST>', MainForm.Project.ListUnitStr(' '));
|
||||||
// result.replace("<SOURCESPCLIST>","");
|
// result.replace("<SOURCESPCLIST>","");
|
||||||
} else if (e!=nullptr) { // Non-project editor macros
|
} else if (e!=nullptr) { // Non-project editor macros
|
||||||
result.replace("<EXENAME>", changeFileExt(e->filename(),EXECUTABLE_EXT));
|
result.replace("<EXENAME>", extractFileName(changeFileExt(e->filename(),EXECUTABLE_EXT)));
|
||||||
|
result.replace("<EXEFILE>", localizePath(changeFileExt(e->filename(),EXECUTABLE_EXT)));
|
||||||
result.replace("<PROJECTNAME>", extractFileName(e->filename()));
|
result.replace("<PROJECTNAME>", extractFileName(e->filename()));
|
||||||
result.replace("<PROJECTFILE>",e->filename());
|
result.replace("<PROJECTFILE>", localizePath(e->filename()));
|
||||||
result.replace("<PROJECTPATH>", extractFileDir(e->filename()));
|
result.replace("<PROJECTFILENAME>", extractFileName(e->filename()));
|
||||||
|
result.replace("<PROJECTPATH>", localizePath(extractFileDir(e->filename())));
|
||||||
// result.replace("<SOURCESPCLIST>", ""); // clear unchanged macros
|
// result.replace("<SOURCESPCLIST>", ""); // clear unchanged macros
|
||||||
} else {
|
} else {
|
||||||
result.replace("<EXENAME>", "");
|
result.replace("<EXENAME>", "");
|
||||||
|
@ -817,8 +814,8 @@ QString parseMacros(const QString &s)
|
||||||
// Editor macros
|
// Editor macros
|
||||||
if (e!=nullptr) {
|
if (e!=nullptr) {
|
||||||
result.replace("<SOURCENAME>", extractFileName(e->filename()));
|
result.replace("<SOURCENAME>", extractFileName(e->filename()));
|
||||||
result.replace("<SOURCEFILE>", e->filename());
|
result.replace("<SOURCEFILE>", localizePath(e->filename()));
|
||||||
result.replace("<SOURCEPATH>", extractFileDir(e->filename()));
|
result.replace("<SOURCEPATH>", localizePath(extractFileDir(e->filename())));
|
||||||
result.replace("<WORDXY>", e->wordAtCursor());
|
result.replace("<WORDXY>", e->wordAtCursor());
|
||||||
} else {
|
} else {
|
||||||
result.replace("<SOURCENAME>", "");
|
result.replace("<SOURCENAME>", "");
|
||||||
|
@ -928,3 +925,10 @@ QList<QByteArray> splitByteArrayToLines(const QByteArray &content)
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString localizePath(const QString &path)
|
||||||
|
{
|
||||||
|
QString result = path;
|
||||||
|
result.replace("/",QDir::separator());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -138,7 +138,6 @@ QString genMakePath2(const QString& fileName);
|
||||||
QString getCompiledExecutableName(const QString& filename);
|
QString getCompiledExecutableName(const QString& filename);
|
||||||
void splitStringArguments(const QString& arguments, QStringList& argumentList);
|
void splitStringArguments(const QString& arguments, QStringList& argumentList);
|
||||||
bool programHasConsole(const QString& filename);
|
bool programHasConsole(const QString& filename);
|
||||||
QString toLocalPath(const QString& filename);
|
|
||||||
using LineProcessFunc = std::function<void(const QString&)>;
|
using LineProcessFunc = std::function<void(const QString&)>;
|
||||||
|
|
||||||
QStringList readStreamToLines(QTextStream* stream);
|
QStringList readStreamToLines(QTextStream* stream);
|
||||||
|
@ -178,6 +177,7 @@ bool findComplement(const QString& s,
|
||||||
int increment);
|
int increment);
|
||||||
void logToFile(const QString& s, const QString& filename, bool append=true);
|
void logToFile(const QString& s, const QString& filename, bool append=true);
|
||||||
|
|
||||||
|
QString localizePath(const QString& path);
|
||||||
QString extractFileName(const QString& fileName);
|
QString extractFileName(const QString& fileName);
|
||||||
QString extractFileDir(const QString& fileName);
|
QString extractFileDir(const QString& fileName);
|
||||||
QString extractFilePath(const QString& filePath);
|
QString extractFilePath(const QString& filePath);
|
||||||
|
|
|
@ -11,12 +11,14 @@ MacroInfoModel::MacroInfoModel(QObject *parent) : QAbstractListModel(parent)
|
||||||
addMacroInfo("<INCLUDE>", tr("The first include directory of the working compiler set."));
|
addMacroInfo("<INCLUDE>", tr("The first include directory of the working compiler set."));
|
||||||
addMacroInfo("<LIB>", tr("The first lib directory of the working compiler set."));
|
addMacroInfo("<LIB>", tr("The first lib directory of the working compiler set."));
|
||||||
addMacroInfo("<EXENAME>", tr("The compiled filename"));
|
addMacroInfo("<EXENAME>", tr("The compiled filename"));
|
||||||
|
addMacroInfo("<EXEFILE>", tr("Full path to the compiled file"));
|
||||||
addMacroInfo("<SOURCENAME>", tr("Filename of the current source file"));
|
addMacroInfo("<SOURCENAME>", tr("Filename of the current source file"));
|
||||||
addMacroInfo("<SOURCEFILE>", tr("Full path to the current source file"));
|
addMacroInfo("<SOURCEFILE>", tr("Full path to the current source file"));
|
||||||
addMacroInfo("<SOURCEPATH>", tr("Path to the current source file's parent folder"));
|
addMacroInfo("<SOURCEPATH>", tr("Path to the current source file's parent folder"));
|
||||||
addMacroInfo("<WORDXY>", tr("Word at the cursor in the active editor"));
|
addMacroInfo("<WORDXY>", tr("Word at the cursor in the active editor"));
|
||||||
addMacroInfo("<PROJECTNAME>", tr("Name of the current project"));
|
addMacroInfo("<PROJECTNAME>", tr("Name of the current project"));
|
||||||
addMacroInfo("<PROJECTFILE>", tr("Full path to the current project file"));
|
addMacroInfo("<PROJECTFILE>", tr("Full path to the current project file"));
|
||||||
|
addMacroInfo("<PROJECTFILENAME>", tr("Name of the current project file"));
|
||||||
addMacroInfo("<PROJECTPATH>", tr("Path to the current project's folder"));
|
addMacroInfo("<PROJECTPATH>", tr("Path to the current project's folder"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue