Commit 5c651c9f authored by Tobias Hunger's avatar Tobias Hunger
Browse files

/target/buildtarget/g in cmakeprojectmanager

This is in preparation of the addition of "targets" in the
sense of "platforms to develop for" into the codebase.

Reviewed-by: dt
parent 5173c2dc
......@@ -297,7 +297,7 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
cmProject->parseCMakeLists();
// Default to all
if (cmProject->hasTarget("all"))
if (cmProject->hasBuildTarget("all"))
makeStep->setBuildTarget("all", true);
return bc;
......
......@@ -205,7 +205,7 @@ bool CMakeProject::parseCMakeLists()
buildTree(m_rootNode, fileList);
//qDebug()<<"Adding Targets";
m_targets = cbpparser.targets();
m_buildTargets = cbpparser.buildTargets();
// qDebug()<<"Printing targets";
// foreach(CMakeTarget ct, m_targets) {
// qDebug()<<ct.title<<" with executable:"<<ct.executable;
......@@ -257,7 +257,7 @@ bool CMakeProject::parseCMakeLists()
}
bool setActive = existingRunConfigurations.isEmpty();
foreach(const CMakeTarget &ct, m_targets) {
foreach(const CMakeBuildTarget &ct, m_buildTargets) {
if (ct.executable.isEmpty())
continue;
if (ct.title.endsWith(QLatin1String("/fast")))
......@@ -299,17 +299,17 @@ bool CMakeProject::parseCMakeLists()
// TODO report error
qDebug()<<"Parsing failed";
// activeBC->updateToolChain(QString::null);
emit targetsChanged();
emit buildTargetsChanged();
return false;
}
emit targetsChanged();
emit buildTargetsChanged();
return true;
}
QStringList CMakeProject::targets() const
QStringList CMakeProject::buildTargetTitles() const
{
QStringList results;
foreach (const CMakeTarget &ct, m_targets) {
foreach (const CMakeBuildTarget &ct, m_buildTargets) {
if (ct.executable.isEmpty())
continue;
if (ct.title.endsWith(QLatin1String("/fast")))
......@@ -319,9 +319,9 @@ QStringList CMakeProject::targets() const
return results;
}
bool CMakeProject::hasTarget(const QString &title) const
bool CMakeProject::hasBuildTarget(const QString &title) const
{
foreach (const CMakeTarget &ct, m_targets) {
foreach (const CMakeBuildTarget &ct, m_buildTargets) {
if (ct.executable.isEmpty())
continue;
if (ct.title.endsWith(QLatin1String("/fast")))
......@@ -556,7 +556,7 @@ bool CMakeProject::fromMap(const QVariantMap &map)
if (!result)
return false;
if (!hasUserFile && hasTarget("all"))
if (!hasUserFile && hasBuildTarget("all"))
makeStep->setBuildTarget("all", true);
m_lastActiveBuildConfiguration = activeCMakeBuildConfiguration();
......@@ -569,12 +569,12 @@ bool CMakeProject::fromMap(const QVariantMap &map)
return true;
}
CMakeTarget CMakeProject::targetForTitle(const QString &title)
CMakeBuildTarget CMakeProject::buildTargetForTitle(const QString &title)
{
foreach(const CMakeTarget &ct, m_targets)
foreach(const CMakeBuildTarget &ct, m_buildTargets)
if (ct.title == title)
return ct;
return CMakeTarget();
return CMakeBuildTarget();
}
// CMakeFile
......@@ -747,45 +747,45 @@ void CMakeCbpParser::parseBuild()
if (isEndElement()) {
return;
} else if (name() == "Target") {
parseTarget();
parseBuildTarget();
} else if (isStartElement()) {
parseUnknownElement();
}
}
}
void CMakeCbpParser::parseTarget()
void CMakeCbpParser::parseBuildTarget()
{
m_targetType = false;
m_target.clear();
m_buildTargetType = false;
m_buildTarget.clear();
if (attributes().hasAttribute("title"))
m_target.title = attributes().value("title").toString();
m_buildTarget.title = attributes().value("title").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
if (m_targetType || m_target.title == "all" || m_target.title == "install") {
m_targets.append(m_target);
if (m_buildTargetType || m_buildTarget.title == "all" || m_buildTarget.title == "install") {
m_buildTargets.append(m_buildTarget);
}
return;
} else if (name() == "Compiler") {
parseCompiler();
} else if (name() == "Option") {
parseTargetOption();
parseBuildTargetOption();
} else if (isStartElement()) {
parseUnknownElement();
}
}
}
void CMakeCbpParser::parseTargetOption()
void CMakeCbpParser::parseBuildTargetOption()
{
if (attributes().hasAttribute("output"))
m_target.executable = attributes().value("output").toString();
m_buildTarget.executable = attributes().value("output").toString();
else if (attributes().hasAttribute("type") && (attributes().value("type") == "1" || attributes().value("type") == "0"))
m_targetType = true;
m_buildTargetType = true;
else if (attributes().hasAttribute("working_dir"))
m_target.workingDirectory = attributes().value("working_dir").toString();
m_buildTarget.workingDirectory = attributes().value("working_dir").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
......@@ -828,19 +828,19 @@ void CMakeCbpParser::parseMakeCommand()
if (isEndElement()) {
return;
} else if (name() == "Build") {
parseTargetBuild();
parseBuildTargetBuild();
} else if (name() == "Clean") {
parseTargetClean();
parseBuildTargetClean();
} else if (isStartElement()) {
parseUnknownElement();
}
}
}
void CMakeCbpParser::parseTargetBuild()
void CMakeCbpParser::parseBuildTargetBuild()
{
if (attributes().hasAttribute("command"))
m_target.makeCommand = attributes().value("command").toString();
m_buildTarget.makeCommand = attributes().value("command").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
......@@ -851,10 +851,10 @@ void CMakeCbpParser::parseTargetBuild()
}
}
void CMakeCbpParser::parseTargetClean()
void CMakeCbpParser::parseBuildTargetClean()
{
if (attributes().hasAttribute("command"))
m_target.makeCleanCommand = attributes().value("command").toString();
m_buildTarget.makeCleanCommand = attributes().value("command").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
......@@ -972,9 +972,9 @@ QStringList CMakeCbpParser::includeFiles()
return m_includeFiles;
}
QList<CMakeTarget> CMakeCbpParser::targets()
QList<CMakeBuildTarget> CMakeCbpParser::buildTargets()
{
return m_targets;
return m_buildTargets;
}
QString CMakeCbpParser::compilerName() const
......@@ -982,7 +982,7 @@ QString CMakeCbpParser::compilerName() const
return m_compiler;
}
void CMakeTarget::clear()
void CMakeBuildTarget::clear()
{
executable = QString::null;
makeCommand = QString::null;
......
......@@ -53,7 +53,7 @@ namespace Internal {
class CMakeFile;
class CMakeBuildSettingsWidget;
struct CMakeTarget
struct CMakeBuildTarget
{
QString title;
QString executable;
......@@ -90,10 +90,11 @@ public:
ProjectExplorer::ProjectNode *rootProjectNode() const;
QStringList files(FilesMode fileMode) const;
QStringList targets() const;
bool hasTarget(const QString &title) const;
QStringList buildTargetTitles() const;
QList<CMakeBuildTarget> buildTargets() const;
bool hasBuildTarget(const QString &title) const;
CMakeTarget targetForTitle(const QString &title);
CMakeBuildTarget buildTargetForTitle(const QString &title);
QString sourceDirectory() const;
......@@ -102,7 +103,7 @@ signals:
/// or if the activeBuildConfiguration changes
void environmentChanged();
/// emitted after parsing
void targetsChanged();
void buildTargetsChanged();
protected:
bool fromMap(const QVariantMap &map);
......@@ -130,7 +131,7 @@ private:
// TODO probably need a CMake specific node structure
CMakeProjectNode *m_rootNode;
QStringList m_files;
QList<CMakeTarget> m_targets;
QList<CMakeBuildTarget> m_buildTargets;
ProjectExplorer::FileWatcher *m_watcher;
bool m_insideFileChanged;
QSet<QString> m_watchedFiles;
......@@ -146,7 +147,7 @@ public:
QList<ProjectExplorer::FileNode *> fileList();
QList<ProjectExplorer::FileNode *> cmakeFileList();
QStringList includeFiles();
QList<CMakeTarget> targets();
QList<CMakeBuildTarget> buildTargets();
QString projectName() const;
QString compilerName() const;
bool hasCMakeFiles();
......@@ -155,11 +156,11 @@ private:
void parseProject();
void parseBuild();
void parseOption();
void parseTarget();
void parseTargetOption();
void parseBuildTarget();
void parseBuildTargetOption();
void parseMakeCommand();
void parseTargetBuild();
void parseTargetClean();
void parseBuildTargetBuild();
void parseBuildTargetClean();
void parseCompiler();
void parseAdd();
void parseUnit();
......@@ -172,9 +173,9 @@ private:
bool m_parsingCmakeUnit;
QStringList m_includeFiles;
CMakeTarget m_target;
bool m_targetType;
QList<CMakeTarget> m_targets;
CMakeBuildTarget m_buildTarget;
bool m_buildTargetType;
QList<CMakeBuildTarget> m_buildTargets;
QString m_projectName;
QString m_compiler;
};
......
......@@ -59,14 +59,14 @@ const char * const ARGUMENTS_KEY("CMakeProjectManager.CMakeRunConfiguration.Argu
const char * const USER_ENVIRONMENT_CHANGES_KEY("CMakeProjectManager.CMakeRunConfiguration.UserEnvironmentChanges");
const char * const BASE_ENVIRONMENT_BASE_KEY("CMakeProjectManager.BaseEnvironmentBase");
QString targetFromId(const QString &id)
QString buildTargetFromId(const QString &id)
{
if (!id.startsWith(QLatin1String(CMAKE_RC_PREFIX)))
return QString();
return id.mid(QString::fromLatin1(CMAKE_RC_PREFIX).length());
}
QString idFromTarget(const QString &target)
QString idFromBuildTarget(const QString &target)
{
return QString::fromLatin1(CMAKE_RC_PREFIX) + target;
}
......@@ -76,7 +76,7 @@ QString idFromTarget(const QString &target)
CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory, const QString &title) :
ProjectExplorer::LocalApplicationRunConfiguration(pro, QString::fromLatin1(CMAKE_RC_PREFIX)),
m_runMode(Gui),
m_target(target),
m_buildTarget(target),
m_workingDirectory(workingDirectory),
m_title(title),
m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase)
......@@ -87,7 +87,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &t
CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, CMakeRunConfiguration *source) :
ProjectExplorer::LocalApplicationRunConfiguration(pro, source),
m_runMode(source->m_runMode),
m_target(source->m_target),
m_buildTarget(source->m_buildTarget),
m_workingDirectory(source->m_workingDirectory),
m_userWorkingDirectory(source->m_userWorkingDirectory),
m_title(source->m_title),
......@@ -117,7 +117,7 @@ CMakeProject *CMakeRunConfiguration::cmakeProject() const
QString CMakeRunConfiguration::executable() const
{
return m_target;
return m_buildTarget;
}
ProjectExplorer::LocalApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const
......@@ -144,7 +144,7 @@ QString CMakeRunConfiguration::title() const
void CMakeRunConfiguration::setExecutable(const QString &executable)
{
m_target = executable;
m_buildTarget = executable;
}
void CMakeRunConfiguration::setWorkingDirectory(const QString &wd)
......@@ -173,7 +173,7 @@ QVariantMap CMakeRunConfiguration::toMap() const
{
QVariantMap map(ProjectExplorer::LocalApplicationRunConfiguration::toMap());
map.insert(QLatin1String(TARGET_KEY), m_target);
map.insert(QLatin1String(TARGET_KEY), m_buildTarget);
map.insert(QLatin1String(WORKING_DIRECTORY_KEY), m_workingDirectory);
map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory);
map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == Console);
......@@ -187,7 +187,7 @@ QVariantMap CMakeRunConfiguration::toMap() const
bool CMakeRunConfiguration::fromMap(const QVariantMap &map)
{
m_target = map.value(QLatin1String(TARGET_KEY)).toString();
m_buildTarget = map.value(QLatin1String(TARGET_KEY)).toString();
m_workingDirectory = map.value(QLatin1String(WORKING_DIRECTORY_KEY)).toString();
m_userWorkingDirectory = map.value(QLatin1String(USER_WORKING_DIRECTORY_KEY)).toString();
m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() ? Console : Gui;
......@@ -453,15 +453,15 @@ QStringList CMakeRunConfigurationFactory::availableCreationIds(ProjectExplorer::
if (!project)
return QStringList();
QStringList allIds;
foreach (const QString &target, project->targets())
allIds << idFromTarget(target);
foreach (const QString &buildTarget, project->buildTargetTitles())
allIds << idFromBuildTarget(buildTarget);
return allIds;
}
// used to translate the ids to names to display to the user
QString CMakeRunConfigurationFactory::displayNameForId(const QString &id) const
{
return targetFromId(id);
return buildTargetFromId(id);
}
bool CMakeRunConfigurationFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
......@@ -469,7 +469,7 @@ bool CMakeRunConfigurationFactory::canCreate(ProjectExplorer::Project *parent, c
CMakeProject *project(qobject_cast<CMakeProject *>(parent));
if (!project)
return false;
return project->hasTarget(targetFromId(id));
return project->hasBuildTarget(buildTargetFromId(id));
}
ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::create(ProjectExplorer::Project *parent, const QString &id)
......@@ -478,8 +478,8 @@ ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::create(ProjectE
return 0;
CMakeProject *project(static_cast<CMakeProject *>(parent));
const QString title(targetFromId(id));
const CMakeTarget &ct = project->targetForTitle(title);
const QString title(buildTargetFromId(id));
const CMakeBuildTarget &ct = project->buildTargetForTitle(title);
return new CMakeRunConfiguration(project, ct.executable, ct.workingDirectory, ct.title);
}
......
......@@ -106,7 +106,7 @@ private:
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
RunMode m_runMode;
QString m_target;
QString m_buildTarget;
QString m_workingDirectory;
QString m_userWorkingDirectory;
QString m_title;
......
......@@ -172,18 +172,18 @@ void MakeStep::stdOut(const QString &line)
AbstractProcessStep::stdOutput(line);
}
bool MakeStep::buildsTarget(const QString &target) const
bool MakeStep::buildsBuildTarget(const QString &target) const
{
return m_buildTargets.contains(target);
}
void MakeStep::setBuildTarget(const QString &target, bool on)
void MakeStep::setBuildTarget(const QString &buildTarget, bool on)
{
QStringList old = m_buildTargets;
if (on && !old.contains(target))
old << target;
else if(!on && old.contains(target))
old.removeOne(target);
if (on && !old.contains(buildTarget))
old << buildTarget;
else if(!on && old.contains(buildTarget))
old.removeOne(buildTarget);
m_buildTargets = old;
}
......@@ -214,20 +214,20 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
connect(m_additionalArguments, SIGNAL(textEdited(const QString &)), this, SLOT(additionalArgumentsEdited()));
m_targetsList = new QListWidget;
m_targetsList->setMinimumHeight(200);
fl->addRow(tr("Targets:"), m_targetsList);
m_buildTargetsList = new QListWidget;
m_buildTargetsList->setMinimumHeight(200);
fl->addRow(tr("Targets:"), m_buildTargetsList);
// TODO update this list also on rescans of the CMakeLists.txt
// TODO shouldn't be accessing project
CMakeProject *pro = m_makeStep->cmakeBuildConfiguration()->cmakeProject();
foreach(const QString& target, pro->targets()) {
QListWidgetItem *item = new QListWidgetItem(target, m_targetsList);
foreach(const QString& buildTarget, pro->buildTargetTitles()) {
QListWidgetItem *item = new QListWidgetItem(buildTarget, m_buildTargetsList);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(Qt::Unchecked);
}
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
this, SLOT(updateDetails()));
......@@ -253,34 +253,34 @@ QString MakeStepConfigWidget::displayName() const
void MakeStepConfigWidget::init()
{
// disconnect to make the changes to the items
disconnect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
int count = m_targetsList->count();
disconnect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
int count = m_buildTargetsList->count();
for(int i = 0; i < count; ++i) {
QListWidgetItem *item = m_targetsList->item(i);
item->setCheckState(m_makeStep->buildsTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
QListWidgetItem *item = m_buildTargetsList->item(i);
item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
}
// and connect again
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
m_additionalArguments->setText(Environment::joinArgumentList(m_makeStep->additionalArguments()));
updateDetails();
CMakeProject *pro = m_makeStep->cmakeBuildConfiguration()->cmakeProject();
connect(pro, SIGNAL(targetsChanged()),
this, SLOT(targetsChanged()));
connect(pro, SIGNAL(buildTargetsChanged()),
this, SLOT(buildTargetsChanged()));
}
void MakeStepConfigWidget::targetsChanged()
void MakeStepConfigWidget::buildTargetsChanged()
{
disconnect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
m_targetsList->clear();
disconnect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
m_buildTargetsList->clear();
CMakeProject *pro = m_makeStep->cmakeBuildConfiguration()->cmakeProject();
foreach(const QString& target, pro->targets()) {
QListWidgetItem *item = new QListWidgetItem(target, m_targetsList);
foreach(const QString& buildTarget, pro->buildTargetTitles()) {
QListWidgetItem *item = new QListWidgetItem(buildTarget, m_buildTargetsList);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(m_makeStep->buildsTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
}
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
updateSummary();
}
......
......@@ -63,7 +63,7 @@ public:
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
virtual bool immutable() const;
bool buildsTarget(const QString &target) const;
bool buildsBuildTarget(const QString &target) const;
void setBuildTarget(const QString &target, bool on);
QStringList additionalArguments() const;
void setAdditionalArguments(const QStringList &list);
......@@ -103,10 +103,10 @@ private slots:
void itemChanged(QListWidgetItem*);
void additionalArgumentsEdited();
void updateDetails();
void targetsChanged();
void buildTargetsChanged();
private:
MakeStep *m_makeStep;
QListWidget *m_targetsList;
QListWidget *m_buildTargetsList;
QLineEdit *m_additionalArguments;
QString m_summaryText;
};
......
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