McuSupport: Use aspects more directly in McuBuildStep

Change-Id: I2c4c033a23fa9e8de9f8439fbddbc0127a18c150
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-10 13:29:27 +02:00
parent 62795df12a
commit dddf16226a

View File

@@ -30,6 +30,8 @@
#include <QTemporaryDir> #include <QTemporaryDir>
#include <QVersionNumber> #include <QVersionNumber>
using namespace Utils;
namespace McuSupport::Internal { namespace McuSupport::Internal {
class DeployMcuProcessStep : public ProjectExplorer::AbstractProcessStep class DeployMcuProcessStep : public ProjectExplorer::AbstractProcessStep
@@ -43,6 +45,10 @@ public:
private: private:
QString findKitInformation(ProjectExplorer::Kit *kit, const QString &key); QString findKitInformation(ProjectExplorer::Kit *kit, const QString &key);
QTemporaryDir m_tmpDir; QTemporaryDir m_tmpDir;
FilePathAspect cmd{this};
StringAspect args{this};
FilePathAspect outDir{this};
}; };
const Utils::Id DeployMcuProcessStep::id = "QmlProject.Mcu.DeployStep"; const Utils::Id DeployMcuProcessStep::id = "QmlProject.Mcu.DeployStep";
@@ -74,14 +80,12 @@ DeployMcuProcessStep::DeployMcuProcessStep(ProjectExplorer::BuildStepList *bc, U
QString root = findKitInformation(kit, Internal::Legacy::Constants::QUL_CMAKE_VAR); QString root = findKitInformation(kit, Internal::Legacy::Constants::QUL_CMAKE_VAR);
auto rootPath = Utils::FilePath::fromString(root); auto rootPath = Utils::FilePath::fromString(root);
auto cmd = addAspect<Utils::FilePathAspect>(); cmd.setSettingsKey("QmlProject.Mcu.ProcessStep.Command");
cmd->setSettingsKey("QmlProject.Mcu.ProcessStep.Command"); cmd.setExpectedKind(PathChooser::Command);
cmd->setExpectedKind(Utils::PathChooser::Command); cmd.setLabelText(QmlProjectManager::Tr::tr("Command:"));
cmd->setLabelText(QmlProjectManager::Tr::tr("Command:")); cmd.setValue(rootPath.pathAppended("/bin/qmlprojectexporter"));
cmd->setValue(rootPath.pathAppended("/bin/qmlprojectexporter"));
const char *importPathConstant = QtSupport::Constants::KIT_QML_IMPORT_PATH; const char *importPathConstant = QtSupport::Constants::KIT_QML_IMPORT_PATH;
Utils::FilePath projectDir = buildSystem()->projectDirectory();
Utils::FilePath qulIncludeDir = Utils::FilePath::fromVariant(kit->value(importPathConstant)); Utils::FilePath qulIncludeDir = Utils::FilePath::fromVariant(kit->value(importPathConstant));
QStringList includeDirs { QStringList includeDirs {
Utils::ProcessArgs::quoteArg(qulIncludeDir.toString()), Utils::ProcessArgs::quoteArg(qulIncludeDir.toString()),
@@ -96,25 +100,23 @@ DeployMcuProcessStep::DeployMcuProcessStep(ProjectExplorer::BuildStepList *bc, U
"--include-dirs", includeDirs.join(","), "--include-dirs", includeDirs.join(","),
}; };
auto args = addAspect<Utils::StringAspect>(); args.setSettingsKey("QmlProject.Mcu.ProcessStep.Arguments");
args->setSettingsKey("QmlProject.Mcu.ProcessStep.Arguments"); args.setDisplayStyle(Utils::StringAspect::LineEditDisplay);
args->setDisplayStyle(Utils::StringAspect::LineEditDisplay); args.setLabelText(QmlProjectManager::Tr::tr("Arguments:"));
args->setLabelText(QmlProjectManager::Tr::tr("Arguments:")); args.setValue(Utils::ProcessArgs::joinArgs(arguments));
args->setValue(Utils::ProcessArgs::joinArgs(arguments));
auto outDir = addAspect<Utils::FilePathAspect>(); outDir.setSettingsKey("QmlProject.Mcu.ProcessStep.BuildDirectory");
outDir->setSettingsKey("QmlProject.Mcu.ProcessStep.BuildDirectory"); outDir.setExpectedKind(Utils::PathChooser::Directory);
outDir->setExpectedKind(Utils::PathChooser::Directory); outDir.setLabelText(QmlProjectManager::Tr::tr("Build directory:"));
outDir->setLabelText(QmlProjectManager::Tr::tr("Build directory:")); outDir.setPlaceHolderText(m_tmpDir.path());
outDir->setPlaceHolderText(m_tmpDir.path());
setCommandLineProvider([this, cmd, args, outDir]() -> Utils::CommandLine { setCommandLineProvider([this] {
auto directory = outDir->stringValue(); QString directory = outDir().path();
if (directory.isEmpty()) if (directory.isEmpty())
directory = m_tmpDir.path(); directory = m_tmpDir.path();
Utils::CommandLine cmdLine(cmd->filePath()); CommandLine cmdLine(cmd());
cmdLine.addArgs(args->value(), Utils::CommandLine::Raw); cmdLine.addArgs(args(), Utils::CommandLine::Raw);
cmdLine.addArg("--outdir"); cmdLine.addArg("--outdir");
cmdLine.addArg(directory); cmdLine.addArg(directory);
return cmdLine; return cmdLine;