diff --git a/src/plugins/qmakeprojectmanager/makefileparse.cpp b/src/plugins/qmakeprojectmanager/makefileparse.cpp index 04048801b21..86c25935eeb 100644 --- a/src/plugins/qmakeprojectmanager/makefileparse.cpp +++ b/src/plugins/qmakeprojectmanager/makefileparse.cpp @@ -26,28 +26,26 @@ #include "makefileparse.h" #include -#include + #include #include #include #include +#include #include #include -#include using namespace ProjectExplorer; -using namespace Utils;; - -using QtSupport::QtVersionManager; -using QtSupport::BaseQtVersion; +using namespace QtSupport; +using namespace Utils; namespace QmakeProjectManager { namespace Internal { -static QString findQMakeLine(const QString &makefile, const QString &key) +static QString findQMakeLine(const FilePath &makefile, const QString &key) { - QFile fi(makefile); + QFile fi(makefile.toString()); if (fi.exists() && fi.open(QFile::ReadOnly)) { QTextStream ts(&fi); while (!ts.atEnd()) { @@ -247,9 +245,9 @@ QList MakeFileParse::parseAssignments(const QList -#include #include +#include +#include namespace QmakeProjectManager { namespace Internal { @@ -43,13 +43,13 @@ class MakeFileParse { public: enum class Mode { FilterKnownConfigValues, DoNotFilterKnownConfigValues }; - MakeFileParse(const QString &makefile, Mode mode); + MakeFileParse(const Utils::FilePath &makefile, Mode mode); enum MakefileState { MakefileMissing, CouldNotParse, Okay }; MakefileState makeFileState() const; Utils::FilePath qmakePath() const; - QString srcProFile() const; + Utils::FilePath srcProFile() const; QMakeStepConfig config() const; QString unparsedArguments() const; @@ -78,7 +78,7 @@ private: const Mode m_mode; MakefileState m_state; Utils::FilePath m_qmakePath; - QString m_srcProFile; + Utils::FilePath m_srcProFile; QmakeBuildConfig m_qmakeBuildConfig; QMakeStepConfig m_config; diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp index 11a17c186ab..8fffcc56b88 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp @@ -171,9 +171,9 @@ QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target, Utils::Id id) this, &QmakeBuildConfiguration::kitChanged); MacroExpander *expander = macroExpander(); expander->registerVariable("Qmake:Makefile", "Qmake makefile", [this]() -> QString { - const QString file = makefile(); + const FilePath file = makefile(); if (!file.isEmpty()) - return file; + return file.path(); return QLatin1String("Makefile"); }); @@ -275,13 +275,8 @@ void QmakeBuildConfiguration::updateProblemLabel() // we only show if we actually have a qmake and makestep QString errorString; if (qmakeStep() && makeStep()) { - QString makefile = buildDirectory().toString() + QLatin1Char('/'); - if (this->makefile().isEmpty()) - makefile.append(QLatin1String("Makefile")); - else - makefile.append(this->makefile()); - - switch (compareToImportFrom(makefile, &errorString)) { + const QString makeFile = this->makefile().isEmpty() ? "Makefile" : makefile().path(); + switch (compareToImportFrom(buildDirectory() / makeFile, &errorString)) { case QmakeBuildConfiguration::MakefileMatches: allGood = true; break; @@ -382,9 +377,9 @@ void QmakeBuildConfiguration::setFileNodeBuild(FileNode *node) m_fileNodeBuild = node; } -QString QmakeBuildConfiguration::makefile() const +FilePath QmakeBuildConfiguration::makefile() const { - return m_buildSystem->rootProFile()->singleVariableValue(Variable::Makefile); + return FilePath::fromString(m_buildSystem->rootProFile()->singleVariableValue(Variable::Makefile)); } BaseQtVersion::QmakeBuildConfigs QmakeBuildConfiguration::qmakeBuildConfiguration() const @@ -507,7 +502,7 @@ QmakeBuildSystem *QmakeBuildConfiguration::qmakeBuildSystem() const } // Returns true if both are equal. -QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportFrom(const QString &makefile, QString *errorString) +QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportFrom(const FilePath &makefile, QString *errorString) { const QLoggingCategory &logs = MakeFileParse::logging(); qCDebug(logs) << "QMakeBuildConfiguration::compareToImport"; @@ -537,9 +532,9 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF return MakefileForWrongProject; } - const Utils::FilePath projectPath = + const FilePath projectPath = m_subNodeBuild ? m_subNodeBuild->filePath() : qs->project()->projectFilePath(); - if (parse.srcProFile() != projectPath.toString()) { + if (parse.srcProFile() != projectPath) { qCDebug(logs) << "**Different profile used to generate the Makefile:" << parse.srcProFile() << " expected profile:" << projectPath; if (errorString) @@ -548,8 +543,8 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF } if (version->qmakeFilePath() != parse.qmakePath()) { - qCDebug(logs) << "**Different Qt versions, buildconfiguration:" << version->qmakeFilePath().toString() - << " Makefile:"<< parse.qmakePath().toString(); + qCDebug(logs) << "**Different Qt versions, buildconfiguration:" << version->qmakeFilePath() + << " Makefile:" << parse.qmakePath(); return MakefileForWrongProject; } @@ -567,7 +562,7 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF // now compare arguments lists // we have to compare without the spec/platform cmd argument // and compare that on its own - QString workingDirectory = QFileInfo(makefile).absolutePath(); + FilePath workingDirectory = makefile.parentDir(); QStringList actualArgs; QString allArgs = macroExpander()->expandProcessArgs(qs->allArguments( QtKitAspect::qtVersion(target()->kit()), QMakeStep::ArgumentFlag::Expand)); @@ -639,7 +634,8 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF } QString QmakeBuildConfiguration::extractSpecFromArguments(QString *args, - const QString &directory, const BaseQtVersion *version, + const FilePath &directory, + const BaseQtVersion *version, QStringList *outArgs) { FilePath parsedSpec; @@ -684,8 +680,8 @@ QString QmakeBuildConfiguration::extractSpecFromArguments(QString *args, // if it is the former we need to get the canonical form // for the other one we don't need to do anything if (parsedSpec.toFileInfo().isRelative()) { - if (QFileInfo::exists(directory + QLatin1Char('/') + parsedSpec.toString())) - parsedSpec = FilePath::fromUserInput(directory + QLatin1Char('/') + parsedSpec.toString()); + if (QFileInfo::exists(directory.path() + QLatin1Char('/') + parsedSpec.toString())) + parsedSpec = FilePath::fromUserInput(directory.path() + QLatin1Char('/') + parsedSpec.toString()); else parsedSpec = FilePath::fromUserInput(baseMkspecDir.toString() + QLatin1Char('/') + parsedSpec.toString()); } diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.h b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.h index 92b2bc13def..5eee78efbea 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.h +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.h @@ -79,12 +79,12 @@ public: QmakeBuildSystem *qmakeBuildSystem() const; - QString makefile() const; + Utils::FilePath makefile() const; enum MakefileState { MakefileMatches, MakefileForWrongProject, MakefileIncompatible, MakefileMissing }; - MakefileState compareToImportFrom(const QString &makefile, QString *errorString = nullptr); + MakefileState compareToImportFrom(const Utils::FilePath &makefile, QString *errorString = nullptr); static QString extractSpecFromArguments( - QString *arguments, const QString &directory, const QtSupport::BaseQtVersion *version, + QString *arguments, const Utils::FilePath &directory, const QtSupport::BaseQtVersion *version, QStringList *outArgs = nullptr); QVariantMap toMap() const override; diff --git a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp index 1c3d4c50a58..0dee4c3f8ac 100644 --- a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp @@ -138,10 +138,10 @@ bool QmakeMakeStep::init() m_makeFileToCheck = workingDirectory / makefile; } else { - QString makefile = bc->makefile(); + FilePath makefile = bc->makefile(); if (!makefile.isEmpty()) { - makeCmd.addArgs({"-f", makefile}); - m_makeFileToCheck = workingDirectory / makefile; + makeCmd.addArgs({"-f", makefile.path()}); + m_makeFileToCheck = workingDirectory / makefile.path(); } else { m_makeFileToCheck = workingDirectory / "Makefile"; } @@ -257,7 +257,7 @@ QStringList QmakeMakeStep::displayArguments() const { const auto bc = static_cast(buildConfiguration()); if (bc && !bc->makefile().isEmpty()) - return {"-f", bc->makefile()}; + return {"-f", bc->makefile().path()}; return {}; } diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp index bbeeb4bea60..8966731659f 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp @@ -127,19 +127,18 @@ QList QmakeProjectImporter::examineDirectory(const FilePath &importPath, qCDebug(logs) << " Parsing makefile" << file; // find interesting makefiles - QString makefile = importPath.toString() + QLatin1Char('/') + file; + const FilePath makefile = importPath / file; MakeFileParse parse(makefile, MakeFileParse::Mode::FilterKnownConfigValues); if (parse.makeFileState() != MakeFileParse::Okay) { qCDebug(logs) << " Parsing the makefile failed" << makefile; continue; } - if (parse.srcProFile() != projectFilePath().toString()) { + if (parse.srcProFile() != projectFilePath()) { qCDebug(logs) << " pro files doesn't match" << parse.srcProFile() << projectFilePath(); continue; } - QFileInfo qmakeFi = parse.qmakePath().toFileInfo(); - data->canonicalQmakeBinary = FilePath::fromString(qmakeFi.canonicalFilePath()); + data->canonicalQmakeBinary = parse.qmakePath().canonicalPath(); if (data->canonicalQmakeBinary.isEmpty()) { qCDebug(logs) << " " << parse.qmakePath() << "doesn't exist anymore"; continue; @@ -184,7 +183,7 @@ QList QmakeProjectImporter::examineDirectory(const FilePath &importPath, data->additionalArguments = parse.unparsedArguments(); qCDebug(logs) << " Unparsed arguments:" << data->additionalArguments; data->parsedSpec = - QmakeBuildConfiguration::extractSpecFromArguments(&(data->additionalArguments), importPath.toString(), version); + QmakeBuildConfiguration::extractSpecFromArguments(&(data->additionalArguments), importPath, version); qCDebug(logs) << " Extracted spec:" << data->parsedSpec; qCDebug(logs) << " Arguments now:" << data->additionalArguments; diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index 94adb3279df..a74b8b5f32e 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -220,20 +220,22 @@ bool QMakeStep::init() // The Makefile is used by qmake and make on the build device, from that // perspective it is local. - QString makefile = workingDirectory.path() + '/'; + QString make; if (qmakeBc->subNodeBuild()) { QmakeProFileNode *pro = qmakeBc->subNodeBuild(); if (pro && !pro->makefile().isEmpty()) - makefile.append(pro->makefile()); + make = pro->makefile(); else - makefile.append("Makefile"); + make = "Makefile"; } else if (!qmakeBc->makefile().isEmpty()) { - makefile.append(qmakeBc->makefile()); + make = qmakeBc->makefile().path(); } else { - makefile.append("Makefile"); + make = "Makefile"; } + FilePath makeFile = workingDirectory / make; + if (m_runMakeQmake) { const FilePath make = makeCommand(); if (make.isEmpty()) { @@ -242,14 +244,14 @@ bool QMakeStep::init() BuildStep::OutputFormat::ErrorMessage); return false; } - m_makeCommand = CommandLine{make, makeArguments(makefile), CommandLine::Raw}; + m_makeCommand = CommandLine{make, makeArguments(makeFile.path()), CommandLine::Raw}; } else { m_makeCommand = {}; } // Check whether we need to run qmake if (m_forced || QmakeSettings::alwaysRunQmake() - || qmakeBc->compareToImportFrom(makefile) != QmakeBuildConfiguration::MakefileMatches) { + || qmakeBc->compareToImportFrom(makeFile) != QmakeBuildConfiguration::MakefileMatches) { m_needToRunQMake = true; } m_forced = false; @@ -433,20 +435,22 @@ QString QMakeStep::makeArguments(const QString &makefile) const QString QMakeStep::effectiveQMakeCall() const { BaseQtVersion *qtVersion = QtKitAspect::qtVersion(kit()); - QString qmake = qtVersion ? qtVersion->qmakeFilePath().toUserOutput() : QString(); + FilePath qmake = qtVersion ? qtVersion->qmakeFilePath() : FilePath(); if (qmake.isEmpty()) - qmake = tr(""); - QString make = makeCommand().toUserOutput(); + qmake = FilePath::fromString(tr("")); + FilePath make = makeCommand(); if (make.isEmpty()) - make = tr(""); + make = FilePath::fromString(tr("")); - QString result = qmake; + CommandLine cmd(qmake, {}); + + QString result = qmake.toString(); if (qtVersion) { QmakeBuildConfiguration *qmakeBc = qmakeBuildConfiguration(); - const QString makefile = qmakeBc ? qmakeBc->makefile() : QString(); + const FilePath makefile = qmakeBc ? qmakeBc->makefile() : FilePath(); result += ' ' + allArguments(qtVersion, ArgumentFlag::Expand); if (qtVersion->qtVersion() >= QtVersionNumber(5, 0, 0)) - result.append(QString::fromLatin1(" && %1 %2").arg(make).arg(makeArguments(makefile))); + result.append(QString(" && %1 %2").arg(make.path()).arg(makeArguments(makefile.path()))); } return result; }