[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/devtools/kdevelop4-extra-plugins/qmake
From: Milian Wolff <mail () milianw ! de>
Date: 2010-10-26 15:09:45
Message-ID: 20101026150945.CE7D6AC897 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1189987 by mwolff:
handle QtconfigVariable in variablereferenceparser and warn about it
fix qregexp replacmenet of the same in QMakeMkSpecs (TODO: cleanup)
add unit test
M +4 -0 qmakefile.cpp
M +5 -3 qmakemkspecs.cpp
M +58 -0 tests/test_qmakefile.cpp
M +2 -0 tests/test_qmakefile.h
M +10 -0 variablereferenceparser.cpp
M +1 -0 variablereferenceparser.h
--- trunk/playground/devtools/kdevelop4-extra-plugins/qmake/qmakefile.cpp #1189986:1189987
@@ -320,6 +320,10 @@
///TODO: make vs qmake time
varValue = QProcessEnvironment::systemEnvironment().value(variable);
break;
+ case VariableInfo::QtConfigVariable:
+ //should be handled in QMakeProjectfile
+ kWarning(9024) << "QtConfigVariable slipped through:" << variable;
+ continue;
case VariableInfo::FunctionCall:
///TODO:
kWarning(9024) << "unimplemented function call in variable:" << variable;
--- trunk/playground/devtools/kdevelop4-extra-plugins/qmake/qmakemkspecs.cpp #1189986:1189987
@@ -19,7 +19,9 @@
***************************************************************************/
#include "qmakemkspecs.h"
+
#include <QStringList>
+#include <QDebug>
QMakeMkSpecs::QMakeMkSpecs( const QString& basicmkspecs, const QHash<QString,QString>& variables )
: QMakeFile( basicmkspecs ), m_qmakeInternalVariables( variables )
@@ -33,13 +35,13 @@
QString QMakeMkSpecs::resolveInternalQMakeVariables( const QString& value ) const
{
- QRegExp mkspecsvar("$$\\[([^\\]])\\]");
+ QRegExp mkspecsvar("\\$\\$\\[([^\\]]+)\\]", Qt::CaseSensitive, QRegExp::RegExp2);
int pos = 0;
QString ret = value;
- while( pos != -1 )
+ while( -1 != (pos = mkspecsvar.indexIn( value, pos )) )
{
- pos = mkspecsvar.indexIn( value, pos );
ret.replace( pos, mkspecsvar.matchedLength(), qmakeInternalVariable( mkspecsvar.cap(1) ) );
+ pos += mkspecsvar.matchedLength();
}
return ret;
}
--- trunk/playground/devtools/kdevelop4-extra-plugins/qmake/tests/test_qmakefile.cpp #1189986:1189987
@@ -21,6 +21,8 @@
#include "test_qmakefile.h"
#include "qmakefile.h"
#include "variablereferenceparser.h"
+#include "qmakeprojectfile.h"
+#include "qmakemkspecs.h"
#include <QTest>
@@ -28,6 +30,8 @@
#include <QProcessEnvironment>
#include <QDebug>
#include <KTemporaryFile>
+#include <KProcess>
+#include <QFileInfo>
QTEST_MAIN(TestQMakeFile);
@@ -65,6 +69,37 @@
}
+QHash<QString,QString> queryQMake( const QString& path )
+{
+ QHash<QString,QString> hash;
+ KProcess p;
+ QStringList queryVariables;
+ queryVariables << "QMAKE_MKSPECS" << "QMAKE_VERSION" <<
+ "QT_INSTALL_BINS" << "QT_INSTALL_CONFIGURATION" <<
+ "QT_INSTALL_DATA" << "QT_INSTALL_DEMOS" << "QT_INSTALL_DOCS" <<
+ "QT_INSTALL_EXAMPLES" << "QT_INSTALL_HEADERS" <<
+ "QT_INSTALL_LIBS" << "QT_INSTALL_PLUGINS" << "QT_INSTALL_PREFIX" <<
+ "QT_INSTALL_TRANSLATIONS" << "QT_VERSION";
+
+ QFileInfo info(path);
+ Q_ASSERT(info.exists());
+ foreach( const QString& var, queryVariables)
+ {
+ p.clearProgram();
+ p.setOutputChannelMode( KProcess::OnlyStdoutChannel );
+ p.setWorkingDirectory( info.absolutePath() );
+ //To be implemented when there's an API to fetch Env from Project
+ //p.setEnv();
+ p << "qmake-qt4" << "-query" << var;
+ p.execute();
+ QString result = QString::fromLocal8Bit( p.readAllStandardOutput() ).trimmed();
+ if( result != "**Unknown**")
+ hash[var] = result;
+ }
+ qDebug() << "Ran qmake-qt4, found:" << hash;
+ return hash;
+}
+
void TestQMakeFile::varResolution()
{
QFETCH(QString, fileContents);
@@ -152,4 +187,27 @@
QTest::newRow("dotdot") << "..";
}
+void TestQMakeFile::libTarget()
+{
+ KTemporaryFile tmpfile;
+ tmpfile.open();
+ QTextStream stream(&tmpfile);
+ stream << "TARGET = MyLib\nTEMPLATE = lib\n";
+ stream << flush;
+ tmpfile.close();
+
+ QMakeProjectFile file(tmpfile.fileName());
+
+ QHash<QString,QString> qmvars = queryQMake( tmpfile.fileName() );
+ QString specFile = qmvars["QMAKE_MKSPECS"] + "/default/qmake.conf";
+ QVERIFY(QFile::exists(specFile));
+ QMakeMkSpecs* mkspecs = new QMakeMkSpecs( specFile, qmvars );
+ mkspecs->read();
+ file.setMkSpecs(mkspecs);
+ QVERIFY(file.read());
+
+ QCOMPARE(file.targets(), QStringList() << "MyLib");
+}
+
+
#include "test_qmakefile.moc"
--- trunk/playground/devtools/kdevelop4-extra-plugins/qmake/tests/test_qmakefile.h #1189986:1189987
@@ -32,6 +32,8 @@
void referenceParser_data();
void referenceParser();
+
+ void libTarget();
};
#endif // TEST_QMAKEFILE_H
--- trunk/playground/devtools/kdevelop4-extra-plugins/qmake/variablereferenceparser.cpp #1189986:1189987
@@ -86,6 +86,16 @@
}while( curpos < size && it->unicode() != '}' );
variable = m_content.mid( begin + 3, curpos - begin - 3 );
++curpos;
+ }else if( it->unicode() == '[' )
+ {
+ do
+ {
+ it++;
+ curpos++;
+ }while( curpos < size && it->unicode() != ']' );
+ type = VariableInfo::QtConfigVariable;
+ variable = m_content.mid( begin + 3, curpos - begin - 3 );
+ ++curpos;
}else
{
do
--- trunk/playground/devtools/kdevelop4-extra-plugins/qmake/variablereferenceparser.h #1189986:1189987
@@ -33,6 +33,7 @@
enum VariableType
{
QMakeVariable,
+ QtConfigVariable,
ShellVariableResolveQMake,
ShellVariableResolveMake,
FunctionCall,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic