From 665285b981e5bb12dcce246262e4cb857eac4139 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 18 Oct 2021 10:23:35 +0200 Subject: [PATCH] Docker: Map build directory to device in cmake calls Change-Id: Ibcd2e1aebac337e880a28a2a22b35d8ca60b6dcf Reviewed-by: hjk --- src/plugins/cmakeprojectmanager/cmakebuildstep.cpp | 13 ++++++++----- src/plugins/cmakeprojectmanager/cmakeprocess.cpp | 12 ++++++------ src/plugins/cmakeprojectmanager/cmakeproject.cpp | 7 ++++--- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index 2dfb70076a2..0973bbc519a 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -376,13 +377,15 @@ void CMakeBuildStep::setBuildTargets(const QStringList &buildTargets) CommandLine CMakeBuildStep::cmakeCommand() const { - CMakeTool *tool = CMakeKitAspect::cmakeTool(kit()); + CommandLine cmd; + if (CMakeTool *tool = CMakeKitAspect::cmakeTool(kit())) + cmd.setExecutable(tool->cmakeExecutable()); - CommandLine cmd(tool ? tool->cmakeExecutable() : FilePath(), {}); - QString buildDirectory = "."; + FilePath buildDirectory = "."; if (buildConfiguration()) - buildDirectory = buildConfiguration()->buildDirectory().path(); - cmd.addArgs({"--build", buildDirectory}); + buildDirectory = buildConfiguration()->buildDirectory(); + + cmd.addArgs({"--build", buildDirectory.onDevice(cmd.executable()).path()}); cmd.addArg("--target"); cmd.addArgs(Utils::transform(m_buildTargets, [this](const QString &s) { diff --git a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp index d8f24b43623..e43db3176f9 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp @@ -72,7 +72,11 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList & CMakeTool *cmake = parameters.cmakeTool(); QTC_ASSERT(parameters.isValid() && cmake, return); - const FilePath buildDirectory = parameters.buildDirectory; + const FilePath cmakeExecutable = cmake->cmakeExecutable(); + + const FilePath sourceDirectory = parameters.sourceDirectory.onDevice(cmakeExecutable); + const FilePath buildDirectory = parameters.buildDirectory.onDevice(cmakeExecutable); + if (!buildDirectory.exists()) { QString msg = tr("The build directory \"%1\" does not exist") .arg(buildDirectory.toUserOutput()); @@ -119,12 +123,8 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList & connect(process.get(), &QtcProcess::finished, this, &CMakeProcess::handleProcessFinished); - const FilePath cmakeExecutable = cmake->cmakeExecutable(); - const FilePath sourceDirectory = parameters.sourceDirectory.onDevice(cmakeExecutable); - CommandLine commandLine(cmakeExecutable); - commandLine.addArgs({"-S", sourceDirectory.mapToDevicePath(), - "-B", buildDirectory.mapToDevicePath()}); + commandLine.addArgs({"-S", sourceDirectory.path(), "-B", buildDirectory.path()}); commandLine.addArgs(arguments); TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 9f881802c5d..f201ab523be 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -140,11 +140,12 @@ MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target, config << "--config" << bc->cmakeBuildType(); } - QString buildDirectory = "."; + FilePath buildDirectory = "."; if (bc) - buildDirectory = bc->buildDirectory().toString(); + buildDirectory = bc->buildDirectory(); - cmd.arguments << "--build" << buildDirectory << "--target" << installTarget << config; + cmd.arguments << "--build" << buildDirectory.onDevice(cmd.command).mapToDevicePath() + << "--target" << installTarget << config; cmd.environment.set("DESTDIR", QDir::toNativeSeparators(installRoot)); return cmd;