ProjectExplorer: Use FilePath in installRoot machinery

Helps to get path delimiters right.

Change-Id: Ifaab593a530c667488b7b5e6546041d8c212ece8
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-06-10 15:23:22 +02:00
parent eb886ad40b
commit e2e5d67bc3
9 changed files with 22 additions and 22 deletions

View File

@@ -117,7 +117,7 @@ ProjectExplorer::DeploymentKnowledge CMakeProject::deploymentKnowledge() const
} }
MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target, MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target,
const QString &installRoot) const FilePath &installRoot)
{ {
MakeInstallCommand cmd; MakeInstallCommand cmd;
if (const BuildConfiguration * const bc = target->activeBuildConfiguration()) { if (const BuildConfiguration * const bc = target->activeBuildConfiguration()) {
@@ -131,12 +131,12 @@ MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target,
QStringList config; QStringList config;
auto bs = qobject_cast<CMakeBuildSystem*>(target->buildSystem()); auto bs = qobject_cast<CMakeBuildSystem*>(target->buildSystem());
if (bs) { QTC_ASSERT(bs, return {});
if (bs->usesAllCapsTargets()) if (bs->usesAllCapsTargets())
installTarget = "INSTALL"; installTarget = "INSTALL";
if (bs->isMultiConfigReader()) if (bs->isMultiConfigReader())
config << "--config" << bs->cmakeBuildType(); config << "--config" << bs->cmakeBuildType();
}
FilePath buildDirectory = "."; FilePath buildDirectory = ".";
if (auto bc = bs->buildConfiguration()) if (auto bc = bs->buildConfiguration())
@@ -148,7 +148,7 @@ MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target,
cmd.command.addArg(installTarget); cmd.command.addArg(installTarget);
cmd.command.addArgs(config); cmd.command.addArgs(config);
cmd.environment.set("DESTDIR", QDir::toNativeSeparators(installRoot)); cmd.environment.set("DESTDIR", installRoot.nativePath());
return cmd; return cmd;
} }

View File

@@ -55,7 +55,7 @@ protected:
private: private:
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override; ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
ProjectExplorer::MakeInstallCommand makeInstallCommand(const ProjectExplorer::Target *target, ProjectExplorer::MakeInstallCommand makeInstallCommand(const ProjectExplorer::Target *target,
const QString &installRoot) override; const Utils::FilePath &installRoot) final;
mutable Internal::CMakeProjectImporter *m_projectImporter = nullptr; mutable Internal::CMakeProjectImporter *m_projectImporter = nullptr;

View File

@@ -25,9 +25,7 @@
#include "mesonproject.h" #include "mesonproject.h"
#include "mesonbuildsystem.h"
#include "mesonpluginconstants.h" #include "mesonpluginconstants.h"
#include "exewrappers/mesontools.h"
#include "settings/tools/kitaspect/mesontoolkitaspect.h" #include "settings/tools/kitaspect/mesontoolkitaspect.h"
#include "settings/tools/kitaspect/ninjatoolkitaspect.h" #include "settings/tools/kitaspect/ninjatoolkitaspect.h"
@@ -79,8 +77,8 @@ ProjectExplorer::DeploymentKnowledge MesonProject::deploymentKnowledge() const
return ProjectExplorer::DeploymentKnowledge::Bad; return ProjectExplorer::DeploymentKnowledge::Bad;
} }
ProjectExplorer::MakeInstallCommand MesonProject::makeInstallCommand( ProjectExplorer::MakeInstallCommand MesonProject::makeInstallCommand(const ProjectExplorer::Target *target,
const ProjectExplorer::Target *target, const QString &installRoot) const Utils::FilePath &installRoot)
{ {
Q_UNUSED(target) Q_UNUSED(target)
Q_UNUSED(installRoot) Q_UNUSED(installRoot)

View File

@@ -47,7 +47,7 @@ public:
private: private:
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override; ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
ProjectExplorer::MakeInstallCommand makeInstallCommand(const ProjectExplorer::Target *target, ProjectExplorer::MakeInstallCommand makeInstallCommand(const ProjectExplorer::Target *target,
const QString &installRoot) override; const Utils::FilePath &installRoot) final;
mutable std::unique_ptr<MesonProjectImporter> m_projectImporter; mutable std::unique_ptr<MesonProjectImporter> m_projectImporter;
}; };

View File

@@ -971,7 +971,7 @@ bool Project::hasMakeInstallEquivalent() const
return d->m_hasMakeInstallEquivalent; return d->m_hasMakeInstallEquivalent;
} }
MakeInstallCommand Project::makeInstallCommand(const Target *target, const QString &installRoot) MakeInstallCommand Project::makeInstallCommand(const Target *target, const FilePath &installRoot)
{ {
QTC_ASSERT(hasMakeInstallEquivalent(), return MakeInstallCommand()); QTC_ASSERT(hasMakeInstallEquivalent(), return MakeInstallCommand());
MakeInstallCommand cmd; MakeInstallCommand cmd;
@@ -980,7 +980,7 @@ MakeInstallCommand Project::makeInstallCommand(const Target *target, const QStri
cmd.command.setExecutable(makeStep->makeExecutable()); cmd.command.setExecutable(makeStep->makeExecutable());
} }
cmd.command.addArg("install"); cmd.command.addArg("install");
cmd.command.addArg("INSTALL_ROOT=" + QDir::toNativeSeparators(installRoot)); cmd.command.addArg("INSTALL_ROOT=" + installRoot.nativePath());
return cmd; return cmd;
} }

View File

@@ -149,7 +149,8 @@ public:
virtual DeploymentKnowledge deploymentKnowledge() const { return DeploymentKnowledge::Bad; } virtual DeploymentKnowledge deploymentKnowledge() const { return DeploymentKnowledge::Bad; }
bool hasMakeInstallEquivalent() const; bool hasMakeInstallEquivalent() const;
virtual MakeInstallCommand makeInstallCommand(const Target *target, const QString &installRoot); virtual MakeInstallCommand makeInstallCommand(const Target *target,
const Utils::FilePath &installRoot);
void setup(const QList<BuildInfo> &infoList); void setup(const QList<BuildInfo> &infoList);
Utils::MacroExpander *macroExpander() const; Utils::MacroExpander *macroExpander() const;

View File

@@ -803,7 +803,7 @@ QVariant Target::additionalData(Utils::Id id) const
return {}; return {};
} }
MakeInstallCommand Target::makeInstallCommand(const QString &installRoot) const MakeInstallCommand Target::makeInstallCommand(const FilePath &installRoot) const
{ {
return project()->makeInstallCommand(this, installRoot); return project()->makeInstallCommand(this, installRoot);
} }

View File

@@ -114,7 +114,7 @@ public:
void setNamedSettings(const QString &name, const QVariant &value); void setNamedSettings(const QString &name, const QVariant &value);
QVariant additionalData(Utils::Id id) const; QVariant additionalData(Utils::Id id) const;
MakeInstallCommand makeInstallCommand(const QString &installRoot) const; MakeInstallCommand makeInstallCommand(const Utils::FilePath &installRoot) const;
Utils::MacroExpander *macroExpander() const; Utils::MacroExpander *macroExpander() const;

View File

@@ -118,7 +118,8 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent
QTemporaryDir tmpDir; QTemporaryDir tmpDir;
installRootAspect->setFilePath(FilePath::fromString(tmpDir.path())); installRootAspect->setFilePath(FilePath::fromString(tmpDir.path()));
const MakeInstallCommand cmd = target()->makeInstallCommand(tmpDir.path());
const MakeInstallCommand cmd = target()->makeInstallCommand(FilePath::fromString(tmpDir.path()));
QTC_ASSERT(!cmd.command.isEmpty(), return); QTC_ASSERT(!cmd.command.isEmpty(), return);
makeAspect->setExecutable(cmd.command.executable()); makeAspect->setExecutable(cmd.command.executable());
} }
@@ -167,7 +168,7 @@ bool MakeInstallStep::init()
"last in the list of deploy steps. " "last in the list of deploy steps. "
"Consider moving it up."))); "Consider moving it up.")));
} }
const MakeInstallCommand cmd = target()->makeInstallCommand(rootDir.path()); const MakeInstallCommand cmd = target()->makeInstallCommand(rootDir);
if (cmd.environment.isValid()) { if (cmd.environment.isValid()) {
Environment env = processParameters()->environment(); Environment env = processParameters()->environment();
for (auto it = cmd.environment.constBegin(); it != cmd.environment.constEnd(); ++it) { for (auto it = cmd.environment.constBegin(); it != cmd.environment.constEnd(); ++it) {
@@ -255,7 +256,7 @@ void MakeInstallStep::updateArgsFromAspect()
if (customCommandLineAspect()->isChecked()) if (customCommandLineAspect()->isChecked())
return; return;
const CommandLine cmd = target()->makeInstallCommand(installRoot().toString()).command; const CommandLine cmd = target()->makeInstallCommand(installRoot()).command;
setUserArguments(cmd.arguments()); setUserArguments(cmd.arguments());
updateFullCommandLine(); updateFullCommandLine();
} }