Commit cd27fdec authored by dt's avatar dt

Parse the Makefile in the importing case a lot better

We add each command line argument to the Additional Arguments
parent ecfb6eaf
......@@ -62,8 +62,10 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
m_temporaryVersion = true;
}
m_importBuildConfig = m_importVersion->defaultBuildConfig();
m_importBuildConfig= QtVersionManager::scanMakefileForQmakeConfig(directory, m_importBuildConfig);
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QtVersionManager::scanMakeFile(directory, m_importVersion->defaultBuildConfig());
m_importBuildConfig = result.first;
m_additionalArguments = result.second;
}
// So now we have the version and the configuration for that version
......@@ -73,7 +75,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
// Also if the qt version is not yet in the Tools Options dialog we offer to add it there
if (m_importVersion)
setupImportPage(m_importVersion, m_importBuildConfig);
setupImportPage(m_importVersion, m_importBuildConfig, m_additionalArguments);
setOptions(options() | QWizard::NoCancelButton | QWizard::NoBackButtonOnLastPage);
}
......@@ -93,8 +95,9 @@ ProjectLoadWizard::~ProjectLoadWizard()
}
void ProjectLoadWizard::addBuildConfiguration(QString buildConfigurationName, QtVersion *qtversion, QtVersion::QmakeBuildConfig qmakeBuildConfiguration)
void ProjectLoadWizard::addBuildConfiguration(QString buildConfigurationName, QtVersion *qtversion, QtVersion::QmakeBuildConfig qmakeBuildConfiguration, QStringList additionalArguments)
{
QMakeStep *qmakeStep = m_project->qmakeStep();
MakeStep *makeStep = m_project->makeStep();
bool debug = qmakeBuildConfiguration & QtVersion::DebugBuild;
......@@ -109,6 +112,7 @@ void ProjectLoadWizard::addBuildConfiguration(QString buildConfigurationName, Qt
// Add the buildconfiguration
m_project->addBuildConfiguration(buildConfigurationName);
qmakeStep->setValue(buildConfigurationName, "qmakeArgs", additionalArguments);
// set some options for qmake and make
if (qmakeBuildConfiguration & QtVersion::BuildAll) // debug_and_release => explicit targets
makeStep->setValue(buildConfigurationName, "makeargs", QStringList() << (debug ? "debug" : "release"));
......@@ -139,7 +143,7 @@ void ProjectLoadWizard::done(int result)
// qDebug()<<"Creating m_buildconfiguration entry from imported stuff";
// qDebug()<<((m_importBuildConfig& QtVersion::BuildAll)? "debug_and_release" : "")<<((m_importBuildConfig & QtVersion::DebugBuild)? "debug" : "release");
bool debug = m_importBuildConfig & QtVersion::DebugBuild;
addBuildConfiguration(debug ? "Debug" : "Release", m_importVersion, m_importBuildConfig);
addBuildConfiguration(debug ? "Debug" : "Release", m_importVersion, m_importBuildConfig, m_additionalArguments);
if (m_importBuildConfig & QtVersion::BuildAll) {
// Also create the other configuration
......@@ -149,7 +153,7 @@ void ProjectLoadWizard::done(int result)
else
otherBuildConfiguration = QtVersion::QmakeBuildConfig(otherBuildConfiguration | QtVersion::DebugBuild);
addBuildConfiguration(debug ? "Release" : "Debug", m_importVersion, otherBuildConfiguration);
addBuildConfiguration(debug ? "Release" : "Debug", m_importVersion, otherBuildConfiguration, m_additionalArguments);
}
} else {
// Not importing
......@@ -161,11 +165,11 @@ void ProjectLoadWizard::done(int result)
if (defaultVersion && defaultVersion->isValid() && (defaultVersion->defaultBuildConfig() & QtVersion::BuildAll))
buildAll = true;
if (buildAll) {
addBuildConfiguration("Debug", 0, QtVersion::QmakeBuildConfig(QtVersion::BuildAll | QtVersion::DebugBuild));
addBuildConfiguration("Release", 0, QtVersion::BuildAll);
addBuildConfiguration("Debug", 0, QtVersion::QmakeBuildConfig(QtVersion::BuildAll | QtVersion::DebugBuild), m_additionalArguments);
addBuildConfiguration("Release", 0, QtVersion::BuildAll, m_additionalArguments);
} else {
addBuildConfiguration("Debug", 0, QtVersion::DebugBuild);
addBuildConfiguration("Release", 0, QtVersion::QmakeBuildConfig(0));
addBuildConfiguration("Debug", 0, QtVersion::DebugBuild, m_additionalArguments);
addBuildConfiguration("Release", 0, QtVersion::QmakeBuildConfig(0), m_additionalArguments);
}
}
......@@ -179,7 +183,7 @@ int ProjectLoadWizard::nextId() const
return -1;
}
void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfig buildConfig)
void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfig buildConfig, QStringList addtionalArguments)
{
resize(605, 490);
// Import Page
......@@ -194,9 +198,11 @@ void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuil
importLabel->setTextFormat(Qt::RichText);
importLabel->setText(tr("Qt Creator has found an already existing build in the source directory.<br><br>"
"<b>Qt Version:</b> %1<br>"
"<b>Build configuration:</b> %2<br>")
"<b>Build configuration:</b> %2<br>"
"<b>Additional QMake Arguments:</b>%3")
.arg(versionString)
.arg(buildConfigString));
.arg(buildConfigString)
.arg(ProjectExplorer::Environment::joinArgumentList(addtionalArguments)));
importLayout->addWidget(importLabel);
......
......@@ -57,14 +57,15 @@ public:
void execDialog();
private:
void addBuildConfiguration(QString name, QtVersion *qtversion, QtVersion::QmakeBuildConfig buildConfiguration);
void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfig buildConfig);
void addBuildConfiguration(QString name, QtVersion *qtversion, QtVersion::QmakeBuildConfig buildConfiguration, QStringList additionalArguments);
void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfig buildConfig, QStringList addtionalArguments);
Qt4Project *m_project;
// Only used for imported stuff
QtVersion *m_importVersion;
QtVersion::QmakeBuildConfig m_importBuildConfig;
QStringList m_additionalArguments;
// Those that we might add
bool m_temporaryVersion;
......
......@@ -722,11 +722,7 @@ void Qt4Project::addDefaultBuild()
wizard.execDialog();
} else {
// Migrate settings
QMakeStep *qs = 0;
foreach(BuildStep *bs, buildSteps())
if ( (qs = qobject_cast<QMakeStep *>(bs)) != 0)
break;
QMakeStep *qs = qmakeStep();
foreach (const QString &buildConfiguration, buildConfigurations()) {
QVariant v = qs->value(buildConfiguration, "buildConfiguration");
if (v.isValid()) {
......@@ -1044,6 +1040,15 @@ void Qt4Project::proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *nod
}
}
QMakeStep *Qt4Project::qmakeStep() const
{
QMakeStep *qs = 0;
foreach(BuildStep *bs, buildSteps())
if ((qs = qobject_cast<QMakeStep *>(bs)) != 0)
return qs;
return 0;
}
MakeStep *Qt4Project::makeStep() const
{
MakeStep *qs = 0;
......
......@@ -179,6 +179,7 @@ public:
// That is generally the stuff that is asked should normally be transfered to
// Qt4Project *
// So that we can later enable people to build qt4projects the way they would like
QMakeStep *qmakeStep() const;
MakeStep *makeStep() const;
void notifyChanged(const QString &name);
......
......@@ -227,14 +227,18 @@ void Qt4ProjectConfigWidget::importLabelClicked()
version = new QtVersion(QFileInfo(qtPath).baseName(), qtPath);
vm->addVersion(version);
}
QtVersion::QmakeBuildConfig qmakeBuildConfig = version->defaultBuildConfig();
qmakeBuildConfig = QtVersionManager::scanMakefileForQmakeConfig(directory, qmakeBuildConfig);
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig());
QtVersion::QmakeBuildConfig qmakeBuildConfig = result.first;
QStringList additionalArguments = result.second;
// So we got all the information now apply it...
m_pro->setQtVersion(m_buildConfiguration, version->uniqueId());
// Combo box will be updated at the end
// Find qmakestep...
QMakeStep *qmakeStep = m_pro->qmakeStep();
qmakeStep->setValue(m_buildConfiguration, "qmakeArgs", additionalArguments);
MakeStep *makeStep = m_pro->makeStep();
m_pro->setValue(m_buildConfiguration, "buildConfiguration", int(qmakeBuildConfig));
......
......@@ -256,10 +256,7 @@ void Qt4Manager::runQMakeContextMenu()
void Qt4Manager::runQMake(ProjectExplorer::Project *p)
{
QMakeStep *qs = 0;
foreach(BuildStep *bs, p->buildSteps())
if ( (qs = qobject_cast<QMakeStep *>(bs)) != 0)
break;
QMakeStep *qs = qobject_cast<Qt4Project *>(p)->qmakeStep();
if (!qs)
return;
//found qmakeStep, now use it
......
......@@ -167,6 +167,13 @@ private:
mutable QString m_qmakeCXX;
};
struct QMakeAssignment
{
QString variable;
QString op;
QString value;
};
class QtVersionManager : public QObject
{
Q_OBJECT
......@@ -189,13 +196,18 @@ public:
void removeVersion(QtVersion *version);
// Static Methods
static QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig);
static QPair<QtVersion::QmakeBuildConfig, QStringList> scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig);
static QString findQtVersionFromMakefile(const QString &directory);
signals:
void defaultQtVersionChanged();
void qtVersionsChanged();
void updatedExamples(const QString& examplesPath, const QString& demosPath);
private:
static QString findQMakeLine(const QString &directory);
static QString trimLine(const QString line);
static QStringList splitLine(const QString &line);
static void parseParts(const QStringList &parts, QList<QMakeAssignment> *assignments, QList<QMakeAssignment> *afterAssignments, QStringList *additionalArguments);
static QtVersion::QmakeBuildConfig qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfig defaultBuildConfig);
// Used by QtOptionsPage
void setNewQtVersions(QList<QtVersion *> newVersions, int newDefaultVersion);
// Used by QtVersion
......
......@@ -59,6 +59,9 @@ public:
void setVerbose(bool on); // Default is false
void setCumulative(bool on); // Default is true!
void setOutputDir(const QString &dir); // Default is empty
// -nocache, -cache, -spec, QMAKESPEC
// -set persistent value
void setUserConfigCmdArgs(const QStringList &addUserConfigCmdArgs, const QStringList &removeUserConfigCmdArgs);
void setParsePreAndPostFiles(bool on); // Default is true
......
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