From 82d5f0ae622d2579b925a5f6a8054eeeccb9a233 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 18 Aug 2010 11:44:27 +0200 Subject: add indirect input/output specification capability to QMAKE_SUBSTITUTES like in SUBDIRS, the specified strings can now be basenames of "structures" which specify the actual input and output files: QMAKE_SUBSTITUTES += test test.input = infile.txt.in test.output = foobar.out Reviewed-by: joerg --- qmake/generators/makefile.cpp | 37 ++++++++++++++++++++----- tests/auto/qmake/testdata/substitutes/test.pro | 6 +++- tests/auto/qmake/testdata/substitutes/test3.txt | 1 + tests/auto/qmake/tst_qmake.cpp | 2 ++ 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 tests/auto/qmake/testdata/substitutes/test3.txt diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 852471d..03732ba 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -466,14 +466,37 @@ MakefileGenerator::init() if(!project->isEmpty("QMAKE_SUBSTITUTES")) { const QStringList &subs = v["QMAKE_SUBSTITUTES"]; for(int i = 0; i < subs.size(); ++i) { - if(!subs.at(i).endsWith(".in")) { - warn_msg(WarnLogic, "Substitute '%s' does not end with '.in'", - subs.at(i).toLatin1().constData()); - continue; + QString inn = subs.at(i) + ".input", outn = subs.at(i) + ".output"; + if (v.contains(inn) || v.contains(outn)) { + if (!v.contains(inn) || !v.contains(outn)) { + warn_msg(WarnLogic, "Substitute '%s' has only one of .input and .output", + subs.at(i).toLatin1().constData()); + continue; + } + const QStringList &tinn = v[inn], &toutn = v[outn]; + if (tinn.length() != 1) { + warn_msg(WarnLogic, "Substitute '%s.input' does not have exactly one value", + subs.at(i).toLatin1().constData()); + continue; + } + if (toutn.length() != 1) { + warn_msg(WarnLogic, "Substitute '%s.output' does not have exactly one value", + subs.at(i).toLatin1().constData()); + continue; + } + inn = tinn.first(); + outn = toutn.first(); + } else { + inn = subs.at(i); + if(!inn.endsWith(".in")) { + warn_msg(WarnLogic, "Substitute '%s' does not end with '.in'", + inn.toLatin1().constData()); + continue; + } + outn = inn.left(inn.length()-3); } - QFile in(fileFixify(subs.at(i))); - QFile out(fileFixify(subs.at(i).left(subs.at(i).length()-3), - qmake_getpwd(), Option::output_dir)); + QFile in(fileFixify(inn)); + QFile out(fileFixify(outn, qmake_getpwd(), Option::output_dir)); if(in.open(QFile::ReadOnly)) { QString contents; QStack state; diff --git a/tests/auto/qmake/testdata/substitutes/test.pro b/tests/auto/qmake/testdata/substitutes/test.pro index ddad93f..26b0272 100644 --- a/tests/auto/qmake/testdata/substitutes/test.pro +++ b/tests/auto/qmake/testdata/substitutes/test.pro @@ -1 +1,5 @@ -QMAKE_SUBSTITUTES += test.in sub/test2.in +QMAKE_SUBSTITUTES += test.in sub/test2.in indirect + +indirect.input = $$PWD/test3.txt +indirect.output = $$OUT_PWD/sub/indirect_test.txt + diff --git a/tests/auto/qmake/testdata/substitutes/test3.txt b/tests/auto/qmake/testdata/substitutes/test3.txt new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/tests/auto/qmake/testdata/substitutes/test3.txt @@ -0,0 +1 @@ +hello diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 060fa01..277e9f8 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -484,12 +484,14 @@ void tst_qmake::substitutes() QVERIFY( test_compiler.qmake( workDir, "test" )); QVERIFY( test_compiler.exists( workDir, "test", Plain, "" )); QVERIFY( test_compiler.exists( workDir, "sub/test2", Plain, "" )); + QVERIFY( test_compiler.exists( workDir, "sub/indirect_test.txt", Plain, "" )); QVERIFY( test_compiler.makeDistClean( workDir )); QString buildDir = base_path + "/testdata/substitutes_build"; QVERIFY( test_compiler.qmake( workDir, "test", buildDir )); 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, "" )); QVERIFY( test_compiler.makeDistClean( buildDir )); } -- cgit v0.12