2009-03-10 14:20:07 +01:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
**
|
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
**
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
**
|
|
|
|
** Commercial Usage
|
|
|
|
**
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
**
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
** contact the sales department at qt-sales@nokia.com.
|
|
|
|
**
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#include "genericproject.h"
|
|
|
|
#include "genericprojectconstants.h"
|
2009-03-18 13:33:00 +01:00
|
|
|
#include "genericmakestep.h"
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2009-03-19 16:33:44 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2009-03-10 14:20:07 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
#include <cpptools/cppmodelmanagerinterface.h>
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-03-18 13:33:00 +01:00
|
|
|
#include <utils/pathchooser.h>
|
2009-03-10 14:20:07 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
2009-03-12 13:50:43 +01:00
|
|
|
#include <QtCore/QtDebug>
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
#include <QtCore/QSettings>
|
|
|
|
#include <QtCore/QProcess>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2009-03-12 13:50:43 +01:00
|
|
|
#include <QtGui/QFormLayout>
|
|
|
|
#include <QtGui/QMainWindow>
|
|
|
|
#include <QtGui/QComboBox>
|
2009-03-12 14:34:01 +01:00
|
|
|
#include <QtGui/QStringListModel>
|
|
|
|
#include <QtGui/QListWidget>
|
2009-03-12 16:31:40 +01:00
|
|
|
#include <QtGui/QPushButton>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
using namespace GenericProjectManager;
|
|
|
|
using namespace GenericProjectManager::Internal;
|
|
|
|
|
2009-03-12 14:34:01 +01:00
|
|
|
namespace {
|
|
|
|
|
2009-03-18 14:35:35 +01:00
|
|
|
/**
|
|
|
|
* An editable string list model. New strings can be added by editing the entry
|
|
|
|
* called "<new>", displayed at the end.
|
|
|
|
*/
|
2009-03-12 14:34:01 +01:00
|
|
|
class ListModel: public QStringListModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ListModel(QObject *parent)
|
|
|
|
: QStringListModel(parent) {}
|
|
|
|
|
|
|
|
virtual ~ListModel() {}
|
|
|
|
|
|
|
|
virtual int rowCount(const QModelIndex &parent) const
|
|
|
|
{ return 1 + QStringListModel::rowCount(parent); }
|
|
|
|
|
|
|
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const
|
|
|
|
{ return QStringListModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; }
|
|
|
|
|
|
|
|
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
|
|
|
|
{
|
|
|
|
if (row == stringList().size())
|
|
|
|
return createIndex(row, column);
|
|
|
|
|
|
|
|
return QStringListModel::index(row, column, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role) const
|
|
|
|
{
|
|
|
|
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
|
|
|
if (index.row() == stringList().size())
|
|
|
|
return tr("<new>");
|
|
|
|
}
|
|
|
|
|
|
|
|
return QStringListModel::data(index, role);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
|
|
|
|
{
|
|
|
|
if (role == Qt::EditRole && index.row() == stringList().size())
|
|
|
|
insertRow(index.row(), QModelIndex());
|
|
|
|
|
|
|
|
return QStringListModel::setData(index, value, role);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end of anonymous namespace
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// GenericProject
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-03-10 14:20:07 +01:00
|
|
|
GenericProject::GenericProject(Manager *manager, const QString &fileName)
|
2009-03-18 12:18:59 +01:00
|
|
|
: m_manager(manager),
|
|
|
|
m_fileName(fileName),
|
|
|
|
m_toolChain(0)
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
QFileInfo fileInfo(m_fileName);
|
2009-03-16 11:49:57 +01:00
|
|
|
QDir dir = fileInfo.dir();
|
|
|
|
|
2009-03-19 16:33:44 +01:00
|
|
|
m_projectName = fileInfo.baseName();
|
|
|
|
m_filesFileName = QFileInfo(dir, m_projectName + QLatin1String(".files")).absoluteFilePath();
|
|
|
|
m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath();
|
|
|
|
m_configFileName = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath();
|
2009-03-16 11:49:57 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_file = new GenericProjectFile(this, fileName);
|
|
|
|
m_rootNode = new GenericProjectNode(this, m_file);
|
2009-03-16 11:08:07 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_manager->registerProject(this);
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericProject::~GenericProject()
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
m_manager->unregisterProject(this);
|
2009-03-16 11:08:07 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
delete m_rootNode;
|
|
|
|
delete m_toolChain;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
2009-03-16 11:49:57 +01:00
|
|
|
QString GenericProject::filesFileName() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_filesFileName; }
|
2009-03-16 11:49:57 +01:00
|
|
|
|
|
|
|
QString GenericProject::includesFileName() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_includesFileName; }
|
2009-03-16 11:49:57 +01:00
|
|
|
|
|
|
|
QString GenericProject::configFileName() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_configFileName; }
|
2009-03-16 11:49:57 +01:00
|
|
|
|
2009-03-16 11:08:07 +01:00
|
|
|
QStringList GenericProject::readLines(const QString &absoluteFileName) const
|
|
|
|
{
|
|
|
|
QStringList lines;
|
|
|
|
|
|
|
|
QFile file(absoluteFileName);
|
|
|
|
if (file.open(QFile::ReadOnly)) {
|
|
|
|
QTextStream stream(&file);
|
|
|
|
|
|
|
|
forever {
|
|
|
|
QString line = stream.readLine();
|
|
|
|
if (line.isNull())
|
|
|
|
break;
|
|
|
|
|
|
|
|
line = line.trimmed();
|
|
|
|
if (line.isEmpty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
lines.append(line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-12 15:07:54 +01:00
|
|
|
void GenericProject::parseProject()
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
const QFileInfo projectFileInfo(m_fileName);
|
2009-03-16 11:08:07 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
QSettings projectInfo(m_fileName, QSettings::IniFormat);
|
2009-03-12 15:07:54 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_files = convertToAbsoluteFiles(readLines(filesFileName()));
|
|
|
|
m_files.removeDuplicates();
|
2009-03-16 11:49:57 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_projectIncludePaths = readLines(includesFileName());
|
|
|
|
m_projectIncludePaths.removeDuplicates();
|
2009-03-16 11:08:07 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList());
|
2009-03-16 12:42:16 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_defines.clear();
|
2009-03-16 12:42:16 +01:00
|
|
|
|
2009-03-18 11:32:45 +01:00
|
|
|
QFile configFile(configFileName());
|
|
|
|
if (configFile.open(QFile::ReadOnly))
|
2009-03-18 12:18:59 +01:00
|
|
|
m_defines = configFile.readAll();
|
2009-03-16 11:08:07 +01:00
|
|
|
|
|
|
|
emit fileListChanged();
|
2009-03-12 15:07:54 +01:00
|
|
|
}
|
|
|
|
|
2009-03-10 14:20:07 +01:00
|
|
|
void GenericProject::refresh()
|
|
|
|
{
|
2009-03-16 11:08:07 +01:00
|
|
|
parseProject();
|
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_rootNode->refresh();
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
CppTools::CppModelManagerInterface *modelManager =
|
|
|
|
ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
|
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
if (m_toolChain && modelManager) {
|
|
|
|
const QByteArray predefinedMacros = m_toolChain->predefinedMacros();
|
|
|
|
const QList<ProjectExplorer::HeaderPath> systemHeaderPaths = m_toolChain->systemHeaderPaths();
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelManager->projectInfo(this);
|
|
|
|
pinfo.defines = predefinedMacros;
|
2009-03-16 12:42:16 +01:00
|
|
|
pinfo.defines += '\n';
|
2009-03-18 12:18:59 +01:00
|
|
|
pinfo.defines += m_defines;
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
QStringList allIncludePaths, allFrameworkPaths;
|
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
foreach (const ProjectExplorer::HeaderPath &headerPath, m_toolChain->systemHeaderPaths()) {
|
2009-03-10 14:20:07 +01:00
|
|
|
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
|
|
|
|
allFrameworkPaths.append(headerPath.path());
|
|
|
|
|
|
|
|
else
|
|
|
|
allIncludePaths.append(headerPath.path());
|
|
|
|
}
|
|
|
|
|
2009-03-13 15:12:54 +01:00
|
|
|
allIncludePaths += this->allIncludePaths();
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
pinfo.frameworkPaths = allFrameworkPaths;
|
|
|
|
pinfo.includePaths = allIncludePaths;
|
|
|
|
|
|
|
|
// ### add _defines.
|
2009-03-12 15:07:54 +01:00
|
|
|
pinfo.sourceFiles = files();
|
|
|
|
pinfo.sourceFiles += generated();
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2009-03-18 11:32:45 +01:00
|
|
|
QStringList filesToUpdate = pinfo.sourceFiles;
|
|
|
|
filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name
|
|
|
|
|
2009-03-10 14:20:07 +01:00
|
|
|
modelManager->updateProjectInfo(pinfo);
|
2009-03-18 11:32:45 +01:00
|
|
|
modelManager->updateSourceFiles(filesToUpdate);
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-12 15:07:54 +01:00
|
|
|
QStringList GenericProject::convertToAbsoluteFiles(const QStringList &paths) const
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
const QDir projectDir(QFileInfo(m_fileName).dir());
|
2009-03-12 15:07:54 +01:00
|
|
|
QStringList absolutePaths;
|
|
|
|
foreach (const QString &file, paths) {
|
|
|
|
QFileInfo fileInfo(projectDir, file);
|
|
|
|
absolutePaths.append(fileInfo.absoluteFilePath());
|
|
|
|
}
|
|
|
|
absolutePaths.removeDuplicates();
|
|
|
|
return absolutePaths;
|
|
|
|
}
|
|
|
|
|
2009-03-13 15:12:54 +01:00
|
|
|
QStringList GenericProject::allIncludePaths() const
|
|
|
|
{
|
|
|
|
QStringList paths;
|
2009-03-18 12:18:59 +01:00
|
|
|
paths += m_includePaths;
|
|
|
|
paths += m_projectIncludePaths;
|
2009-03-13 15:12:54 +01:00
|
|
|
paths.removeDuplicates();
|
|
|
|
return paths;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList GenericProject::projectIncludePaths() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_projectIncludePaths; }
|
2009-03-13 15:12:54 +01:00
|
|
|
|
2009-03-12 15:07:54 +01:00
|
|
|
QStringList GenericProject::files() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_files; }
|
2009-03-12 15:07:54 +01:00
|
|
|
|
|
|
|
QStringList GenericProject::generated() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_generated; }
|
2009-03-12 15:07:54 +01:00
|
|
|
|
|
|
|
QStringList GenericProject::includePaths() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_includePaths; }
|
2009-03-12 15:07:54 +01:00
|
|
|
|
|
|
|
void GenericProject::setIncludePaths(const QStringList &includePaths)
|
2009-03-18 12:18:59 +01:00
|
|
|
{ m_includePaths = includePaths; }
|
2009-03-12 15:07:54 +01:00
|
|
|
|
2009-03-16 12:42:16 +01:00
|
|
|
QByteArray GenericProject::defines() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_defines; }
|
2009-03-12 15:07:54 +01:00
|
|
|
|
|
|
|
void GenericProject::setToolChainId(const QString &toolChainId)
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_toolChainId = toolChainId;
|
2009-03-12 13:50:43 +01:00
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
delete m_toolChain;
|
|
|
|
m_toolChain = 0;
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
if (toolChainId == QLatin1String("mingw")) {
|
|
|
|
const QLatin1String qmake_cxx("g++"); // ### FIXME
|
|
|
|
const QString mingwDirectory; // ### FIXME
|
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
m_toolChain = ToolChain::createMinGWToolChain(qmake_cxx, mingwDirectory);
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
} else if (toolChainId == QLatin1String("msvc")) {
|
|
|
|
const QString msvcVersion; // ### FIXME
|
2009-03-18 12:18:59 +01:00
|
|
|
m_toolChain = ToolChain::createMSVCToolChain(msvcVersion);
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
} else if (toolChainId == QLatin1String("wince")) {
|
|
|
|
const QString msvcVersion, wincePlatform; // ### FIXME
|
2009-03-18 12:18:59 +01:00
|
|
|
m_toolChain = ToolChain::createWinCEToolChain(msvcVersion, wincePlatform);
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
} else if (toolChainId == QLatin1String("gcc") || toolChainId == QLatin1String("icc")) {
|
|
|
|
const QLatin1String qmake_cxx("g++"); // ### FIXME
|
2009-03-18 12:18:59 +01:00
|
|
|
m_toolChain = ToolChain::createGccToolChain(qmake_cxx);
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString GenericProject::buildParser(const QString &buildConfiguration) const
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
if (m_toolChain) {
|
|
|
|
switch (m_toolChain->type()) {
|
2009-03-10 14:20:07 +01:00
|
|
|
case ProjectExplorer::ToolChain::GCC:
|
|
|
|
case ProjectExplorer::ToolChain::LinuxICC:
|
|
|
|
case ProjectExplorer::ToolChain::MinGW:
|
|
|
|
return QLatin1String(ProjectExplorer::Constants::BUILD_PARSER_GCC);
|
|
|
|
|
|
|
|
case ProjectExplorer::ToolChain::MSVC:
|
|
|
|
case ProjectExplorer::ToolChain::WINCE:
|
|
|
|
return ProjectExplorer::Constants::BUILD_PARSER_MSVC;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} // switch
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2009-03-18 14:35:35 +01:00
|
|
|
ProjectExplorer::ToolChain *GenericProject::toolChain() const
|
|
|
|
{
|
|
|
|
return m_toolChain;
|
|
|
|
}
|
|
|
|
|
2009-03-12 13:50:43 +01:00
|
|
|
QString GenericProject::toolChainId() const
|
2009-03-18 12:18:59 +01:00
|
|
|
{ return m_toolChainId; }
|
2009-03-12 13:50:43 +01:00
|
|
|
|
2009-03-10 14:20:07 +01:00
|
|
|
QString GenericProject::name() const
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
return m_projectName;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Core::IFile *GenericProject::file() const
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
return m_file;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExplorer::IProjectManager *GenericProject::projectManager() const
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
return m_manager;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QList<ProjectExplorer::Project *> GenericProject::dependsOn()
|
|
|
|
{
|
|
|
|
return QList<Project *>();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GenericProject::isApplication() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExplorer::Environment GenericProject::environment(const QString &) const
|
|
|
|
{
|
|
|
|
return ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString GenericProject::buildDirectory(const QString &buildConfiguration) const
|
|
|
|
{
|
|
|
|
QString buildDirectory = value(buildConfiguration, "buildDirectory").toString();
|
|
|
|
|
|
|
|
if (buildDirectory.isEmpty()) {
|
2009-03-18 12:18:59 +01:00
|
|
|
QFileInfo fileInfo(m_fileName);
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
buildDirectory = fileInfo.absolutePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
return buildDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExplorer::BuildStepConfigWidget *GenericProject::createConfigWidget()
|
|
|
|
{
|
|
|
|
return new GenericBuildSettingsWidget(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<ProjectExplorer::BuildStepConfigWidget*> GenericProject::subConfigWidgets()
|
|
|
|
{
|
|
|
|
return QList<ProjectExplorer::BuildStepConfigWidget*>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenericProject::newBuildConfiguration(const QString &buildConfiguration)
|
|
|
|
{
|
|
|
|
makeStep()->setBuildTarget(buildConfiguration, "all", true);
|
|
|
|
}
|
|
|
|
|
2009-03-12 13:50:43 +01:00
|
|
|
GenericProjectNode *GenericProject::rootProjectNode() const
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
return m_rootNode;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList GenericProject::files(FilesMode fileMode) const
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
return m_files; // ### TODO: handle generated files here.
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList GenericProject::targets() const
|
|
|
|
{
|
|
|
|
QStringList targets;
|
|
|
|
targets.append(QLatin1String("all"));
|
|
|
|
targets.append(QLatin1String("clean"));
|
|
|
|
return targets;
|
|
|
|
}
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
GenericMakeStep *GenericProject::makeStep() const
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
|
|
|
foreach (ProjectExplorer::BuildStep *bs, buildSteps()) {
|
2009-03-18 13:33:00 +01:00
|
|
|
if (GenericMakeStep *ms = qobject_cast<GenericMakeStep *>(bs))
|
2009-03-10 14:20:07 +01:00
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
|
|
|
|
{
|
|
|
|
Project::restoreSettingsImpl(reader);
|
|
|
|
|
|
|
|
if (buildConfigurations().isEmpty()) {
|
2009-03-18 13:33:00 +01:00
|
|
|
GenericMakeStep *makeStep = new GenericMakeStep(this);
|
2009-03-10 14:20:07 +01:00
|
|
|
insertBuildStep(0, makeStep);
|
|
|
|
|
|
|
|
const QLatin1String all("all");
|
|
|
|
|
|
|
|
addBuildConfiguration(all);
|
|
|
|
setActiveBuildConfiguration(all);
|
|
|
|
makeStep->setBuildTarget(all, all, /* on = */ true);
|
|
|
|
|
|
|
|
const QLatin1String buildDirectory("buildDirectory");
|
|
|
|
|
|
|
|
const QFileInfo fileInfo(file()->fileName());
|
|
|
|
setValue(all, buildDirectory, fileInfo.absolutePath());
|
|
|
|
}
|
2009-03-12 12:26:32 +01:00
|
|
|
|
|
|
|
QString toolChainId = reader.restoreValue(QLatin1String("toolChain")).toString();
|
|
|
|
if (toolChainId.isEmpty())
|
|
|
|
toolChainId = QLatin1String("gcc");
|
|
|
|
|
2009-03-12 15:07:54 +01:00
|
|
|
setToolChainId(toolChainId.toLower()); // ### move
|
2009-03-13 15:12:54 +01:00
|
|
|
|
|
|
|
const QStringList userIncludePaths =
|
|
|
|
reader.restoreValue(QLatin1String("includePaths")).toStringList();
|
|
|
|
|
|
|
|
setIncludePaths(allIncludePaths());
|
2009-03-12 12:26:32 +01:00
|
|
|
|
2009-03-12 15:07:54 +01:00
|
|
|
parseProject();
|
|
|
|
refresh();
|
2009-03-12 12:26:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
|
|
|
|
{
|
|
|
|
Project::saveSettingsImpl(writer);
|
|
|
|
|
2009-03-18 12:18:59 +01:00
|
|
|
writer.saveValue(QLatin1String("toolChain"), m_toolChainId);
|
|
|
|
writer.saveValue(QLatin1String("includePaths"), m_includePaths);
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// GenericBuildSettingsWidget
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
2009-03-18 13:33:00 +01:00
|
|
|
|
2009-03-10 14:20:07 +01:00
|
|
|
GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project)
|
2009-03-18 12:18:59 +01:00
|
|
|
: m_project(project)
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
|
|
|
QFormLayout *fl = new QFormLayout(this);
|
2009-03-12 14:34:01 +01:00
|
|
|
|
|
|
|
// build directory
|
2009-03-18 12:18:59 +01:00
|
|
|
m_pathChooser = new Core::Utils::PathChooser(this);
|
|
|
|
m_pathChooser->setEnabled(true);
|
|
|
|
fl->addRow(tr("Build directory:"), m_pathChooser);
|
|
|
|
connect(m_pathChooser, SIGNAL(changed()), this, SLOT(buildDirectoryChanged()));
|
2009-03-12 13:50:43 +01:00
|
|
|
|
2009-03-12 14:34:01 +01:00
|
|
|
// tool chain
|
2009-03-12 13:50:43 +01:00
|
|
|
QComboBox *toolChainChooser = new QComboBox;
|
|
|
|
toolChainChooser->addItems(ProjectExplorer::ToolChain::supportedToolChains());
|
2009-03-18 12:18:59 +01:00
|
|
|
toolChainChooser->setCurrentIndex(toolChainChooser->findText(m_project->toolChainId()));
|
2009-03-12 14:34:01 +01:00
|
|
|
fl->addRow(tr("Tool chain:"), toolChainChooser);
|
2009-03-18 12:18:59 +01:00
|
|
|
connect(toolChainChooser, SIGNAL(activated(QString)), m_project, SLOT(setToolChainId(QString)));
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericBuildSettingsWidget::~GenericBuildSettingsWidget()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
QString GenericBuildSettingsWidget::displayName() const
|
|
|
|
{ return tr("Generic Manager"); }
|
|
|
|
|
|
|
|
void GenericBuildSettingsWidget::init(const QString &buildConfiguration)
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
m_buildConfiguration = buildConfiguration;
|
|
|
|
m_pathChooser->setPath(m_project->buildDirectory(buildConfiguration));
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GenericBuildSettingsWidget::buildDirectoryChanged()
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
m_project->setValue(m_buildConfiguration, "buildDirectory", m_pathChooser->path());
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// GenericProjectFile
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
2009-03-18 13:33:00 +01:00
|
|
|
|
2009-03-10 14:20:07 +01:00
|
|
|
GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName)
|
|
|
|
: Core::IFile(parent),
|
2009-03-18 12:18:59 +01:00
|
|
|
m_project(parent),
|
|
|
|
m_fileName(fileName)
|
2009-03-10 14:20:07 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
GenericProjectFile::~GenericProjectFile()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool GenericProjectFile::save(const QString &)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString GenericProjectFile::fileName() const
|
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
return m_fileName;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString GenericProjectFile::defaultPath() const
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString GenericProjectFile::suggestedFileName() const
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString GenericProjectFile::mimeType() const
|
|
|
|
{
|
|
|
|
return Constants::GENERICMIMETYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GenericProjectFile::isModified() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GenericProjectFile::isReadOnly() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GenericProjectFile::isSaveAsAllowed() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenericProjectFile::modified(ReloadBehavior *)
|
|
|
|
{
|
|
|
|
}
|