Commit 2ce52e32 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Use "clean" target

Use the "clean" in the MakeStep to clean up.

Change-Id: I7da29866a7dfc6debd70e83cc61f89b809a81cac
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 8150209f
......@@ -237,8 +237,7 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
MakeStep *cleanMakeStep = new MakeStep(cleanSteps);
cleanSteps->insertStep(0, cleanMakeStep);
cleanMakeStep->setAdditionalArguments(QLatin1String("clean"));
cleanMakeStep->setClean(true);
cleanMakeStep->setBuildTarget(MakeStep::cleanTarget(), true);
bc->setBuildDirectory(copy.buildDirectory);
bc->setInitialArguments(copy.arguments);
......
......@@ -124,7 +124,6 @@ void CMakeLocatorFilter::accept(Core::LocatorFilterEntry selection) const
// Change the make step to build only the given target
QStringList oldTargets = makeStep->buildTargets();
makeStep->setClean(false);
makeStep->clearBuildTargets();
makeStep->setBuildTarget(selection.displayName, true);
......
......@@ -64,7 +64,7 @@ using namespace ProjectExplorer;
namespace {
const char MS_ID[] = "CMakeProjectManager.MakeStep";
const char CLEAN_KEY[] = "CMakeProjectManager.MakeStep.Clean";
const char CLEAN_KEY[] = "CMakeProjectManager.MakeStep.Clean"; // Obsolete since QtC 3.7
const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets";
const char ADDITIONAL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments";
const char ADD_RUNCONFIGURATION_ARGUMENT_KEY[] = "CMakeProjectManager.MakeStep.AddRunConfigurationArgument";
......@@ -73,20 +73,19 @@ const char ADD_RUNCONFIGURATION_TEXT[] = "Current executable";
}
MakeStep::MakeStep(BuildStepList *bsl) :
AbstractProcessStep(bsl, Core::Id(MS_ID)), m_clean(false), m_addRunConfigurationArgument(false)
AbstractProcessStep(bsl, Core::Id(MS_ID)), m_addRunConfigurationArgument(false)
{
ctor();
}
MakeStep::MakeStep(BuildStepList *bsl, Core::Id id) :
AbstractProcessStep(bsl, id), m_clean(false), m_addRunConfigurationArgument(false)
AbstractProcessStep(bsl, id), m_addRunConfigurationArgument(false)
{
ctor();
}
MakeStep::MakeStep(BuildStepList *bsl, MakeStep *bs) :
AbstractProcessStep(bsl, bs),
m_clean(bs->m_clean),
m_buildTargets(bs->m_buildTargets),
m_additionalArguments(bs->m_additionalArguments),
m_addRunConfigurationArgument(bs->m_addRunConfigurationArgument),
......@@ -157,15 +156,9 @@ void MakeStep::buildTargetsChanged()
setBuildTargets(filteredTargets);
}
void MakeStep::setClean(bool clean)
{
m_clean = clean;
}
QVariantMap MakeStep::toMap() const
{
QVariantMap map(AbstractProcessStep::toMap());
map.insert(QLatin1String(CLEAN_KEY), m_clean);
map.insert(QLatin1String(BUILD_TARGETS_KEY), m_buildTargets);
map.insert(QLatin1String(ADDITIONAL_ARGUMENTS_KEY), m_additionalArguments);
map.insert(QLatin1String(ADD_RUNCONFIGURATION_ARGUMENT_KEY), m_addRunConfigurationArgument);
......@@ -175,9 +168,12 @@ QVariantMap MakeStep::toMap() const
bool MakeStep::fromMap(const QVariantMap &map)
{
m_clean = map.value(QLatin1String(CLEAN_KEY), false).toBool();
m_buildTargets = map.value(QLatin1String(BUILD_TARGETS_KEY)).toStringList();
m_additionalArguments = map.value(QLatin1String(ADDITIONAL_ARGUMENTS_KEY)).toString();
if (map.value(QLatin1String(CLEAN_KEY), false).toBool()) {
m_buildTargets = QStringList({ MakeStep::cleanTarget() });
} else {
m_buildTargets = map.value(QLatin1String(BUILD_TARGETS_KEY)).toStringList();
m_additionalArguments = map.value(QLatin1String(ADDITIONAL_ARGUMENTS_KEY)).toString();
}
m_addRunConfigurationArgument = map.value(QLatin1String(ADD_RUNCONFIGURATION_ARGUMENT_KEY), false).toBool();
m_makeCmd = map.value(QLatin1String(MAKE_COMMAND_KEY)).toString();
......@@ -225,7 +221,7 @@ bool MakeStep::init(QList<const BuildStep *> &earlierSteps)
Utils::QtcProcess::addArgs(&arguments, m_buildTargets);
Utils::QtcProcess::addArgs(&arguments, additionalArguments());
setIgnoreReturnValue(m_clean);
setIgnoreReturnValue(m_buildTargets.contains(MakeStep::cleanTarget()));
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
......@@ -375,6 +371,11 @@ QString MakeStep::userMakeCommand() const
return m_makeCmd;
}
QString MakeStep::cleanTarget()
{
return QLatin1String("clean");
}
//
// MakeStepConfigWidget
//
......@@ -557,10 +558,8 @@ BuildStep *MakeStepFactory::create(BuildStepList *parent, Core::Id id)
if (!canCreate(parent, id))
return 0;
MakeStep *step = new MakeStep(parent);
if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) {
step->setClean(true);
step->setAdditionalArguments(QLatin1String("clean"));
}
if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN)
step->setBuildTarget(MakeStep::cleanTarget(), true);
return step;
}
......
......@@ -81,12 +81,13 @@ public:
QString makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const;
void setClean(bool clean);
QVariantMap toMap() const override;
void setUserMakeCommand(const QString &make);
QString userMakeCommand() const;
static QString cleanTarget();
private:
void activeBuildConfigurationChanged();
void buildTargetsChanged();
......@@ -112,7 +113,6 @@ private:
CMakeBuildConfiguration *targetsActiveBuildConfiguration() const;
CMakeRunConfiguration *targetsActiveRunConfiguration() const;
bool m_clean;
QRegExp m_percentProgress;
QRegExp m_ninjaProgress;
QString m_ninjaProgressString;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment