Implement QMAKE_SUBSTITUTES.config = verbatim.

Change-Id: Ie0b333fa7fae2283e99e42f9cd7bab4e84991f40
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
Stephen Kelly 2012-02-11 10:42:03 +01:00 committed by Qt by Nokia
parent 8b7a9b4898
commit 7a7d82ffd9
4 changed files with 76 additions and 50 deletions

View File

@ -498,8 +498,18 @@ MakefileGenerator::init()
} }
outn = fileFixify(inn.left(inn.length()-3), qmake_getpwd(), Option::output_dir); outn = fileFixify(inn.left(inn.length()-3), qmake_getpwd(), Option::output_dir);
} }
QString confign = subs.at(i) + ".config";
bool verbatim = false;
if (v.contains(confign))
verbatim = v[confign].contains(QLatin1String("verbatim"));
QFile in(inn); QFile in(inn);
if (in.open(QFile::ReadOnly)) { if (in.open(QFile::ReadOnly)) {
QByteArray contentBytes;
if (verbatim) {
contentBytes = in.readAll();
} else {
QString contents; QString contents;
QStack<int> state; QStack<int> state;
enum { IN_CONDITION, MET_CONDITION, PENDING_CONDITION }; enum { IN_CONDITION, MET_CONDITION, PENDING_CONDITION };
@ -550,10 +560,12 @@ MakefileGenerator::init()
contents += project->expand(line, in.fileName(), count); contents += project->expand(line, in.fileName(), count);
} }
} }
contentBytes = contents.toUtf8();
}
QFile out(outn); QFile out(outn);
if (out.exists() && out.open(QFile::ReadOnly)) { if (out.exists() && out.open(QFile::ReadOnly)) {
QString old = QString::fromUtf8(out.readAll()); QByteArray old = out.readAll();
if(contents == old) { if (contentBytes == old) {
v["QMAKE_INTERNAL_INCLUDED_FILES"].append(in.fileName()); v["QMAKE_INTERNAL_INCLUDED_FILES"].append(in.fileName());
continue; continue;
} }
@ -567,7 +579,7 @@ MakefileGenerator::init()
mkdir(QFileInfo(out).absolutePath()); mkdir(QFileInfo(out).absolutePath());
if(out.open(QFile::WriteOnly)) { if(out.open(QFile::WriteOnly)) {
v["QMAKE_INTERNAL_INCLUDED_FILES"].append(in.fileName()); v["QMAKE_INTERNAL_INCLUDED_FILES"].append(in.fileName());
out.write(contents.toUtf8()); out.write(contentBytes);
} else { } else {
warn_msg(WarnLogic, "Cannot open substitute for output '%s'", warn_msg(WarnLogic, "Cannot open substitute for output '%s'",
out.fileName().toLatin1().constData()); out.fileName().toLatin1().constData());

View File

@ -0,0 +1,3 @@
This file is $processed verbatim. It's not going to "warn about
anything that is usually substituted in qmake such as $${PWD}.

View File

@ -1,5 +1,8 @@
QMAKE_SUBSTITUTES += test.in sub/test2.in indirect QMAKE_SUBSTITUTES += test.in sub/test2.in indirect copy
indirect.input = $$PWD/test3.txt indirect.input = $$PWD/test3.txt
indirect.output = $$OUT_PWD/sub/indirect_test.txt indirect.output = $$OUT_PWD/sub/indirect_test.txt
copy.input = $$PWD/copy.txt
copy.output = $$OUT_PWD/copy_test.txt
copy.config = verbatim

View File

@ -510,6 +510,14 @@ void tst_qmake::substitutes()
QVERIFY( test_compiler.exists( buildDir, "test", Plain, "" )); QVERIFY( test_compiler.exists( buildDir, "test", Plain, "" ));
QVERIFY( test_compiler.exists( buildDir, "sub/test2", Plain, "" )); QVERIFY( test_compiler.exists( buildDir, "sub/test2", Plain, "" ));
QVERIFY( test_compiler.exists( buildDir, "sub/indirect_test.txt", Plain, "" )); QVERIFY( test_compiler.exists( buildDir, "sub/indirect_test.txt", Plain, "" ));
QFile copySource(workDir + "/copy.txt");
QFile copyDestination(buildDir + "/copy_test.txt");
QVERIFY(copySource.open(QFile::ReadOnly));
QVERIFY(copyDestination.open(QFile::ReadOnly));
QCOMPARE(copySource.readAll(), copyDestination.readAll());
QVERIFY( test_compiler.makeDistClean( buildDir )); QVERIFY( test_compiler.makeDistClean( buildDir ));
} }