forked from qt-creator/qt-creator
CMake: Use aspects more directly in CMakeBuildStep
Change-Id: Id12381556439ef6b3e56307a169830bb18da9003 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -208,37 +208,34 @@ static bool supportsStageForInstallation(const Kit *kit)
|
|||||||
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
|
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
|
||||||
CMakeAbstractProcessStep(bsl, id)
|
CMakeAbstractProcessStep(bsl, id)
|
||||||
{
|
{
|
||||||
m_cmakeArguments = addAspect<StringAspect>();
|
cmakeArguments.setSettingsKey(CMAKE_ARGUMENTS_KEY);
|
||||||
m_cmakeArguments->setSettingsKey(CMAKE_ARGUMENTS_KEY);
|
cmakeArguments.setLabelText(Tr::tr("CMake arguments:"));
|
||||||
m_cmakeArguments->setLabelText(Tr::tr("CMake arguments:"));
|
cmakeArguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
||||||
m_cmakeArguments->setDisplayStyle(StringAspect::LineEditDisplay);
|
|
||||||
|
|
||||||
m_toolArguments = addAspect<StringAspect>();
|
toolArguments.setSettingsKey(TOOL_ARGUMENTS_KEY);
|
||||||
m_toolArguments->setSettingsKey(TOOL_ARGUMENTS_KEY);
|
toolArguments.setLabelText(Tr::tr("Tool arguments:"));
|
||||||
m_toolArguments->setLabelText(Tr::tr("Tool arguments:"));
|
toolArguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
||||||
m_toolArguments->setDisplayStyle(StringAspect::LineEditDisplay);
|
|
||||||
|
|
||||||
m_useStaging = addAspect<BoolAspect>();
|
useStaging.setSettingsKey(USE_STAGING_KEY);
|
||||||
m_useStaging->setSettingsKey(USE_STAGING_KEY);
|
useStaging.setLabel(Tr::tr("Stage for installation"), BoolAspect::LabelPlacement::AtCheckBox);
|
||||||
m_useStaging->setLabel(Tr::tr("Stage for installation"), BoolAspect::LabelPlacement::AtCheckBox);
|
useStaging.setDefaultValue(supportsStageForInstallation(kit()));
|
||||||
m_useStaging->setDefaultValue(supportsStageForInstallation(kit()));
|
|
||||||
|
|
||||||
m_stagingDir = addAspect<FilePathAspect>();
|
stagingDir.setSettingsKey(STAGING_DIR_KEY);
|
||||||
m_stagingDir->setSettingsKey(STAGING_DIR_KEY);
|
stagingDir.setLabelText(Tr::tr("Staging directory:"));
|
||||||
m_stagingDir->setLabelText(Tr::tr("Staging directory:"));
|
stagingDir.setDefaultValue(FilePath::fromUserInput(initialStagingDir(kit())));
|
||||||
m_stagingDir->setDefaultValue(FilePath::fromUserInput(initialStagingDir(kit())));
|
|
||||||
|
|
||||||
Kit *kit = buildConfiguration()->kit();
|
Kit *kit = buildConfiguration()->kit();
|
||||||
if (CMakeBuildConfiguration::isIos(kit)) {
|
if (CMakeBuildConfiguration::isIos(kit)) {
|
||||||
m_useiOSAutomaticProvisioningUpdates = addAspect<BoolAspect>();
|
useiOSAutomaticProvisioningUpdates.setDefaultValue(true);
|
||||||
m_useiOSAutomaticProvisioningUpdates->setDefaultValue(true);
|
useiOSAutomaticProvisioningUpdates.setSettingsKey(
|
||||||
m_useiOSAutomaticProvisioningUpdates->setSettingsKey(
|
IOS_AUTOMATIC_PROVISIONG_UPDATES_ARGUMENTS_KEY);
|
||||||
IOS_AUTOMATIC_PROVISIONG_UPDATES_ARGUMENTS_KEY);
|
useiOSAutomaticProvisioningUpdates.setLabel(
|
||||||
m_useiOSAutomaticProvisioningUpdates->setLabel(
|
Tr::tr("Enable automatic provisioning updates:"));
|
||||||
Tr::tr("Enable automatic provisioning updates:"));
|
useiOSAutomaticProvisioningUpdates.setToolTip(
|
||||||
m_useiOSAutomaticProvisioningUpdates->setToolTip(
|
Tr::tr("Tells xcodebuild to create and download a provisioning profile "
|
||||||
Tr::tr("Tells xcodebuild to create and download a provisioning profile "
|
"if a valid one does not exist."));
|
||||||
"if a valid one does not exist."));
|
} else {
|
||||||
|
useiOSAutomaticProvisioningUpdates.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_buildTargetModel.setHeader({Tr::tr("Target")});
|
m_buildTargetModel.setHeader({Tr::tr("Target")});
|
||||||
@@ -259,8 +256,8 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
|
|||||||
env.set("NINJA_STATUS", ninjaProgressString + "%o/sec] ");
|
env.set("NINJA_STATUS", ninjaProgressString + "%o/sec] ");
|
||||||
env.modify(m_userEnvironmentChanges);
|
env.modify(m_userEnvironmentChanges);
|
||||||
|
|
||||||
if (m_useStaging)
|
if (useStaging())
|
||||||
env.set("DESTDIR", currentStagingDir());
|
env.set("DESTDIR", stagingDir().path());
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(target(), &Target::parsingFinished, this, [this](bool success) {
|
connect(target(), &Target::parsingFinished, this, [this](bool success) {
|
||||||
@@ -450,7 +447,7 @@ CommandLine CMakeBuildStep::cmakeCommand() const
|
|||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}));
|
}));
|
||||||
if (m_useStaging->value())
|
if (useStaging())
|
||||||
cmd.addArg("install");
|
cmd.addArg("install");
|
||||||
|
|
||||||
auto bs = qobject_cast<CMakeBuildSystem *>(buildSystem());
|
auto bs = qobject_cast<CMakeBuildSystem *>(buildSystem());
|
||||||
@@ -462,17 +459,16 @@ CommandLine CMakeBuildStep::cmakeCommand() const
|
|||||||
cmd.addArg(bs->cmakeBuildType());
|
cmd.addArg(bs->cmakeBuildType());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_cmakeArguments->value().isEmpty())
|
cmd.addArgs(cmakeArguments(), CommandLine::Raw);
|
||||||
cmd.addArgs(m_cmakeArguments->value(), CommandLine::Raw);
|
|
||||||
|
|
||||||
bool toolArgumentsSpecified = false;
|
bool toolArgumentsSpecified = false;
|
||||||
if (!m_toolArguments->value().isEmpty()) {
|
if (!toolArguments().isEmpty()) {
|
||||||
cmd.addArg("--");
|
cmd.addArg("--");
|
||||||
cmd.addArgs(m_toolArguments->value(), CommandLine::Raw);
|
cmd.addArgs(toolArguments(), CommandLine::Raw);
|
||||||
toolArgumentsSpecified = true;
|
toolArgumentsSpecified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_useiOSAutomaticProvisioningUpdates && m_useiOSAutomaticProvisioningUpdates->value()) {
|
if (useiOSAutomaticProvisioningUpdates()) {
|
||||||
// Only add the double dash if it wasn't added before.
|
// Only add the double dash if it wasn't added before.
|
||||||
if (!toolArgumentsSpecified)
|
if (!toolArgumentsSpecified)
|
||||||
cmd.addArg("--");
|
cmd.addArg("--");
|
||||||
@@ -525,12 +521,12 @@ QWidget *CMakeBuildStep::createConfigWidget()
|
|||||||
|
|
||||||
QString summaryText = param.summary(displayName());
|
QString summaryText = param.summary(displayName());
|
||||||
|
|
||||||
m_stagingDir->setEnabled(m_useStaging->value());
|
stagingDir.setEnabled(useStaging());
|
||||||
if (m_useStaging->value()) {
|
if (useStaging()) {
|
||||||
//: Stage (for installation) at <staging_dir> for <installation_dir>
|
//: Stage (for installation) at <staging_dir> for <installation_dir>
|
||||||
summaryText.append(
|
summaryText.append(
|
||||||
"; "
|
"; "
|
||||||
+ Tr::tr("Stage at %2 for %3").arg(currentStagingDir(), currentInstallPrefix()));
|
+ Tr::tr("Stage at %2 for %3").arg(stagingDir().path(), currentInstallPrefix()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_buildPreset.isEmpty()) {
|
if (!m_buildPreset.isEmpty()) {
|
||||||
@@ -591,13 +587,11 @@ QWidget *CMakeBuildStep::createConfigWidget()
|
|||||||
};
|
};
|
||||||
|
|
||||||
Layouting::Form builder;
|
Layouting::Form builder;
|
||||||
builder.addRow({m_cmakeArguments});
|
builder.addRow({cmakeArguments});
|
||||||
builder.addRow({m_toolArguments});
|
builder.addRow({toolArguments});
|
||||||
builder.addRow({m_useStaging});
|
builder.addRow({useStaging});
|
||||||
builder.addRow({m_stagingDir});
|
builder.addRow({stagingDir});
|
||||||
|
builder.addRow({useiOSAutomaticProvisioningUpdates});
|
||||||
if (m_useiOSAutomaticProvisioningUpdates)
|
|
||||||
builder.addRow({m_useiOSAutomaticProvisioningUpdates});
|
|
||||||
|
|
||||||
builder.addRow({new QLabel(Tr::tr("Targets:")), frame});
|
builder.addRow({new QLabel(Tr::tr("Targets:")), frame});
|
||||||
|
|
||||||
@@ -609,13 +603,11 @@ QWidget *CMakeBuildStep::createConfigWidget()
|
|||||||
|
|
||||||
updateDetails();
|
updateDetails();
|
||||||
|
|
||||||
connect(m_cmakeArguments, &StringAspect::changed, this, updateDetails);
|
connect(&cmakeArguments, &BaseAspect::changed, this, updateDetails);
|
||||||
connect(m_toolArguments, &StringAspect::changed, this, updateDetails);
|
connect(&toolArguments, &BaseAspect::changed, this, updateDetails);
|
||||||
connect(m_useStaging, &BoolAspect::changed, this, updateDetails);
|
connect(&useStaging, &BaseAspect::changed, this, updateDetails);
|
||||||
connect(m_stagingDir, &StringAspect::changed, this, updateDetails);
|
connect(&stagingDir, &BaseAspect::changed, this, updateDetails);
|
||||||
|
connect(&useiOSAutomaticProvisioningUpdates, &BaseAspect::changed, this, updateDetails);
|
||||||
if (m_useiOSAutomaticProvisioningUpdates)
|
|
||||||
connect(m_useiOSAutomaticProvisioningUpdates, &BoolAspect::changed, this, updateDetails);
|
|
||||||
|
|
||||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||||
this, updateDetails);
|
this, updateDetails);
|
||||||
@@ -685,12 +677,12 @@ void CMakeBuildStep::setConfiguration(const QString &configuration)
|
|||||||
|
|
||||||
void CMakeBuildStep::setToolArguments(const QStringList &nativeToolArguments)
|
void CMakeBuildStep::setToolArguments(const QStringList &nativeToolArguments)
|
||||||
{
|
{
|
||||||
m_toolArguments->setValue(nativeToolArguments.join(" "));
|
toolArguments.setValue(nativeToolArguments.join(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeBuildStep::setCMakeArguments(const QStringList &cmakeArguments)
|
void CMakeBuildStep::setCMakeArguments(const QStringList &cmakeArgs)
|
||||||
{
|
{
|
||||||
m_cmakeArguments->setValue(cmakeArguments.join(" "));
|
cmakeArguments.setValue(cmakeArgs.join(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment CMakeBuildStep::environment() const
|
Environment CMakeBuildStep::environment() const
|
||||||
@@ -763,11 +755,6 @@ QString CMakeBuildStep::currentInstallPrefix() const
|
|||||||
return QString::fromUtf8(config.valueOf("CMAKE_INSTALL_PREFIX"));
|
return QString::fromUtf8(config.valueOf("CMAKE_INSTALL_PREFIX"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMakeBuildStep::currentStagingDir() const
|
|
||||||
{
|
|
||||||
return m_stagingDir->filePath().path();
|
|
||||||
}
|
|
||||||
|
|
||||||
FilePath CMakeBuildStep::cmakeExecutable() const
|
FilePath CMakeBuildStep::cmakeExecutable() const
|
||||||
{
|
{
|
||||||
CMakeTool *tool = CMakeKitAspect::cmakeTool(kit());
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(kit());
|
||||||
@@ -776,12 +763,11 @@ FilePath CMakeBuildStep::cmakeExecutable() const
|
|||||||
|
|
||||||
void CMakeBuildStep::updateDeploymentData()
|
void CMakeBuildStep::updateDeploymentData()
|
||||||
{
|
{
|
||||||
if (!m_useStaging->value())
|
if (!useStaging())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString install = currentInstallPrefix();
|
QString install = currentInstallPrefix();
|
||||||
QString stagingDir = currentStagingDir();
|
FilePath rootDir = cmakeExecutable().withNewPath(stagingDir().path());
|
||||||
FilePath rootDir = cmakeExecutable().withNewPath(stagingDir);
|
|
||||||
Q_UNUSED(install);
|
Q_UNUSED(install);
|
||||||
|
|
||||||
DeploymentData deploymentData;
|
DeploymentData deploymentData;
|
||||||
|
@@ -70,6 +70,12 @@ public:
|
|||||||
|
|
||||||
void setConfiguration(const QString &configuration);
|
void setConfiguration(const QString &configuration);
|
||||||
|
|
||||||
|
Utils::StringAspect cmakeArguments{this};
|
||||||
|
Utils::StringAspect toolArguments{this};
|
||||||
|
Utils::BoolAspect useiOSAutomaticProvisioningUpdates{this};
|
||||||
|
Utils::BoolAspect useStaging{this};
|
||||||
|
Utils::FilePathAspect stagingDir{this};
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void buildTargetsChanged();
|
void buildTargetsChanged();
|
||||||
void environmentChanged();
|
void environmentChanged();
|
||||||
@@ -86,7 +92,6 @@ private:
|
|||||||
|
|
||||||
Utils::FilePath cmakeExecutable() const;
|
Utils::FilePath cmakeExecutable() const;
|
||||||
QString currentInstallPrefix() const;
|
QString currentInstallPrefix() const;
|
||||||
QString currentStagingDir() const;
|
|
||||||
|
|
||||||
QString defaultBuildTarget() const;
|
QString defaultBuildTarget() const;
|
||||||
bool isCleanStep() const;
|
bool isCleanStep() const;
|
||||||
@@ -98,11 +103,6 @@ private:
|
|||||||
|
|
||||||
friend class CMakeBuildStepConfigWidget;
|
friend class CMakeBuildStepConfigWidget;
|
||||||
QStringList m_buildTargets; // Convention: Empty string member signifies "Current executable"
|
QStringList m_buildTargets; // Convention: Empty string member signifies "Current executable"
|
||||||
Utils::StringAspect *m_cmakeArguments = nullptr;
|
|
||||||
Utils::StringAspect *m_toolArguments = nullptr;
|
|
||||||
Utils::BoolAspect *m_useiOSAutomaticProvisioningUpdates = nullptr;
|
|
||||||
Utils::BoolAspect *m_useStaging = nullptr;
|
|
||||||
Utils::FilePathAspect *m_stagingDir = nullptr;
|
|
||||||
|
|
||||||
QString m_allTarget = "all";
|
QString m_allTarget = "all";
|
||||||
QString m_installTarget = "install";
|
QString m_installTarget = "install";
|
||||||
|
Reference in New Issue
Block a user