forked from qt-creator/qt-creator
Qt4ProjectManager: Support Makefile variable
Pass on the makefile to make, check the right makefile for importing. Task-Nr: QTCREATORBUG-102
This commit is contained in:
@@ -149,7 +149,19 @@ bool MakeStep::init()
|
|||||||
// we should stop the clean queue
|
// we should stop the clean queue
|
||||||
// That is mostly so that rebuild works on a already clean project
|
// That is mostly so that rebuild works on a already clean project
|
||||||
setIgnoreReturnValue(m_clean);
|
setIgnoreReturnValue(m_clean);
|
||||||
QStringList args = m_userArgs;
|
QStringList args;
|
||||||
|
|
||||||
|
ProjectExplorer::ToolChain *toolchain = bc->toolChain();
|
||||||
|
|
||||||
|
if (bc->subNodeBuild()){
|
||||||
|
if(!bc->subNodeBuild()->makefile().isEmpty()) {
|
||||||
|
args << "-f" << bc->subNodeBuild()->makefile();
|
||||||
|
}
|
||||||
|
} else if (!bc->makefile().isEmpty()) {
|
||||||
|
args << "-f" << bc->makefile();
|
||||||
|
}
|
||||||
|
|
||||||
|
args.append(m_userArgs);
|
||||||
if (!m_clean) {
|
if (!m_clean) {
|
||||||
if (!bc->defaultMakeTarget().isEmpty())
|
if (!bc->defaultMakeTarget().isEmpty())
|
||||||
args << bc->defaultMakeTarget();
|
args << bc->defaultMakeTarget();
|
||||||
@@ -159,7 +171,6 @@ bool MakeStep::init()
|
|||||||
// FIXME doing this without the user having a way to override this is rather bad
|
// FIXME doing this without the user having a way to override this is rather bad
|
||||||
// so we only do it for unix and if the user didn't override the make command
|
// so we only do it for unix and if the user didn't override the make command
|
||||||
// but for now this is the least invasive change
|
// but for now this is the least invasive change
|
||||||
ProjectExplorer::ToolChain *toolchain = bc->toolChain();
|
|
||||||
|
|
||||||
if (toolchain) {
|
if (toolchain) {
|
||||||
if (toolchain->type() != ProjectExplorer::ToolChain::MSVC &&
|
if (toolchain->type() != ProjectExplorer::ToolChain::MSVC &&
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ bool QMakeStep::init()
|
|||||||
|
|
||||||
QStringList args = allArguments();
|
QStringList args = allArguments();
|
||||||
QString workingDirectory;
|
QString workingDirectory;
|
||||||
|
|
||||||
if (qt4bc->subNodeBuild())
|
if (qt4bc->subNodeBuild())
|
||||||
workingDirectory = qt4bc->subNodeBuild()->buildDir();
|
workingDirectory = qt4bc->subNodeBuild()->buildDir();
|
||||||
else
|
else
|
||||||
@@ -174,10 +175,24 @@ bool QMakeStep::init()
|
|||||||
|
|
||||||
// Check whether we need to run qmake
|
// Check whether we need to run qmake
|
||||||
m_needToRunQMake = true;
|
m_needToRunQMake = true;
|
||||||
if (QDir(workingDirectory).exists(QLatin1String("Makefile"))) {
|
QString makefile = workingDirectory;
|
||||||
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory);
|
|
||||||
|
if (qt4bc->subNodeBuild()) {
|
||||||
|
if (!qt4bc->subNodeBuild()->makefile().isEmpty()) {
|
||||||
|
makefile.append(qt4bc->subNodeBuild()->makefile());
|
||||||
|
} else {
|
||||||
|
makefile.append("/Makefile");
|
||||||
|
}
|
||||||
|
} else if (!qt4bc->makefile().isEmpty()) {
|
||||||
|
makefile.append(qt4bc->makefile());
|
||||||
|
} else {
|
||||||
|
makefile.append("/Makefile");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QFileInfo(makefile).exists()) {
|
||||||
|
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
|
||||||
if (qtVersion->qmakeCommand() == qmakePath) {
|
if (qtVersion->qmakeCommand() == qmakePath) {
|
||||||
m_needToRunQMake = !qt4bc->compareToImportFrom(workingDirectory);
|
m_needToRunQMake = !qt4bc->compareToImportFrom(makefile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -317,6 +317,13 @@ QString Qt4BuildConfiguration::defaultMakeTarget() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Qt4BuildConfiguration::makefile() const
|
||||||
|
{
|
||||||
|
if (qt4Target()->id() == Constants::S60_DEVICE_TARGET_ID)
|
||||||
|
return QString();
|
||||||
|
return qt4Target()->qt4Project()->rootProjectNode()->makefile();
|
||||||
|
}
|
||||||
|
|
||||||
QtVersion *Qt4BuildConfiguration::qtVersion() const
|
QtVersion *Qt4BuildConfiguration::qtVersion() const
|
||||||
{
|
{
|
||||||
QtVersionManager *vm = QtVersionManager::instance();
|
QtVersionManager *vm = QtVersionManager::instance();
|
||||||
@@ -455,21 +462,22 @@ void Qt4BuildConfiguration::qtVersionsChanged(const QList<int> &changedVersions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns true if both are equal
|
// returns true if both are equal
|
||||||
bool Qt4BuildConfiguration::compareToImportFrom(const QString &workingDirectory)
|
bool Qt4BuildConfiguration::compareToImportFrom(const QString &makefile)
|
||||||
{
|
{
|
||||||
QMakeStep *qs = qmakeStep();
|
QMakeStep *qs = qmakeStep();
|
||||||
if (QDir(workingDirectory).exists(QLatin1String("Makefile")) && qs) {
|
if (QFileInfo(makefile).exists() && qs) {
|
||||||
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory);
|
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
|
||||||
QtVersion *version = qtVersion();
|
QtVersion *version = qtVersion();
|
||||||
if (version->qmakeCommand() == qmakePath) {
|
if (version->qmakeCommand() == qmakePath) {
|
||||||
// same qtversion
|
// same qtversion
|
||||||
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
||||||
QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig());
|
QtVersionManager::scanMakeFile(makefile, version->defaultBuildConfig());
|
||||||
if (qmakeBuildConfiguration() == result.first) {
|
if (qmakeBuildConfiguration() == result.first) {
|
||||||
// The qmake Build Configuration are the same,
|
// The qmake Build Configuration are the same,
|
||||||
// now compare arguments lists
|
// now compare arguments lists
|
||||||
// we have to compare without the spec/platform cmd argument
|
// we have to compare without the spec/platform cmd argument
|
||||||
// and compare that on its own
|
// and compare that on its own
|
||||||
|
QString workingDirectory = QFileInfo(makefile).absolutePath();
|
||||||
QString actualSpec = extractSpecFromArgumentList(qs->userArguments(), workingDirectory, version);
|
QString actualSpec = extractSpecFromArgumentList(qs->userArguments(), workingDirectory, version);
|
||||||
if (actualSpec.isEmpty()) {
|
if (actualSpec.isEmpty()) {
|
||||||
// Easy one: the user has chosen not to override the settings
|
// Easy one: the user has chosen not to override the settings
|
||||||
|
|||||||
@@ -102,8 +102,9 @@ public:
|
|||||||
|
|
||||||
QString makeCommand() const;
|
QString makeCommand() const;
|
||||||
QString defaultMakeTarget() const;
|
QString defaultMakeTarget() const;
|
||||||
|
QString makefile() const;
|
||||||
|
|
||||||
bool compareToImportFrom(const QString &workingDirectory);
|
bool compareToImportFrom(const QString &makefile);
|
||||||
static QStringList removeQMLInspectorFromArgumentList(const QStringList &old);
|
static QStringList removeQMLInspectorFromArgumentList(const QStringList &old);
|
||||||
static QStringList removeSpecFromArgumentList(const QStringList &old);
|
static QStringList removeSpecFromArgumentList(const QStringList &old);
|
||||||
static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version);
|
static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version);
|
||||||
|
|||||||
@@ -1208,6 +1208,13 @@ TargetInformation Qt4ProFileNode::targetInformation(const QString &fileName) con
|
|||||||
return qt4ProFileNode->targetInformation();
|
return qt4ProFileNode->targetInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Qt4ProFileNode::makefile() const
|
||||||
|
{
|
||||||
|
if (m_varValues[Makefile].isEmpty())
|
||||||
|
return QString();
|
||||||
|
return m_varValues[Makefile].first();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Qt4ProFileNode
|
\class Qt4ProFileNode
|
||||||
Implements abstract ProjectNode class
|
Implements abstract ProjectNode class
|
||||||
@@ -1593,6 +1600,7 @@ void Qt4ProFileNode::applyEvaluate(bool parseResult, bool async)
|
|||||||
newVarValues[ConfigVar] = m_readerExact->values(QLatin1String("CONFIG"));
|
newVarValues[ConfigVar] = m_readerExact->values(QLatin1String("CONFIG"));
|
||||||
newVarValues[QmlImportPathVar] = m_readerExact->absolutePathValues(
|
newVarValues[QmlImportPathVar] = m_readerExact->absolutePathValues(
|
||||||
QLatin1String("QML_IMPORT_PATH"), m_projectDir);
|
QLatin1String("QML_IMPORT_PATH"), m_projectDir);
|
||||||
|
newVarValues[Makefile] = m_readerExact->values("MAKEFILE");
|
||||||
|
|
||||||
if (m_varValues != newVarValues) {
|
if (m_varValues != newVarValues) {
|
||||||
m_varValues = newVarValues;
|
m_varValues = newVarValues;
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ enum Qt4Variable {
|
|||||||
PrecompiledHeaderVar,
|
PrecompiledHeaderVar,
|
||||||
LibDirectoriesVar,
|
LibDirectoriesVar,
|
||||||
ConfigVar,
|
ConfigVar,
|
||||||
QmlImportPathVar
|
QmlImportPathVar,
|
||||||
|
Makefile
|
||||||
};
|
};
|
||||||
|
|
||||||
class Qt4PriFileNode;
|
class Qt4PriFileNode;
|
||||||
@@ -278,6 +279,8 @@ public:
|
|||||||
TargetInformation targetInformation(const QString &fileName) const;
|
TargetInformation targetInformation(const QString &fileName) const;
|
||||||
TargetInformation targetInformation() const;
|
TargetInformation targetInformation() const;
|
||||||
|
|
||||||
|
QString makefile() const;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
void scheduleUpdate();
|
void scheduleUpdate();
|
||||||
|
|
||||||
|
|||||||
@@ -299,7 +299,13 @@ void Qt4ProjectConfigWidget::updateImportLabel()
|
|||||||
QtVersionManager *vm = QtVersionManager::instance();
|
QtVersionManager *vm = QtVersionManager::instance();
|
||||||
// we only show if we actually have a qmake and makestep
|
// we only show if we actually have a qmake and makestep
|
||||||
if (m_buildConfiguration->qmakeStep() && m_buildConfiguration->makeStep()) {
|
if (m_buildConfiguration->qmakeStep() && m_buildConfiguration->makeStep()) {
|
||||||
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(m_buildConfiguration->buildDirectory());
|
QString makefile = m_buildConfiguration->buildDirectory();
|
||||||
|
if (m_buildConfiguration->makefile().isEmpty())
|
||||||
|
makefile.append("/Makefile");
|
||||||
|
else
|
||||||
|
makefile.append(m_buildConfiguration->makefile());
|
||||||
|
|
||||||
|
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
|
||||||
QtVersion *version = m_buildConfiguration->qtVersion();
|
QtVersion *version = m_buildConfiguration->qtVersion();
|
||||||
// check that there's a makefile
|
// check that there's a makefile
|
||||||
if (!qmakePath.isEmpty()) {
|
if (!qmakePath.isEmpty()) {
|
||||||
@@ -318,7 +324,7 @@ void Qt4ProjectConfigWidget::updateImportLabel()
|
|||||||
delete newVersion;
|
delete newVersion;
|
||||||
} else {
|
} else {
|
||||||
// check that the qmake flags, arguments match
|
// check that the qmake flags, arguments match
|
||||||
visible = !m_buildConfiguration->compareToImportFrom(m_buildConfiguration->buildDirectory());
|
visible = !m_buildConfiguration->compareToImportFrom(makefile);
|
||||||
targetMatches = true;
|
targetMatches = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -377,7 +383,13 @@ void Qt4ProjectConfigWidget::importLabelClicked()
|
|||||||
return;
|
return;
|
||||||
QString directory = m_buildConfiguration->buildDirectory();
|
QString directory = m_buildConfiguration->buildDirectory();
|
||||||
if (!directory.isEmpty()) {
|
if (!directory.isEmpty()) {
|
||||||
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(directory);
|
QString makefile = directory;
|
||||||
|
if (m_buildConfiguration->makefile().isEmpty())
|
||||||
|
makefile.append("/Makefile");
|
||||||
|
else
|
||||||
|
makefile.append(m_buildConfiguration->makefile());
|
||||||
|
|
||||||
|
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
|
||||||
if (!qmakePath.isEmpty()) {
|
if (!qmakePath.isEmpty()) {
|
||||||
QtVersionManager *vm = QtVersionManager::instance();
|
QtVersionManager *vm = QtVersionManager::instance();
|
||||||
QtVersion *version = vm->qtVersionForQMakeBinary(qmakePath);
|
QtVersion *version = vm->qtVersionForQMakeBinary(qmakePath);
|
||||||
|
|||||||
@@ -803,12 +803,12 @@ void QtVersion::updateSourcePath()
|
|||||||
// That is returns the directory
|
// That is returns the directory
|
||||||
// To find out whether we already have a qtversion for that directory call
|
// To find out whether we already have a qtversion for that directory call
|
||||||
// QtVersion *QtVersionManager::qtVersionForDirectory(const QString directory);
|
// QtVersion *QtVersionManager::qtVersionForDirectory(const QString directory);
|
||||||
QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &directory)
|
QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &makefile)
|
||||||
{
|
{
|
||||||
bool debugAdding = false;
|
bool debugAdding = false;
|
||||||
QFile makefile(directory + "/Makefile" );
|
QFile fi(makefile);
|
||||||
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
|
if (fi.exists() && fi.open(QFile::ReadOnly)) {
|
||||||
QTextStream ts(&makefile);
|
QTextStream ts(&fi);
|
||||||
QRegExp r1("QMAKE\\s*=(.*)");
|
QRegExp r1("QMAKE\\s*=(.*)");
|
||||||
while (!ts.atEnd()) {
|
while (!ts.atEnd()) {
|
||||||
QString line = ts.readLine();
|
QString line = ts.readLine();
|
||||||
@@ -854,32 +854,31 @@ void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtVersionManager::makefileIsFor(const QString &directory, const QString &proFile)
|
bool QtVersionManager::makefileIsFor(const QString &makefile, const QString &proFile)
|
||||||
{
|
{
|
||||||
if (proFile.isEmpty())
|
if (proFile.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
QString line = findQMakeLine(directory, QLatin1String("# Project:")).trimmed();
|
QString line = findQMakeLine(makefile, QLatin1String("# Project:")).trimmed();
|
||||||
if (line.isEmpty())
|
if (line.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
line = line.mid(line.indexOf(QChar(':')) + 1);
|
line = line.mid(line.indexOf(QChar(':')) + 1);
|
||||||
line = line.trimmed();
|
line = line.trimmed();
|
||||||
|
|
||||||
QFileInfo srcFileInfo(QDir(directory), line);
|
QFileInfo srcFileInfo(QFileInfo(makefile).absoluteDir(), line);
|
||||||
QFileInfo proFileInfo(proFile);
|
QFileInfo proFileInfo(proFile);
|
||||||
return srcFileInfo == proFileInfo;
|
return srcFileInfo == proFileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfigs defaultBuildConfig)
|
QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(const QString &makefile, QtVersion::QmakeBuildConfigs defaultBuildConfig)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug()<<"ScanMakeFile, the gory details:";
|
qDebug()<<"ScanMakeFile, the gory details:";
|
||||||
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
|
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
|
||||||
QStringList result2;
|
QStringList result2;
|
||||||
|
|
||||||
QString line = findQMakeLine(directory, QLatin1String("# Command:"));
|
QString line = findQMakeLine(makefile, QLatin1String("# Command:"));
|
||||||
if (!line.isEmpty()) {
|
if (!line.isEmpty()) {
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug()<<"Found line"<<line;
|
qDebug()<<"Found line"<<line;
|
||||||
@@ -930,11 +929,11 @@ QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(
|
|||||||
return qMakePair(result, result2);
|
return qMakePair(result, result2);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QtVersionManager::findQMakeLine(const QString &directory, const QString &key)
|
QString QtVersionManager::findQMakeLine(const QString &makefile, const QString &key)
|
||||||
{
|
{
|
||||||
QFile makefile(directory + QLatin1String("/Makefile" ));
|
QFile fi(makefile);
|
||||||
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
|
if (fi.exists() && fi.open(QFile::ReadOnly)) {
|
||||||
QTextStream ts(&makefile);
|
QTextStream ts(&fi);
|
||||||
while (!ts.atEnd()) {
|
while (!ts.atEnd()) {
|
||||||
const QString line = ts.readLine();
|
const QString line = ts.readLine();
|
||||||
if (line.startsWith(key))
|
if (line.startsWith(key))
|
||||||
|
|||||||
@@ -250,10 +250,10 @@ public:
|
|||||||
QSet<QString> supportedTargetIds() const;
|
QSet<QString> supportedTargetIds() const;
|
||||||
|
|
||||||
// Static Methods
|
// Static Methods
|
||||||
static bool makefileIsFor(const QString &directory, const QString &proFile);
|
static bool makefileIsFor(const QString &makefile, const QString &proFile);
|
||||||
static QPair<QtVersion::QmakeBuildConfigs, QStringList> scanMakeFile(const QString &directory,
|
static QPair<QtVersion::QmakeBuildConfigs, QStringList> scanMakeFile(const QString &makefile,
|
||||||
QtVersion::QmakeBuildConfigs defaultBuildConfig);
|
QtVersion::QmakeBuildConfigs defaultBuildConfig);
|
||||||
static QString findQMakeBinaryFromMakefile(const QString &directory);
|
static QString findQMakeBinaryFromMakefile(const QString &makefile);
|
||||||
bool isValidId(int id) const;
|
bool isValidId(int id) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@@ -379,11 +379,11 @@ TargetSetupPage::recursivelyCheckDirectoryForBuild(const QString &directory, con
|
|||||||
return results;
|
return results;
|
||||||
|
|
||||||
// Check for in-source builds first:
|
// Check for in-source builds first:
|
||||||
QString qmakeBinary = QtVersionManager::findQMakeBinaryFromMakefile(directory);
|
QString qmakeBinary = QtVersionManager::findQMakeBinaryFromMakefile(directory + "/Makefile");
|
||||||
QDir dir(directory);
|
QDir dir(directory);
|
||||||
|
|
||||||
// Recurse into subdirectories:
|
// Recurse into subdirectories:
|
||||||
if (qmakeBinary.isNull() || !QtVersionManager::makefileIsFor(directory, proFile)) {
|
if (qmakeBinary.isNull() || !QtVersionManager::makefileIsFor(directory + "/Makefile", proFile)) {
|
||||||
QStringList subDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
QStringList subDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
foreach (QString subDir, subDirs)
|
foreach (QString subDir, subDirs)
|
||||||
results.append(recursivelyCheckDirectoryForBuild(dir.absoluteFilePath(subDir),
|
results.append(recursivelyCheckDirectoryForBuild(dir.absoluteFilePath(subDir),
|
||||||
@@ -409,7 +409,7 @@ TargetSetupPage::recursivelyCheckDirectoryForBuild(const QString &directory, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
||||||
QtVersionManager::scanMakeFile(directory, info.version->defaultBuildConfig());
|
QtVersionManager::scanMakeFile(directory + "/Makefile", info.version->defaultBuildConfig());
|
||||||
info.buildConfig = result.first;
|
info.buildConfig = result.first;
|
||||||
info.additionalArguments = Qt4BuildConfiguration::removeSpecFromArgumentList(result.second);
|
info.additionalArguments = Qt4BuildConfiguration::removeSpecFromArgumentList(result.second);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user