summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-08-18 11:44:27 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-08-23 13:52:55 +0200
commit82d5f0ae622d2579b925a5f6a8054eeeccb9a233 (patch)
treea27709aecb8d209180c9be497124ad004f6f2c25
parent2d60953c4664958c665114c52ce2b92ed11b1488 (diff)
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
-rw-r--r--qmake/generators/makefile.cpp37
-rw-r--r--tests/auto/qmake/testdata/substitutes/test.pro6
-rw-r--r--tests/auto/qmake/testdata/substitutes/test3.txt1
-rw-r--r--tests/auto/qmake/tst_qmake.cpp2
4 files changed, 38 insertions, 8 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 852471df42..03732ba20a 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<int> state;
diff --git a/tests/auto/qmake/testdata/substitutes/test.pro b/tests/auto/qmake/testdata/substitutes/test.pro
index ddad93f697..26b02722e8 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 0000000000..ce01362503
--- /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 060fa0127b..277e9f8b46 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 ));
}