summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Bengtsson <mats.m.bengtsson@stericsson.com>2012-11-16 13:35:38 +0100
committerJoerg Bornemann <joerg.bornemann@digia.com>2012-11-16 16:42:45 +0100
commit7002ca6899c72ceca73b260fc3bae09aa19bcc04 (patch)
tree27b1b6fb6ac9d0f7395930fd7f232c24295e85cf
parent3190ca8deb90ce1c36b68834f3ff34b1541706ed (diff)
Remove platform specific pathname handling
Use Qt built-in functions to handle building of pathnames. To some extent JOM can handle translation of pathnames containing backslashes for Windows into pathnames containing forward leaning slashes for Linux, and vice versa. But there is no handling of Windows/DOS drive letters. So makefiles built on one platform for consumption on another, need to take this limitation into account. Change-Id: I96c441dc36e18e7d86f1c93607fbcbe3e09de653 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--src/jomlib/commandexecutor.cpp6
-rw-r--r--src/jomlib/dependencygraph.cpp3
-rw-r--r--src/jomlib/exception.cpp4
-rw-r--r--src/jomlib/makefile.cpp5
-rw-r--r--src/jomlib/makefilefactory.cpp3
-rw-r--r--src/jomlib/parser.cpp5
-rw-r--r--src/jomlib/preprocessor.cpp4
7 files changed, 17 insertions, 13 deletions
diff --git a/src/jomlib/commandexecutor.cpp b/src/jomlib/commandexecutor.cpp
index c80240b..fc7fa8b 100644
--- a/src/jomlib/commandexecutor.cpp
+++ b/src/jomlib/commandexecutor.cpp
@@ -53,7 +53,7 @@ CommandExecutor::CommandExecutor(QObject* parent, const ProcessEnvironment &envi
DWORD count = GetTempPathW(MAX_PATH, buf);
if (count) {
m_tempPath = QString::fromWCharArray(buf, count);
- if (!m_tempPath.endsWith(QLatin1Char('\\'))) m_tempPath.append(QLatin1Char('\\'));
+ if (!m_tempPath.endsWith(QDir::separator())) m_tempPath.append(QDir::separator());
}
}
@@ -125,7 +125,7 @@ void CommandExecutor::onProcessFinished(int exitCode, Process::ExitStatus exitSt
const Command &currentCommand = m_pTarget->m_commands.at(m_currentCommandIdx);
if (exitCode > currentCommand.m_maxExitCode) {
QByteArray msg = "jom: ";
- msg += QDir::toNativeSeparators(QDir::currentPath()).toLocal8Bit() + "\\";
+ msg += QDir::toNativeSeparators(QDir::currentPath() + QDir::separator()).toLocal8Bit();
msg += m_pTarget->makefile()->fileName().toLocal8Bit();
msg += " [" + m_pTarget->targetName().toLocal8Bit() + "] Error ";
msg += QByteArray::number(exitCode);
@@ -316,7 +316,7 @@ void CommandExecutor::createTempFiles()
tempFile.file->write(content);
tempFile.file->close();
- QString replacement = QString(tempFile.file->fileName()).replace(QLatin1Char('/'), QLatin1Char('\\'));
+ QString replacement = QDir::toNativeSeparators(tempFile.file->fileName());
if (replacement.contains(QLatin1Char(' ')) || replacement.contains(QLatin1Char('\t'))) {
replacement.prepend(QLatin1Char('"'));
replacement.append(QLatin1Char('"'));
diff --git a/src/jomlib/dependencygraph.cpp b/src/jomlib/dependencygraph.cpp
index cf00a1a..51bae06 100644
--- a/src/jomlib/dependencygraph.cpp
+++ b/src/jomlib/dependencygraph.cpp
@@ -27,6 +27,7 @@
#include <QFile>
#include <QDebug>
+#include <QDir>
namespace NMakeFile {
@@ -163,7 +164,7 @@ void DependencyGraph::internalBuild(Node* node)
DescriptionBlock* dependent = makefile->target(dependentName);
if (!dependent) {
// We don't know dependent "foo" but it may have been defined as "C:\MySourceDir\foo"
- dependent = makefile->target(makefile->dirPath() + QLatin1Char('\\') + dependentName);
+ dependent = makefile->target(makefile->dirPath() + QDir::separator() + dependentName);
}
if (!dependent) {
if (!FastFileInfo(dependentName).exists()) {
diff --git a/src/jomlib/exception.cpp b/src/jomlib/exception.cpp
index dabc71f..66ec6a6 100644
--- a/src/jomlib/exception.cpp
+++ b/src/jomlib/exception.cpp
@@ -22,6 +22,8 @@
****************************************************************************/
#include "exception.h"
+#include <QDir>
+
namespace NMakeFile {
Exception::Exception(const QString& message)
@@ -47,7 +49,7 @@ const QString FileException::toString() const
if (!m_fileName.isEmpty()) {
output += QLatin1String(" in ");
QString fileName = m_fileName;
- fileName.replace(QLatin1Char('/'), QLatin1Char('\\'));
+ fileName = QDir::toNativeSeparators(fileName);
output += fileName;
output += QLatin1String(" ");
}
diff --git a/src/jomlib/makefile.cpp b/src/jomlib/makefile.cpp
index ba3a9b8..d86f280 100644
--- a/src/jomlib/makefile.cpp
+++ b/src/jomlib/makefile.cpp
@@ -25,6 +25,7 @@
#include "options.h"
#include <QFileInfo>
#include <QDebug>
+#include <QDir>
namespace NMakeFile {
@@ -376,7 +377,7 @@ QString InferenceRule::inferredDependent(const QString &targetName) const
dependent.append(m_fromExtension);
if (m_fromSearchPath != QLatin1String("."))
- dependent.prepend(m_fromSearchPath + QLatin1Char('\\'));
+ dependent.prepend(m_fromSearchPath + QDir::separator());
return dependent;
}
@@ -483,7 +484,7 @@ void Makefile::filterRulesByDependent(QVector<InferenceRule*>& rules, const QStr
// is guaranteed to end with rule->m_toExtension.
QString baseName = targetFileName;
baseName.chop(rule->m_toExtension.length());
- QString dependentName = rule->m_fromSearchPath + QLatin1Char('\\') +
+ QString dependentName = rule->m_fromSearchPath + QDir::separator() +
baseName + rule->m_fromExtension;
DescriptionBlock* depTarget = m_targets.value(dependentName);
diff --git a/src/jomlib/makefilefactory.cpp b/src/jomlib/makefilefactory.cpp
index 49601ae..9abf2fa 100644
--- a/src/jomlib/makefilefactory.cpp
+++ b/src/jomlib/makefilefactory.cpp
@@ -126,8 +126,7 @@ bool MakefileFactory::apply(const QStringList& commandLineArguments, Options **o
}
}
- options->fullAppPath = QCoreApplication::applicationFilePath();
- options->fullAppPath.replace(QLatin1Char('/'), QDir::separator());
+ options->fullAppPath = QDir::toNativeSeparators(QCoreApplication::applicationFilePath());
readEnvironment(m_environment, macroTable, options->overrideEnvVarMacros);
if (!options->ignorePredefinedRulesAndMacros) {
diff --git a/src/jomlib/parser.cpp b/src/jomlib/parser.cpp
index f2c13db..f5a51e9 100644
--- a/src/jomlib/parser.cpp
+++ b/src/jomlib/parser.cpp
@@ -27,6 +27,7 @@
#include "helperfunctions.h"
#include <QDebug>
+#include <QDir>
namespace NMakeFile {
@@ -324,8 +325,8 @@ void Parser::parseDescriptionBlock(int separatorPos, int separatorLength, int co
if (commandSeparatorPos >= 0) value.truncate(commandSeparatorPos);
value.remove(0, separatorPos + separatorLength);
value = m_preprocessor->macroTable()->expandMacros(value.trimmed(), true);
- target.replace(QLatin1Char('/'), QLatin1Char('\\'));
- value.replace(QLatin1Char('/'), QLatin1Char('\\'));
+ target = QDir::toNativeSeparators(target);
+ value = QDir::toNativeSeparators(value);
// extract command from description block line
QList<Command> commands;
diff --git a/src/jomlib/preprocessor.cpp b/src/jomlib/preprocessor.cpp
index 19730a7..3dabeaf 100644
--- a/src/jomlib/preprocessor.cpp
+++ b/src/jomlib/preprocessor.cpp
@@ -72,7 +72,7 @@ bool Preprocessor::internalOpenFile(QString fileName)
QStringList includeDirs = includeVar.split(QLatin1Char(';'), QString::SkipEmptyParts);
QString fullFileName;
foreach (const QString& includeDir, includeDirs) {
- fullFileName = includeDir + QLatin1Char('\\') + fileName;
+ fullFileName = includeDir + QDir::separator() + fileName;
if (QFile::exists(fullFileName)) {
fileName = fullFileName;
break;
@@ -88,7 +88,7 @@ bool Preprocessor::internalOpenFile(QString fileName)
}
TextFile textFile = m_fileStack.pop();
tmpStack.push(textFile);
- fullFileName = textFile.fileDirectory + QLatin1Char('\\') + fileName;
+ fullFileName = textFile.fileDirectory + QDir::separator() + fileName;
}
while (!tmpStack.isEmpty())
m_fileStack.push(tmpStack.pop());