From: Stephen Kelly Date: Sat, 11 Feb 2012 09:42:03 +0000 (+0100) Subject: Implement QMAKE_SUBSTITUTES.config = verbatim. X-Git-Tag: qt-v5.0.0-alpha1~1141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a7d82ffd9fac842fb573aad4fe28e27bc879f91;p=profile%2Fivi%2Fqtbase.git Implement QMAKE_SUBSTITUTES.config = verbatim. Change-Id: Ie0b333fa7fae2283e99e42f9cd7bab4e84991f40 Reviewed-by: Oswald Buddenhagen --- diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index b595486..dd09859 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -498,62 +498,74 @@ MakefileGenerator::init() } 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); - if(in.open(QFile::ReadOnly)) { - QString contents; - QStack state; - enum { IN_CONDITION, MET_CONDITION, PENDING_CONDITION }; - for(int count = 1; !in.atEnd(); ++count) { - QString line = QString::fromUtf8(in.readLine()); - if(line.startsWith("!!IF ")) { - if(state.isEmpty() || state.top() == IN_CONDITION) { - QString test = line.mid(5, line.length()-(5+1)); - if(project->test(test)) - state.push(IN_CONDITION); - else - state.push(PENDING_CONDITION); - } else { - state.push(MET_CONDITION); - } - } else if(line.startsWith("!!ELIF ")) { - if(state.isEmpty()) { - warn_msg(WarnLogic, "(%s:%d): Unexpected else condition", - in.fileName().toLatin1().constData(), count); - } else if(state.top() == PENDING_CONDITION) { - QString test = line.mid(7, line.length()-(7+1)); - if(project->test(test)) { + if (in.open(QFile::ReadOnly)) { + QByteArray contentBytes; + if (verbatim) { + contentBytes = in.readAll(); + } else { + QString contents; + QStack state; + enum { IN_CONDITION, MET_CONDITION, PENDING_CONDITION }; + for (int count = 1; !in.atEnd(); ++count) { + QString line = QString::fromUtf8(in.readLine()); + if (line.startsWith("!!IF ")) { + if (state.isEmpty() || state.top() == IN_CONDITION) { + QString test = line.mid(5, line.length()-(5+1)); + if (project->test(test)) + state.push(IN_CONDITION); + else + state.push(PENDING_CONDITION); + } else { + state.push(MET_CONDITION); + } + } else if (line.startsWith("!!ELIF ")) { + if (state.isEmpty()) { + warn_msg(WarnLogic, "(%s:%d): Unexpected else condition", + in.fileName().toLatin1().constData(), count); + } else if (state.top() == PENDING_CONDITION) { + QString test = line.mid(7, line.length()-(7+1)); + if (project->test(test)) { + state.pop(); + state.push(IN_CONDITION); + } + } else if (state.top() == IN_CONDITION) { + state.pop(); + state.push(MET_CONDITION); + } + } else if (line.startsWith("!!ELSE")) { + if (state.isEmpty()) { + warn_msg(WarnLogic, "(%s:%d): Unexpected else condition", + in.fileName().toLatin1().constData(), count); + } else if (state.top() == PENDING_CONDITION) { state.pop(); state.push(IN_CONDITION); + } else if (state.top() == IN_CONDITION) { + state.pop(); + state.push(MET_CONDITION); } - } else if(state.top() == IN_CONDITION) { - state.pop(); - state.push(MET_CONDITION); - } - } else if(line.startsWith("!!ELSE")) { - if(state.isEmpty()) { - warn_msg(WarnLogic, "(%s:%d): Unexpected else condition", - in.fileName().toLatin1().constData(), count); - } else if(state.top() == PENDING_CONDITION) { - state.pop(); - state.push(IN_CONDITION); - } else if(state.top() == IN_CONDITION) { - state.pop(); - state.push(MET_CONDITION); + } else if (line.startsWith("!!ENDIF")) { + if (state.isEmpty()) + warn_msg(WarnLogic, "(%s:%d): Unexpected endif", + in.fileName().toLatin1().constData(), count); + else + state.pop(); + } else if (state.isEmpty() || state.top() == IN_CONDITION) { + contents += project->expand(line, in.fileName(), count); } - } else if(line.startsWith("!!ENDIF")) { - if(state.isEmpty()) - warn_msg(WarnLogic, "(%s:%d): Unexpected endif", - in.fileName().toLatin1().constData(), count); - else - state.pop(); - } else if(state.isEmpty() || state.top() == IN_CONDITION) { - contents += project->expand(line, in.fileName(), count); } + contentBytes = contents.toUtf8(); } QFile out(outn); - if(out.exists() && out.open(QFile::ReadOnly)) { - QString old = QString::fromUtf8(out.readAll()); - if(contents == old) { + if (out.exists() && out.open(QFile::ReadOnly)) { + QByteArray old = out.readAll(); + if (contentBytes == old) { v["QMAKE_INTERNAL_INCLUDED_FILES"].append(in.fileName()); continue; } @@ -567,7 +579,7 @@ MakefileGenerator::init() mkdir(QFileInfo(out).absolutePath()); if(out.open(QFile::WriteOnly)) { v["QMAKE_INTERNAL_INCLUDED_FILES"].append(in.fileName()); - out.write(contents.toUtf8()); + out.write(contentBytes); } else { warn_msg(WarnLogic, "Cannot open substitute for output '%s'", out.fileName().toLatin1().constData()); diff --git a/tests/auto/tools/qmake/testdata/substitutes/copy.txt b/tests/auto/tools/qmake/testdata/substitutes/copy.txt new file mode 100644 index 0000000..65e5840 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/substitutes/copy.txt @@ -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}. diff --git a/tests/auto/tools/qmake/testdata/substitutes/test.pro b/tests/auto/tools/qmake/testdata/substitutes/test.pro index 26b0272..65bb2d8 100644 --- a/tests/auto/tools/qmake/testdata/substitutes/test.pro +++ b/tests/auto/tools/qmake/testdata/substitutes/test.pro @@ -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.output = $$OUT_PWD/sub/indirect_test.txt +copy.input = $$PWD/copy.txt +copy.output = $$OUT_PWD/copy_test.txt +copy.config = verbatim diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index fcebd6b..4da781f 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -510,6 +510,14 @@ void tst_qmake::substitutes() QVERIFY( test_compiler.exists( buildDir, "test", Plain, "" )); QVERIFY( test_compiler.exists( buildDir, "sub/test2", 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 )); }