forked from qt-creator/qt-creator
Qt4PM: Build current file
Task-number: QTCREATORBUG-106 Change-Id: I3511f57b9128073104f6691a469f9c54d64138c3 Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
committed by
Daniel Teske
parent
eb6b9c98c8
commit
72bf41b40f
@@ -204,6 +204,24 @@ bool MakeStep::init()
|
||||
Utils::QtcProcess::addArg(&args, bc->defaultMakeTarget());
|
||||
}
|
||||
|
||||
if (bc->fileNodeBuild()) {
|
||||
Qt4ProjectManager::Qt4ProFileNode *proNode = bc->subNodeBuild();
|
||||
if (!proNode) {
|
||||
Qt4Project *qt4project = qobject_cast<Qt4Project *>(project());
|
||||
if (qt4project)
|
||||
proNode = qt4project->rootQt4ProjectNode();
|
||||
}
|
||||
if (proNode) {
|
||||
QString objectsDir = QDir(pp->workingDirectory()).relativeFilePath(
|
||||
proNode->objectsDirectory());
|
||||
if (!objectsDir.isEmpty())
|
||||
objectsDir += QLatin1Char('/');
|
||||
QString objectFile = objectsDir +
|
||||
QFileInfo(bc->fileNodeBuild()->path()).baseName() +
|
||||
proNode->objectExtension();
|
||||
Utils::QtcProcess::addArg(&args, objectFile);
|
||||
}
|
||||
}
|
||||
Utils::Environment env = bc->environment();
|
||||
// Force output to english for the parsers. Do this here and not in the toolchain's
|
||||
// addToEnvironment() to not screw up the users run environment.
|
||||
|
@@ -76,7 +76,8 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BaseTarget *target) :
|
||||
m_isEnabled(false),
|
||||
m_qtVersionId(-1),
|
||||
m_qmakeBuildConfiguration(0),
|
||||
m_subNodeBuild(0)
|
||||
m_subNodeBuild(0),
|
||||
m_fileNodeBuild(0)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
@@ -87,7 +88,8 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BaseTarget *target, const Core::
|
||||
m_isEnabled(false),
|
||||
m_qtVersionId(-1),
|
||||
m_qmakeBuildConfiguration(0),
|
||||
m_subNodeBuild(0)
|
||||
m_subNodeBuild(0),
|
||||
m_fileNodeBuild(0)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
@@ -99,7 +101,8 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BaseTarget *target, Qt4BuildConf
|
||||
m_buildDirectory(source->m_buildDirectory),
|
||||
m_qtVersionId(source->m_qtVersionId),
|
||||
m_qmakeBuildConfiguration(source->m_qmakeBuildConfiguration),
|
||||
m_subNodeBuild(0) // temporary value, so not copied
|
||||
m_subNodeBuild(0), // temporary value, so not copied
|
||||
m_fileNodeBuild(0)
|
||||
{
|
||||
cloneSteps(source);
|
||||
ctor();
|
||||
@@ -271,6 +274,16 @@ void Qt4BuildConfiguration::setSubNodeBuild(Qt4ProjectManager::Qt4ProFileNode *n
|
||||
m_subNodeBuild = node;
|
||||
}
|
||||
|
||||
FileNode *Qt4BuildConfiguration::fileNodeBuild() const
|
||||
{
|
||||
return m_fileNodeBuild;
|
||||
}
|
||||
|
||||
void Qt4BuildConfiguration::setFileNodeBuild(FileNode *node)
|
||||
{
|
||||
m_fileNodeBuild = node;
|
||||
}
|
||||
|
||||
/// returns whether this is a shadow build configuration or not
|
||||
/// note, even if shadowBuild() returns true, it might be using the
|
||||
/// source directory as the shadow build directory, thus it
|
||||
|
@@ -40,6 +40,7 @@
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class ToolChain;
|
||||
class FileNode;
|
||||
}
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
@@ -71,6 +72,9 @@ public:
|
||||
void setSubNodeBuild(Qt4ProjectManager::Qt4ProFileNode *node);
|
||||
Qt4ProjectManager::Qt4ProFileNode *subNodeBuild() const;
|
||||
|
||||
ProjectExplorer::FileNode *fileNodeBuild() const;
|
||||
void setFileNodeBuild(ProjectExplorer::FileNode *node);
|
||||
|
||||
// returns the qtVersion
|
||||
QtSupport::BaseQtVersion *qtVersion() const;
|
||||
void setQtVersion(QtSupport::BaseQtVersion *);
|
||||
@@ -166,6 +170,7 @@ private:
|
||||
int m_qtVersionId;
|
||||
QtSupport::BaseQtVersion::QmakeBuildConfigs m_qmakeBuildConfiguration;
|
||||
Qt4ProjectManager::Qt4ProFileNode *m_subNodeBuild;
|
||||
ProjectExplorer::FileNode *m_fileNodeBuild;
|
||||
};
|
||||
|
||||
class QT4PROJECTMANAGER_EXPORT Qt4BuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory
|
||||
|
@@ -1527,6 +1527,13 @@ bool Qt4ProFileNode::hasBuildTargets(Qt4ProjectType projectType) const
|
||||
return (projectType == ApplicationTemplate || projectType == LibraryTemplate);
|
||||
}
|
||||
|
||||
bool Qt4ProFileNode::isDebugAndRelease() const
|
||||
{
|
||||
const QStringList configValues = m_varValues.value(ConfigVar);
|
||||
return (configValues.contains(QLatin1String("debug_and_release"))
|
||||
&& configValues.contains(QLatin1String("debug_and_release_target")));
|
||||
}
|
||||
|
||||
Qt4ProjectType Qt4ProFileNode::projectType() const
|
||||
{
|
||||
return m_projectType;
|
||||
|
@@ -368,6 +368,7 @@ public:
|
||||
bool parseInProgress() const;
|
||||
|
||||
bool hasBuildTargets(Qt4ProjectType projectType) const;
|
||||
bool isDebugAndRelease() const;
|
||||
|
||||
void setParseInProgress(bool b);
|
||||
void setParseInProgressRecursive(bool b);
|
||||
|
@@ -108,6 +108,7 @@ Qt4Manager::Qt4Manager(Qt4ProjectManagerPlugin *plugin)
|
||||
: m_plugin(plugin),
|
||||
m_contextNode(0),
|
||||
m_contextProject(0),
|
||||
m_contextFile(0),
|
||||
m_lastEditor(0),
|
||||
m_dirty(false)
|
||||
{
|
||||
@@ -305,6 +306,16 @@ void Qt4Manager::setContextProject(ProjectExplorer::Project *project)
|
||||
m_contextProject = project;
|
||||
}
|
||||
|
||||
ProjectExplorer::FileNode *Qt4Manager::contextFile() const
|
||||
{
|
||||
return m_contextFile;
|
||||
}
|
||||
|
||||
void Qt4Manager::setContextFile(ProjectExplorer::FileNode *file)
|
||||
{
|
||||
m_contextFile = file;
|
||||
}
|
||||
|
||||
void Qt4Manager::addLibrary()
|
||||
{
|
||||
Core::EditorManager *em = Core::EditorManager::instance();
|
||||
@@ -417,6 +428,8 @@ void Qt4Manager::handleSubDirContextMenu(Qt4Manager::Action action)
|
||||
if (Qt4ProFileNode *profile = qobject_cast<Qt4ProFileNode *>(m_contextNode))
|
||||
bc->setSubNodeBuild(profile);
|
||||
|
||||
if (m_contextFile)
|
||||
bc->setFileNodeBuild(m_contextFile);
|
||||
if (projectExplorer()->saveModifiedFiles()) {
|
||||
const Core::Id buildStep = Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
const Core::Id cleanStep = Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
|
||||
@@ -438,6 +451,7 @@ void Qt4Manager::handleSubDirContextMenu(Qt4Manager::Action action)
|
||||
}
|
||||
|
||||
bc->setSubNodeBuild(0);
|
||||
bc->setFileNodeBuild(0);
|
||||
}
|
||||
|
||||
QString Qt4Manager::fileTypeId(ProjectExplorer::FileType type)
|
||||
|
@@ -99,6 +99,8 @@ public:
|
||||
void setContextNode(ProjectExplorer::Node *node);
|
||||
ProjectExplorer::Project *contextProject() const;
|
||||
void setContextProject(ProjectExplorer::Project *project);
|
||||
ProjectExplorer::FileNode *contextFile() const;
|
||||
void setContextFile(ProjectExplorer::FileNode *file);
|
||||
|
||||
// Return the id string of a file
|
||||
static QString fileTypeId(ProjectExplorer::FileType type);
|
||||
@@ -138,6 +140,7 @@ private:
|
||||
mutable QString m_unconfiguredToolChainId;
|
||||
ProjectExplorer::Node *m_contextNode;
|
||||
ProjectExplorer::Project *m_contextProject;
|
||||
ProjectExplorer::FileNode *m_contextFile;
|
||||
|
||||
Core::IEditor *m_lastEditor;
|
||||
bool m_dirty;
|
||||
|
@@ -62,6 +62,7 @@ const char RUNQMAKECONTEXTMENU[] = "Qt4Builder.RunQMakeContextMenu";
|
||||
const char BUILDSUBDIR[] = "Qt4Builder.BuildSubDir";
|
||||
const char REBUILDSUBDIR[] = "Qt4Builder.RebuildSubDir";
|
||||
const char CLEANSUBDIR[] = "Qt4Builder.CleanSubDir";
|
||||
const char BUILDFILE[] = "Qt4Builder.BuildFile";
|
||||
const char BUILDSUBDIRCONTEXTMENU[] = "Qt4Builder.BuildSubDirContextMenu";
|
||||
const char REBUILDSUBDIRCONTEXTMENU[] = "Qt4Builder.RebuildSubDirContextMenu";
|
||||
const char CLEANSUBDIRCONTEXTMENU[] = "Qt4Builder.CleanSubDirContextMenu";
|
||||
|
@@ -254,6 +254,16 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
||||
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_CLEAN);
|
||||
connect(m_cleanSubProjectAction, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(cleanSubDirContextMenu()));
|
||||
|
||||
m_buildFileAction = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""),
|
||||
Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_buildFileAction, Constants::BUILDFILE, projectContext);
|
||||
command->setAttribute(Core::Command::CA_Hide);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDescription(m_buildFileAction->text());
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+B")));
|
||||
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
||||
connect(m_buildFileAction, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(buildSubDirContextMenu()));
|
||||
|
||||
connect(m_projectExplorer,
|
||||
SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*,ProjectExplorer::Node*)),
|
||||
this, SLOT(updateContextMenu(ProjectExplorer::Project*,ProjectExplorer::Node*)));
|
||||
@@ -397,9 +407,14 @@ void Qt4ProjectManagerPlugin::currentNodeChanged(ProjectExplorer::Node *node, Pr
|
||||
|
||||
Qt4Project *pro = qobject_cast<Qt4Project *>(project);
|
||||
Qt4ProFileNode *subProjectNode = node ? qobject_cast<Qt4ProFileNode *>(node->projectNode()) : 0;
|
||||
ProjectExplorer::FileNode *fileNode = qobject_cast<ProjectExplorer::FileNode *>(node);
|
||||
bool buildFilePossible = subProjectNode && fileNode
|
||||
&& (fileNode->fileType() == ProjectExplorer::SourceType)
|
||||
&& !subProjectNode->isDebugAndRelease();
|
||||
|
||||
m_qt4ProjectManager->setContextNode(subProjectNode);
|
||||
m_qt4ProjectManager->setContextProject(pro);
|
||||
m_qt4ProjectManager->setContextFile(buildFilePossible ? fileNode : 0);
|
||||
|
||||
bool subProjectActionsVisible = pro && subProjectNode && (subProjectNode != pro->rootProjectNode());
|
||||
|
||||
@@ -411,11 +426,12 @@ void Qt4ProjectManagerPlugin::currentNodeChanged(ProjectExplorer::Node *node, Pr
|
||||
m_rebuildSubProjectAction->setParameter(subProjectName);
|
||||
m_cleanSubProjectAction->setParameter(subProjectName);
|
||||
m_buildSubProjectContextMenu->setParameter(subProjectName);
|
||||
m_buildFileAction->setParameter(node ? QFileInfo(node->path()).fileName() : QString());
|
||||
|
||||
m_buildSubProjectAction->setVisible(subProjectActionsVisible);
|
||||
m_rebuildSubProjectAction->setVisible(subProjectActionsVisible);
|
||||
m_cleanSubProjectAction->setVisible(subProjectActionsVisible);
|
||||
|
||||
m_buildFileAction->setVisible(buildFilePossible);
|
||||
}
|
||||
|
||||
void Qt4ProjectManagerPlugin::buildStateChanged(ProjectExplorer::Project *pro)
|
||||
|
@@ -106,6 +106,7 @@ private:
|
||||
Utils::ParameterAction *m_buildSubProjectAction;
|
||||
Utils::ParameterAction *m_rebuildSubProjectAction;
|
||||
Utils::ParameterAction *m_cleanSubProjectAction;
|
||||
Utils::ParameterAction *m_buildFileAction;
|
||||
QAction *m_addLibraryAction;
|
||||
QAction *m_addLibraryActionContextMenu;
|
||||
Core::Context m_projectContext;
|
||||
|
Reference in New Issue
Block a user