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

View File

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

View File

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

View File

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

View File

@@ -971,7 +971,7 @@ bool Project::hasMakeInstallEquivalent() const
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());
MakeInstallCommand cmd;
@@ -980,7 +980,7 @@ MakeInstallCommand Project::makeInstallCommand(const Target *target, const QStri
cmd.command.setExecutable(makeStep->makeExecutable());
}
cmd.command.addArg("install");
cmd.command.addArg("INSTALL_ROOT=" + QDir::toNativeSeparators(installRoot));
cmd.command.addArg("INSTALL_ROOT=" + installRoot.nativePath());
return cmd;
}

View File

@@ -149,7 +149,8 @@ public:
virtual DeploymentKnowledge deploymentKnowledge() const { return DeploymentKnowledge::Bad; }
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);
Utils::MacroExpander *macroExpander() const;

View File

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

View File

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

View File

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