2009-02-25 09:15:00 +01:00
/**************************************************************************
2008-12-02 12:01:29 +01:00
* *
* * This file is part of Qt Creator
* *
2010-03-05 11:25:49 +01:00
* * Copyright ( c ) 2010 Nokia Corporation and / or its subsidiary ( - ies ) .
2008-12-02 12:01:29 +01:00
* *
2009-06-17 00:01:27 +10:00
* * Contact : Nokia Corporation ( qt - info @ nokia . com )
2008-12-02 12:01:29 +01:00
* *
2009-02-25 09:15:00 +01:00
* * Commercial Usage
2008-12-02 14:17:16 +01:00
* *
2009-02-25 09:15:00 +01:00
* * 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 .
2008-12-02 14:17:16 +01:00
* *
2009-02-25 09:15:00 +01:00
* * GNU Lesser General Public License Usage
2008-12-02 14:17:16 +01:00
* *
2009-02-25 09:15:00 +01:00
* * 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.
2008-12-02 14:17:16 +01:00
* *
2009-02-25 09:15:00 +01:00
* * If you are unsure which license is appropriate for your use , please
2009-08-14 09:30:56 +02:00
* * contact the sales department at http : //qt.nokia.com/contact.
2008-12-02 12:01:29 +01:00
* *
2009-02-25 09:15:00 +01:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-12-02 16:19:05 +01:00
2008-12-02 12:01:29 +01:00
# include "qmakestep.h"
2008-12-02 16:19:05 +01:00
2010-04-07 15:15:52 +02:00
# include "projectexplorer/projectexplorerconstants.h"
2009-12-09 13:54:46 +01:00
# include "qmakeparser.h"
# include "qt4buildconfiguration.h"
2008-12-02 12:01:29 +01:00
# include "qt4project.h"
# include "qt4projectmanagerconstants.h"
# include "qt4projectmanager.h"
2010-02-08 15:50:06 +01:00
# include "qt4target.h"
2009-04-28 12:43:04 +02:00
# include "qtversionmanager.h"
2008-12-02 12:01:29 +01:00
2010-04-07 15:15:52 +02:00
# include "qt-s60/s60manager.h"
2008-12-02 12:01:29 +01:00
# include <coreplugin/icore.h>
2008-12-09 15:25:01 +01:00
# include <utils/qtcassert.h>
2008-12-02 12:01:29 +01:00
2009-12-09 13:54:46 +01:00
# include <QtCore/QDir>
# include <QtCore/QFile>
2008-12-02 12:01:29 +01:00
using namespace Qt4ProjectManager ;
using namespace Qt4ProjectManager : : Internal ;
using namespace ProjectExplorer ;
2010-01-14 17:41:29 +01:00
namespace {
const char * const QMAKE_BS_ID ( " QtProjectManager.QMakeBuildStep " ) ;
const char * const QMAKE_ARGUMENTS_KEY ( " QtProjectManager.QMakeBuildStep.QMakeArguments " ) ;
}
QMakeStep : : QMakeStep ( Qt4BuildConfiguration * bc ) :
AbstractProcessStep ( bc , QLatin1String ( QMAKE_BS_ID ) ) ,
m_forced ( false )
2008-12-02 12:01:29 +01:00
{
2010-01-14 17:41:29 +01:00
ctor ( ) ;
2008-12-02 12:01:29 +01:00
}
2010-01-14 17:41:29 +01:00
QMakeStep : : QMakeStep ( Qt4BuildConfiguration * bc , const QString & id ) :
AbstractProcessStep ( bc , id ) ,
m_forced ( false )
{
ctor ( ) ;
}
QMakeStep : : QMakeStep ( Qt4BuildConfiguration * bc , QMakeStep * bs ) :
AbstractProcessStep ( bc , bs ) ,
2009-10-27 14:16:28 +01:00
m_forced ( false ) ,
2009-11-26 18:51:07 +01:00
m_userArgs ( bs - > m_userArgs )
2009-10-27 14:16:28 +01:00
{
2010-01-14 17:41:29 +01:00
ctor ( ) ;
}
void QMakeStep : : ctor ( )
{
2010-02-16 13:53:29 +01:00
setDisplayName ( tr ( " qmake " , " QMakeStep display name. " ) ) ;
2009-10-27 14:16:28 +01:00
}
2008-12-02 12:01:29 +01:00
QMakeStep : : ~ QMakeStep ( )
{
}
2009-11-26 14:43:27 +01:00
Qt4BuildConfiguration * QMakeStep : : qt4BuildConfiguration ( ) const
{
return static_cast < Qt4BuildConfiguration * > ( buildConfiguration ( ) ) ;
}
2009-11-26 18:51:07 +01:00
QStringList QMakeStep : : allArguments ( )
2008-12-02 12:01:29 +01:00
{
2009-11-26 18:51:07 +01:00
QStringList additonalArguments = m_userArgs ;
2009-11-26 14:43:27 +01:00
Qt4BuildConfiguration * bc = qt4BuildConfiguration ( ) ;
2008-12-02 12:01:29 +01:00
QStringList arguments ;
2010-01-13 18:00:02 +01:00
if ( bc - > subNodeBuild ( ) )
arguments < < bc - > subNodeBuild ( ) - > path ( ) ;
else
2010-02-08 15:50:06 +01:00
arguments < < buildConfiguration ( ) - > target ( ) - > project ( ) - > file ( ) - > fileName ( ) ;
2008-12-02 12:01:29 +01:00
arguments < < " -r " ;
2009-10-30 18:40:33 +01:00
if ( ! additonalArguments . contains ( " -spec " ) )
2009-11-25 18:50:20 +01:00
arguments < < " -spec " < < bc - > qtVersion ( ) - > mkspec ( ) ;
2009-10-26 15:57:30 +01:00
2010-04-07 17:32:02 +02:00
# if defined(Q_OS_WIN) || defined(Q_OS_MAC)
2009-11-30 15:59:27 +01:00
ToolChain : : ToolChainType type = bc - > toolChainType ( ) ;
2009-10-16 17:33:12 +02:00
if ( type = = ToolChain : : GCC_MAEMO )
arguments < < QLatin1String ( " -unix " ) ;
# endif
2009-12-02 17:43:43 +01:00
// Find out what flags we pass on to qmake
QStringList addedUserConfigArguments ;
QStringList removedUserConfigArguments ;
bc - > getConfigCommandLineArguments ( & addedUserConfigArguments , & removedUserConfigArguments ) ;
if ( ! removedUserConfigArguments . isEmpty ( ) ) {
foreach ( const QString & removedConfig , removedUserConfigArguments )
arguments . append ( " CONFIG-= " + removedConfig ) ;
}
if ( ! addedUserConfigArguments . isEmpty ( ) ) {
foreach ( const QString & addedConfig , addedUserConfigArguments )
arguments . append ( " CONFIG+= " + addedConfig ) ;
2008-12-02 12:01:29 +01:00
}
if ( ! additonalArguments . isEmpty ( ) )
arguments < < additonalArguments ;
return arguments ;
}
2009-10-27 14:16:28 +01:00
bool QMakeStep : : init ( )
2008-12-02 12:01:29 +01:00
{
2009-11-26 14:43:27 +01:00
Qt4BuildConfiguration * qt4bc = qt4BuildConfiguration ( ) ;
2009-11-25 18:50:20 +01:00
const QtVersion * qtVersion = qt4bc - > qtVersion ( ) ;
2008-12-02 12:01:29 +01:00
if ( ! qtVersion - > isValid ( ) ) {
2009-06-03 20:45:49 +02:00
# if defined(Q_WS_MAC)
2010-01-12 15:46:23 +01:00
emit addOutput ( tr ( " <font color= \" #ff0000 \" >Qt version <b>%1</b> is invalid. Set a valid Qt Version in Preferences </font> \n " )
. arg ( qtVersion - > displayName ( ) ) ) ;
2008-12-02 12:01:29 +01:00
# else
2010-01-12 15:46:23 +01:00
emit addOutput ( tr ( " <font color= \" #ff0000 \" >Qt version <b>%1</b> is invalid. Set valid Qt Version in Tools/Options </b></font> \n " )
. arg ( qtVersion - > displayName ( ) ) ) ;
2008-12-02 12:01:29 +01:00
# endif
2010-01-12 15:46:23 +01:00
emit addOutput ( " <font color= \" #ff0000 \" > " + qtVersion - > invalidReason ( ) + " </font><br> " ) ;
2008-12-02 12:01:29 +01:00
return false ;
}
2009-11-26 18:51:07 +01:00
QStringList args = allArguments ( ) ;
2010-01-13 18:00:02 +01:00
QString workingDirectory ;
if ( qt4bc - > subNodeBuild ( ) )
workingDirectory = qt4bc - > subNodeBuild ( ) - > buildDir ( ) ;
else
workingDirectory = qt4bc - > buildDirectory ( ) ;
2008-12-02 12:01:29 +01:00
QString program = qtVersion - > qmakeCommand ( ) ;
2009-12-09 13:54:46 +01:00
// Check whether we need to run qmake
2009-10-15 19:06:51 +02:00
m_needToRunQMake = true ;
2009-07-22 19:17:58 +02:00
if ( QDir ( workingDirectory ) . exists ( QLatin1String ( " Makefile " ) ) ) {
2009-09-03 19:16:22 +02:00
QString qmakePath = QtVersionManager : : findQMakeBinaryFromMakefile ( workingDirectory ) ;
if ( qtVersion - > qmakeCommand ( ) = = qmakePath ) {
2009-11-30 12:45:10 +01:00
m_needToRunQMake = ! qt4bc - > compareToImportFrom ( workingDirectory ) ;
2009-07-22 19:17:58 +02:00
}
2008-12-02 12:01:29 +01:00
}
if ( m_forced ) {
m_forced = false ;
2009-10-15 19:06:51 +02:00
m_needToRunQMake = true ;
2008-12-02 12:01:29 +01:00
}
2009-10-15 19:06:51 +02:00
setEnabled ( m_needToRunQMake ) ;
setWorkingDirectory ( workingDirectory ) ;
setCommand ( program ) ;
setArguments ( args ) ;
2009-11-25 18:50:20 +01:00
setEnvironment ( qt4bc - > environment ( ) ) ;
2009-11-11 17:06:58 +01:00
2009-12-09 13:54:46 +01:00
setOutputParser ( new QMakeParser ) ;
return AbstractProcessStep : : init ( ) ;
2008-12-02 12:01:29 +01:00
}
void QMakeStep : : run ( QFutureInterface < bool > & fi )
{
2010-02-08 15:50:06 +01:00
Qt4Project * pro = qt4BuildConfiguration ( ) - > qt4Target ( ) - > qt4Project ( ) ;
2009-11-23 15:47:26 +01:00
if ( pro - > rootProjectNode ( ) - > projectType ( ) = = ScriptTemplate ) {
2008-12-02 12:01:29 +01:00
fi . reportResult ( true ) ;
return ;
}
2009-09-24 16:02:02 +02:00
2010-04-07 15:15:52 +02:00
// Warn on common error conditions:
if ( qt4BuildConfiguration ( ) - > qt4Target ( ) - > id ( ) = = Constants : : S60_DEVICE_TARGET_ID | |
qt4BuildConfiguration ( ) - > qt4Target ( ) - > id ( ) = = Constants : : S60_EMULATOR_TARGET_ID )
{
QtVersion * qtVersion = qt4BuildConfiguration ( ) - > qtVersion ( ) ;
const QString projectDir = QDir ( qt4BuildConfiguration ( ) - > qt4Target ( ) - > qt4Project ( ) - > projectDirectory ( ) ) . absolutePath ( ) ;
const QString epocRootDir = QDir ( Internal : : S60Manager : : instance ( ) - > deviceForQtVersion ( qtVersion ) . epocRoot ) . absolutePath ( ) ;
2010-04-08 21:36:00 +02:00
QFileInfo cppheader ( epocRootDir + QLatin1String ( " /epoc32/include/stdapis/string.h " ) ) ;
2010-04-07 15:15:52 +02:00
# if defined (Q_OS_WIN)
// Report an error if project- and epoc directory are on different drives:
2010-04-08 21:36:11 +02:00
if ( ! epocRootDir . startsWith ( projectDir . left ( 3 ) , Qt : : CaseInsensitive ) ) {
2010-04-07 15:15:52 +02:00
addTask ( Task ( Task : : Error ,
tr ( " The Symbian SDK and the project sources must reside on the same drive. " ) ,
QString ( ) , - 1 , ProjectExplorer : : Constants : : TASK_CATEGORY_BUILDSYSTEM ) ) ;
fi . reportResult ( false ) ;
return ;
}
# endif
2010-04-19 11:52:19 +02:00
// Report an error if EPOC root is not set:
2010-04-07 15:15:52 +02:00
if ( epocRootDir . isEmpty ( ) | | ! QDir ( epocRootDir ) . exists ( ) ) {
addTask ( Task ( Task : : Error ,
tr ( " The Symbian SDK was not found for Qt version %1. " ) . arg ( qtVersion - > displayName ( ) ) ,
QString ( ) , - 1 , ProjectExplorer : : Constants : : TASK_CATEGORY_BUILDSYSTEM ) ) ;
fi . reportResult ( false ) ;
return ;
}
if ( ! cppheader . exists ( ) ) {
addTask ( Task ( Task : : Error ,
tr ( " The \" Open C/C++ plugin \" is not installed in the Symbian SDK or the Symbian SDK path is misconfigured for Qt version %1. " ) . arg ( qtVersion - > displayName ( ) ) ,
QString ( ) , - 1 , ProjectExplorer : : Constants : : TASK_CATEGORY_BUILDSYSTEM ) ) ;
fi . reportResult ( false ) ;
return ;
}
// Warn of strange characters in project name:
2010-04-19 11:52:19 +02:00
QString projectPath = projectDir ;
# if defined (Q_OS_WIN)
if ( projectPath . at ( 1 ) = = QChar ( ' : ' ) & & projectPath . at ( 0 ) . toUpper ( ) > = QChar ( ' A ' ) & & projectPath . at ( 0 ) . toUpper ( ) < = QChar ( ' Z ' ) )
projectPath = projectPath . mid ( 2 ) ;
# endif
if ( projectPath . contains ( QRegExp ( " [^a-zA-Z0-9./] " ) ) ) {
2010-04-07 15:15:52 +02:00
addTask ( Task ( Task : : Warning ,
tr ( " The Symbian toolchain does not handle special characters in a project path well. " ) ,
QString ( ) , - 1 , ProjectExplorer : : Constants : : TASK_CATEGORY_BUILDSYSTEM ) ) ;
}
}
2009-10-15 19:06:51 +02:00
if ( ! m_needToRunQMake ) {
2010-02-16 13:53:29 +01:00
emit addOutput ( tr ( " <font color= \" #0000ff \" >Configuration unchanged, skipping qmake step.</font> " ) ) ;
2008-12-02 12:01:29 +01:00
fi . reportResult ( true ) ;
return ;
}
2010-04-07 15:15:52 +02:00
2009-12-09 13:54:46 +01:00
AbstractProcessStep : : run ( fi ) ;
2008-12-02 12:01:29 +01:00
}
void QMakeStep : : setForced ( bool b )
{
m_forced = b ;
}
bool QMakeStep : : forced ( )
{
return m_forced ;
}
ProjectExplorer : : BuildStepConfigWidget * QMakeStep : : createConfigWidget ( )
{
return new QMakeStepConfigWidget ( this ) ;
}
bool QMakeStep : : immutable ( ) const
{
2009-07-27 16:36:27 +02:00
return false ;
2008-12-02 12:01:29 +01:00
}
void QMakeStep : : processStartupFailed ( )
{
m_forced = true ;
AbstractProcessStep : : processStartupFailed ( ) ;
}
2010-04-09 13:10:59 +02:00
bool QMakeStep : : processSucceeded ( int exitCode , QProcess : : ExitStatus status )
2008-12-02 12:01:29 +01:00
{
2010-04-09 13:10:59 +02:00
bool result = AbstractProcessStep : : processSucceeded ( exitCode , status ) ;
2008-12-02 12:01:29 +01:00
if ( ! result )
m_forced = true ;
2010-02-15 17:33:56 +01:00
qt4BuildConfiguration ( ) - > emitBuildDirectoryInitialized ( ) ;
2008-12-02 12:01:29 +01:00
return result ;
}
2009-11-30 16:34:30 +01:00
void QMakeStep : : setUserArguments ( const QStringList & arguments )
2009-07-24 18:53:54 +02:00
{
2010-01-12 17:20:15 +01:00
if ( m_userArgs = = arguments )
return ;
2009-11-26 18:51:07 +01:00
m_userArgs = arguments ;
2010-01-12 17:20:15 +01:00
2009-11-30 16:34:30 +01:00
emit userArgumentsChanged ( ) ;
2010-01-12 17:20:15 +01:00
qt4BuildConfiguration ( ) - > emitQMakeBuildConfigurationChanged ( ) ;
2009-07-24 18:53:54 +02:00
}
2009-11-26 18:51:07 +01:00
QStringList QMakeStep : : userArguments ( )
2009-10-15 19:06:51 +02:00
{
2009-11-26 18:51:07 +01:00
return m_userArgs ;
2009-10-15 19:06:51 +02:00
}
2010-01-14 17:41:29 +01:00
QVariantMap QMakeStep : : toMap ( ) const
2009-10-15 19:06:51 +02:00
{
2010-01-14 17:41:29 +01:00
QVariantMap map ( AbstractProcessStep : : toMap ( ) ) ;
map . insert ( QLatin1String ( QMAKE_ARGUMENTS_KEY ) , m_userArgs ) ;
return map ;
2009-10-15 19:06:51 +02:00
}
2010-01-14 17:41:29 +01:00
bool QMakeStep : : fromMap ( const QVariantMap & map )
2009-10-15 19:06:51 +02:00
{
2010-01-14 17:41:29 +01:00
m_userArgs = map . value ( QLatin1String ( QMAKE_ARGUMENTS_KEY ) ) . toStringList ( ) ;
return BuildStep : : fromMap ( map ) ;
2009-10-15 19:06:51 +02:00
}
2009-12-03 18:37:27 +01:00
////
// QMakeStepConfigWidget
////
2008-12-02 12:01:29 +01:00
QMakeStepConfigWidget : : QMakeStepConfigWidget ( QMakeStep * step )
2009-11-30 16:34:30 +01:00
: BuildStepConfigWidget ( ) , m_step ( step ) , m_ignoreChange ( false )
2008-12-02 12:01:29 +01:00
{
m_ui . setupUi ( this ) ;
connect ( m_ui . qmakeAdditonalArgumentsLineEdit , SIGNAL ( textEdited ( const QString & ) ) ,
2009-12-03 18:37:27 +01:00
this , SLOT ( qmakeArgumentsLineEdited ( ) ) ) ;
connect ( m_ui . buildConfigurationComboBox , SIGNAL ( currentIndexChanged ( int ) ) ,
this , SLOT ( buildConfigurationSelected ( ) ) ) ;
2009-11-30 16:34:30 +01:00
connect ( step , SIGNAL ( userArgumentsChanged ( ) ) ,
this , SLOT ( userArgumentsChanged ( ) ) ) ;
2009-12-03 18:37:27 +01:00
connect ( step - > qt4BuildConfiguration ( ) , SIGNAL ( qtVersionChanged ( ) ) ,
2009-11-30 13:57:41 +01:00
this , SLOT ( qtVersionChanged ( ) ) ) ;
2009-12-03 18:37:27 +01:00
connect ( step - > qt4BuildConfiguration ( ) , SIGNAL ( qmakeBuildConfigurationChanged ( ) ) ,
this , SLOT ( qmakeBuildConfigChanged ( ) ) ) ;
}
void QMakeStepConfigWidget : : init ( )
{
QString qmakeArgs = ProjectExplorer : : Environment : : joinArgumentList ( m_step - > userArguments ( ) ) ;
m_ui . qmakeAdditonalArgumentsLineEdit - > setText ( qmakeArgs ) ;
qmakeBuildConfigChanged ( ) ;
updateSummaryLabel ( ) ;
updateEffectiveQMakeCall ( ) ;
2008-12-02 12:01:29 +01:00
}
2009-08-06 15:31:32 +02:00
QString QMakeStepConfigWidget : : summaryText ( ) const
{
return m_summaryText ;
}
2009-12-03 18:37:27 +01:00
QString QMakeStepConfigWidget : : displayName ( ) const
{
return m_step - > displayName ( ) ;
}
2009-11-30 13:57:41 +01:00
void QMakeStepConfigWidget : : qtVersionChanged ( )
2009-10-29 19:42:56 +01:00
{
2009-12-03 18:37:27 +01:00
updateSummaryLabel ( ) ;
2009-11-25 20:08:39 +01:00
updateEffectiveQMakeCall ( ) ;
2009-10-29 19:42:56 +01:00
}
2009-12-03 18:37:27 +01:00
void QMakeStepConfigWidget : : qmakeBuildConfigChanged ( )
2009-08-06 15:31:32 +02:00
{
2009-12-03 18:37:27 +01:00
Qt4BuildConfiguration * bc = m_step - > qt4BuildConfiguration ( ) ;
bool debug = bc - > qmakeBuildConfiguration ( ) & QtVersion : : DebugBuild ;
m_ignoreChange = true ;
m_ui . buildConfigurationComboBox - > setCurrentIndex ( debug ? 0 : 1 ) ;
m_ignoreChange = false ;
updateSummaryLabel ( ) ;
updateEffectiveQMakeCall ( ) ;
}
2009-08-06 15:31:32 +02:00
2009-12-03 18:37:27 +01:00
void QMakeStepConfigWidget : : userArgumentsChanged ( )
{
if ( m_ignoreChange )
return ;
QString qmakeArgs = ProjectExplorer : : Environment : : joinArgumentList ( m_step - > userArguments ( ) ) ;
m_ui . qmakeAdditonalArgumentsLineEdit - > setText ( qmakeArgs ) ;
updateSummaryLabel ( ) ;
updateEffectiveQMakeCall ( ) ;
2009-08-06 15:31:32 +02:00
}
2009-12-03 18:37:27 +01:00
void QMakeStepConfigWidget : : qmakeArgumentsLineEdited ( )
2008-12-02 12:01:29 +01:00
{
2009-11-30 16:34:30 +01:00
m_ignoreChange = true ;
m_step - > setUserArguments (
2009-10-15 19:06:51 +02:00
ProjectExplorer : : Environment : : parseCombinedArgString ( m_ui . qmakeAdditonalArgumentsLineEdit - > text ( ) ) ) ;
2009-11-30 16:34:30 +01:00
m_ignoreChange = false ;
2009-08-12 13:21:41 +02:00
2009-12-03 18:37:27 +01:00
updateSummaryLabel ( ) ;
2009-08-12 13:21:41 +02:00
updateEffectiveQMakeCall ( ) ;
2008-12-02 12:01:29 +01:00
}
2009-12-03 18:37:27 +01:00
void QMakeStepConfigWidget : : buildConfigurationSelected ( )
2008-12-02 12:01:29 +01:00
{
2009-12-03 18:37:27 +01:00
if ( m_ignoreChange )
return ;
Qt4BuildConfiguration * bc = m_step - > qt4BuildConfiguration ( ) ;
QtVersion : : QmakeBuildConfigs buildConfiguration = bc - > qmakeBuildConfiguration ( ) ;
if ( m_ui . buildConfigurationComboBox - > currentIndex ( ) = = 0 ) { // debug
2009-10-13 13:44:13 +02:00
buildConfiguration = buildConfiguration | QtVersion : : DebugBuild ;
2008-12-02 12:01:29 +01:00
} else {
2009-10-13 13:44:13 +02:00
buildConfiguration = buildConfiguration & ~ QtVersion : : DebugBuild ;
2008-12-02 12:01:29 +01:00
}
2009-12-03 18:37:27 +01:00
m_ignoreChange = true ;
bc - > setQMakeBuildConfiguration ( buildConfiguration ) ;
m_ignoreChange = false ;
2008-12-02 12:01:29 +01:00
2009-12-03 18:37:27 +01:00
updateSummaryLabel ( ) ;
updateEffectiveQMakeCall ( ) ;
2008-12-02 12:01:29 +01:00
}
2009-12-03 18:37:27 +01:00
void QMakeStepConfigWidget : : updateSummaryLabel ( )
2009-07-24 18:53:54 +02:00
{
2009-12-03 18:37:27 +01:00
Qt4BuildConfiguration * qt4bc = m_step - > qt4BuildConfiguration ( ) ;
const QtVersion * qtVersion = qt4bc - > qtVersion ( ) ;
if ( ! qtVersion ) {
2010-02-25 17:15:30 +01:00
m_summaryText = tr ( " <b>qmake:</b> No Qt version set. Cannot run qmake. " ) ;
2009-12-03 18:37:27 +01:00
emit updateSummary ( ) ;
2009-11-30 16:34:30 +01:00
return ;
2009-12-03 18:37:27 +01:00
}
QStringList args = m_step - > allArguments ( ) ;
// We don't want the full path to the .pro file
2010-02-08 15:50:06 +01:00
const QString projectFileName = m_step - > buildConfiguration ( ) - > target ( ) - > project ( ) - > file ( ) - > fileName ( ) ;
2009-12-03 18:37:27 +01:00
int index = args . indexOf ( projectFileName ) ;
if ( index ! = - 1 )
args [ index ] = QFileInfo ( projectFileName ) . fileName ( ) ;
// And we only use the .pro filename not the full path
QString program = QFileInfo ( qtVersion - > qmakeCommand ( ) ) . fileName ( ) ;
2010-02-16 13:53:29 +01:00
m_summaryText = tr ( " <b>qmake:</b> %1 %2 " ) . arg ( program , args . join ( QString ( QLatin1Char ( ' ' ) ) ) ) ;
2009-12-03 18:37:27 +01:00
emit updateSummary ( ) ;
2009-07-24 18:53:54 +02:00
2009-08-12 13:21:41 +02:00
}
void QMakeStepConfigWidget : : updateEffectiveQMakeCall ( )
{
2009-11-26 14:43:27 +01:00
Qt4BuildConfiguration * qt4bc = m_step - > qt4BuildConfiguration ( ) ;
2009-11-25 18:50:20 +01:00
const QtVersion * qtVersion = qt4bc - > qtVersion ( ) ;
2010-02-08 15:50:06 +01:00
QString program = QFileInfo ( qtVersion - > qmakeCommand ( ) ) . fileName ( ) ;
m_ui . qmakeArgumentsEdit - > setPlainText ( program + QLatin1Char ( ' ' ) + ProjectExplorer : : Environment : : joinArgumentList ( m_step - > allArguments ( ) ) ) ;
2008-12-02 12:01:29 +01:00
}
2009-04-20 16:25:48 +02:00
////
// QMakeStepFactory
////
2010-01-14 17:41:29 +01:00
QMakeStepFactory : : QMakeStepFactory ( QObject * parent ) :
ProjectExplorer : : IBuildStepFactory ( parent )
2009-04-20 16:25:48 +02:00
{
}
QMakeStepFactory : : ~ QMakeStepFactory ( )
{
}
2010-03-16 14:36:59 +01:00
bool QMakeStepFactory : : canCreate ( BuildConfiguration * parent , ProjectExplorer : : StepType type , const QString & id ) const
2009-04-20 16:25:48 +02:00
{
2010-03-16 14:36:59 +01:00
if ( type ! = ProjectExplorer : : Build )
return false ;
2010-01-14 17:41:29 +01:00
if ( ! qobject_cast < Qt4BuildConfiguration * > ( parent ) )
return false ;
return ( id = = QLatin1String ( QMAKE_BS_ID ) ) ;
2009-04-20 16:25:48 +02:00
}
2010-03-16 14:36:59 +01:00
ProjectExplorer : : BuildStep * QMakeStepFactory : : create ( BuildConfiguration * parent , ProjectExplorer : : StepType type , const QString & id )
2009-04-20 16:25:48 +02:00
{
2010-03-16 14:36:59 +01:00
if ( ! canCreate ( parent , type , id ) )
2010-01-14 17:41:29 +01:00
return 0 ;
Qt4BuildConfiguration * bc ( qobject_cast < Qt4BuildConfiguration * > ( parent ) ) ;
Q_ASSERT ( bc ) ;
2009-11-23 15:47:26 +01:00
return new QMakeStep ( bc ) ;
2009-10-27 14:16:28 +01:00
}
2010-03-16 14:36:59 +01:00
bool QMakeStepFactory : : canClone ( BuildConfiguration * parent , ProjectExplorer : : StepType type , BuildStep * source ) const
2009-10-27 14:16:28 +01:00
{
2010-03-16 14:36:59 +01:00
return canCreate ( parent , type , source - > id ( ) ) ;
2009-04-20 16:25:48 +02:00
}
2010-03-16 14:36:59 +01:00
ProjectExplorer : : BuildStep * QMakeStepFactory : : clone ( ProjectExplorer : : BuildConfiguration * parent , ProjectExplorer : : StepType type , ProjectExplorer : : BuildStep * source )
2009-04-20 16:25:48 +02:00
{
2010-03-16 14:36:59 +01:00
if ( ! canClone ( parent , type , source ) )
2010-01-14 17:41:29 +01:00
return 0 ;
Qt4BuildConfiguration * bc ( qobject_cast < Qt4BuildConfiguration * > ( parent ) ) ;
Q_ASSERT ( bc ) ;
return new QMakeStep ( bc , qobject_cast < QMakeStep * > ( source ) ) ;
2009-04-20 16:25:48 +02:00
}
2010-03-16 14:36:59 +01:00
bool QMakeStepFactory : : canRestore ( ProjectExplorer : : BuildConfiguration * parent , ProjectExplorer : : StepType type , const QVariantMap & map ) const
2010-01-14 17:41:29 +01:00
{
QString id ( ProjectExplorer : : idFromMap ( map ) ) ;
2010-03-16 14:36:59 +01:00
return canCreate ( parent , type , id ) ;
2010-01-14 17:41:29 +01:00
}
2010-03-16 14:36:59 +01:00
ProjectExplorer : : BuildStep * QMakeStepFactory : : restore ( ProjectExplorer : : BuildConfiguration * parent , ProjectExplorer : : StepType type , const QVariantMap & map )
2009-04-20 16:25:48 +02:00
{
2010-03-16 14:36:59 +01:00
if ( ! canRestore ( parent , type , map ) )
2010-01-14 17:41:29 +01:00
return 0 ;
Qt4BuildConfiguration * bc ( qobject_cast < Qt4BuildConfiguration * > ( parent ) ) ;
Q_ASSERT ( bc ) ;
QMakeStep * bs ( new QMakeStep ( bc ) ) ;
if ( bs - > fromMap ( map ) )
return bs ;
delete bs ;
return 0 ;
2009-04-20 16:25:48 +02:00
}
2010-03-16 14:36:59 +01:00
QStringList QMakeStepFactory : : availableCreationIds ( ProjectExplorer : : BuildConfiguration * parent , ProjectExplorer : : StepType type ) const
2010-01-14 17:41:29 +01:00
{
2010-03-16 14:36:59 +01:00
if ( type = = Build )
if ( Qt4BuildConfiguration * bc = qobject_cast < Qt4BuildConfiguration * > ( parent ) )
if ( ! bc - > qmakeStep ( ) )
return QStringList ( ) < < QLatin1String ( QMAKE_BS_ID ) ;
2010-01-14 17:41:29 +01:00
return QStringList ( ) ;
}
2009-04-20 16:25:48 +02:00
2010-01-14 17:41:29 +01:00
QString QMakeStepFactory : : displayNameForId ( const QString & id ) const
{
if ( id = = QLatin1String ( QMAKE_BS_ID ) )
2010-02-16 13:53:29 +01:00
return tr ( " qmake " ) ;
2010-01-14 17:41:29 +01:00
return QString ( ) ;
}