diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-07-03 10:23:32 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-07-04 09:54:10 +0000 |
commit | d0e8197bbfb7d2bd33b957a9965fcc5d9b0982a6 (patch) | |
tree | 850f2cea1fc631054ec8a3b8c5d555b58a6d3de0 /tests | |
parent | 5b2b5498c6ee135bd1a8eb39fa96cfe28461234e (diff) |
Give rules access to artifacts matching "explicitlyDependsOn"
If outputs "explicitly depend on" other artifacts, then it is very
likely that these are needed in the prepare script and/or the command.
In fact, such artifacts are almost like inputs, except that they are
always passed the same way, regardless of whether we have a multiplex
rule or not.
[ChangeLog] Artifacts corresponding to the "explicitlyDependsOn" property
are now available under this name in rules and commands.
Change-Id: I28e41c29e250cccb1a64e83152528c28f48d5703
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/api/testdata/explicitly-depends-on/a.in (renamed from tests/auto/api/testdata/explicitly-depends-on/dependency.txt) | 0 | ||||
-rw-r--r-- | tests/auto/api/testdata/explicitly-depends-on/b.in | 0 | ||||
-rw-r--r-- | tests/auto/api/testdata/explicitly-depends-on/c.in | 0 | ||||
-rw-r--r-- | tests/auto/api/testdata/explicitly-depends-on/compiler.cpp | 11 | ||||
-rw-r--r-- | tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs | 71 | ||||
-rw-r--r-- | tests/auto/api/tst_api.cpp | 24 |
6 files changed, 81 insertions, 25 deletions
diff --git a/tests/auto/api/testdata/explicitly-depends-on/dependency.txt b/tests/auto/api/testdata/explicitly-depends-on/a.in index e69de29bb..e69de29bb 100644 --- a/tests/auto/api/testdata/explicitly-depends-on/dependency.txt +++ b/tests/auto/api/testdata/explicitly-depends-on/a.in diff --git a/tests/auto/api/testdata/explicitly-depends-on/b.in b/tests/auto/api/testdata/explicitly-depends-on/b.in new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/api/testdata/explicitly-depends-on/b.in diff --git a/tests/auto/api/testdata/explicitly-depends-on/c.in b/tests/auto/api/testdata/explicitly-depends-on/c.in new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/api/testdata/explicitly-depends-on/c.in diff --git a/tests/auto/api/testdata/explicitly-depends-on/compiler.cpp b/tests/auto/api/testdata/explicitly-depends-on/compiler.cpp new file mode 100644 index 000000000..57b7016df --- /dev/null +++ b/tests/auto/api/testdata/explicitly-depends-on/compiler.cpp @@ -0,0 +1,11 @@ +#include <fstream> + +#include <cassert> + +int main(int argc, char *argv[]) +{ + assert(argc == 3); + std::ofstream target(argv[2]); + assert(target); + target << argv[1]; +} diff --git a/tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs b/tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs index eda4e27df..bbe00083d 100644 --- a/tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs +++ b/tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs @@ -1,30 +1,59 @@ import qbs +import qbs.FileInfo import qbs.TextFile -Product { - type: "mytype" - files: "dependency.txt" - FileTagger { - patterns: "*.txt" - fileTags: ["txt"] +Project { + CppApplication { + name: "compiler" + files: ["compiler.cpp"] } - Rule { - multiplex: true - explicitlyDependsOn: "txt" - Artifact { - filePath: "test.mytype" - fileTags: product.type + Product { + name: "p" + type: ["mytype"] + + Depends { name: "compiler" } + + Rule { + inputs: ["mytype.in"] + explicitlyDependsOn: ["application"] + Artifact { + filePath: input.fileName + ".out" + fileTags: product.type + } + prepare: { + var compiler = explicitlyDependsOn["application"][0].filePath; + var cmd = new Command(compiler, [input.filePath, output.filePath]); + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + return [cmd]; + } } - prepare: { - var cmd = new JavaScriptCommand(); - cmd.description = "Creating output artifact"; - cmd.highlight = "codegen"; - cmd.sourceCode = function() { - var file = new TextFile(output.filePath, TextFile.WriteOnly); - file.truncate(); - file.close(); + + Rule { + multiplex: true + explicitlyDependsOn: ["application"] + Artifact { + filePath: "compiler-name.txt" + fileTags: product.type } - return cmd; + prepare: { + var nameCmd = new JavaScriptCommand(); + nameCmd.description = "writing compiler name"; + nameCmd.sourceCode = function() { + var compiler = explicitlyDependsOn["application"][0].filePath; + var file = new TextFile(output.filePath, TextFile.WriteOnly); + file.write("compiler file name: " + FileInfo.baseName(compiler)); + file.close(); + } + return [nameCmd]; + } + } + + FileTagger { + patterns: "*.in" + fileTags: ["mytype.in"] } + + files: ["a.in", "b.in", "c.in"] } } diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 29891eecc..0b46f04ba 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -1140,18 +1140,34 @@ void TestApi::explicitlyDependsOn() BuildDescriptionReceiver receiver; qbs::ErrorInfo errorInfo = doBuildProject("explicitly-depends-on", &receiver); VERIFY_NO_ERROR(errorInfo); - QVERIFY(receiver.descriptions.contains("Creating output artifact")); + QVERIFY2(receiver.descriptions.contains("compiling compiler.cpp"), + qPrintable(receiver.descriptions)); + QVERIFY2(receiver.descriptions.contains("compiling a.in"), qPrintable(receiver.descriptions)); + QVERIFY2(receiver.descriptions.contains("compiling b.in"), qPrintable(receiver.descriptions)); + QVERIFY2(receiver.descriptions.contains("compiling c.in"), qPrintable(receiver.descriptions)); + QFile txtFile(relativeProductBuildDir("p") + "/compiler-name.txt"); + QVERIFY2(txtFile.open(QIODevice::ReadOnly), qPrintable(txtFile.errorString())); + const QByteArray content = txtFile.readAll(); + QCOMPARE(content, QByteArray("compiler file name: compiler")); receiver.descriptions.clear(); errorInfo = doBuildProject("explicitly-depends-on", &receiver); + QVERIFY2(!receiver.descriptions.contains("compiling compiler.cpp"), + qPrintable(receiver.descriptions)); + QVERIFY2(!receiver.descriptions.contains("compiling a.in"), qPrintable(receiver.descriptions)); + QVERIFY2(!receiver.descriptions.contains("compiling b.in"), qPrintable(receiver.descriptions)); + QVERIFY2(!receiver.descriptions.contains("compiling c.in"), qPrintable(receiver.descriptions)); VERIFY_NO_ERROR(errorInfo); - QVERIFY(!receiver.descriptions.contains("Creating output artifact")); WAIT_FOR_NEW_TIMESTAMP(); - touch("dependency.txt"); + touch("compiler.cpp"); errorInfo = doBuildProject("explicitly-depends-on", &receiver); VERIFY_NO_ERROR(errorInfo); - QVERIFY(receiver.descriptions.contains("Creating output artifact")); + QVERIFY2(receiver.descriptions.contains("compiling compiler.cpp"), + qPrintable(receiver.descriptions)); + QVERIFY2(receiver.descriptions.contains("compiling a.in"), qPrintable(receiver.descriptions)); + QVERIFY2(receiver.descriptions.contains("compiling b.in"), qPrintable(receiver.descriptions)); + QVERIFY2(receiver.descriptions.contains("compiling c.in"), qPrintable(receiver.descriptions)); } void TestApi::exportSimple() |