From a03270f8917a5e5e6fd0c3ffcf3fb4f705e8cffa Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Sun, 28 Oct 2018 01:52:15 +0200 Subject: rcc: Add -d option to output a Makefile-syntax depfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The -d option makes rcc output a dependency file with the specified file name. The resulting dependency file is useful for make or ninja based build systems. [ChangeLog][Tools][rcc] Added -d option to generate a dependency file. Fixes: QTBUG-45460 Change-Id: I495ade50f8d9865d4c00dce9373b2b6d1a6c8f2f Reviewed-by: Jörg Bornemann --- .../auto/tools/rcc/data/depfile/simple.d.expected | 1 + tests/auto/tools/rcc/data/depfile/simple.qrc | 6 +++ .../tools/rcc/data/depfile/specialchar$file.txt | 1 + .../tools/rcc/data/depfile/specialchar.d.expected | 1 + tests/auto/tools/rcc/data/depfile/specialchar.qrc | 6 +++ tests/auto/tools/rcc/tst_rcc.cpp | 48 ++++++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 tests/auto/tools/rcc/data/depfile/simple.d.expected create mode 100644 tests/auto/tools/rcc/data/depfile/simple.qrc create mode 100644 tests/auto/tools/rcc/data/depfile/specialchar$file.txt create mode 100644 tests/auto/tools/rcc/data/depfile/specialchar.d.expected create mode 100644 tests/auto/tools/rcc/data/depfile/specialchar.qrc (limited to 'tests/auto/tools/rcc') diff --git a/tests/auto/tools/rcc/data/depfile/simple.d.expected b/tests/auto/tools/rcc/data/depfile/simple.d.expected new file mode 100644 index 0000000000..a89b61bdc7 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/simple.d.expected @@ -0,0 +1 @@ +simple.qrc.cpp: ../images/images/circle.png ../images/images/square.png diff --git a/tests/auto/tools/rcc/data/depfile/simple.qrc b/tests/auto/tools/rcc/data/depfile/simple.qrc new file mode 100644 index 0000000000..521dc4d4a0 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/simple.qrc @@ -0,0 +1,6 @@ + + + ../images/images/circle.png + ../images/images/square.png + + diff --git a/tests/auto/tools/rcc/data/depfile/specialchar$file.txt b/tests/auto/tools/rcc/data/depfile/specialchar$file.txt new file mode 100644 index 0000000000..5da849b5c6 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar$file.txt @@ -0,0 +1 @@ +ABC diff --git a/tests/auto/tools/rcc/data/depfile/specialchar.d.expected b/tests/auto/tools/rcc/data/depfile/specialchar.d.expected new file mode 100644 index 0000000000..9dd1af0958 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar.d.expected @@ -0,0 +1 @@ +specialchar.qrc.cpp: specialchar$$file.txt ../images/images/subdir/triangle.png diff --git a/tests/auto/tools/rcc/data/depfile/specialchar.qrc b/tests/auto/tools/rcc/data/depfile/specialchar.qrc new file mode 100644 index 0000000000..133cbc7655 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar.qrc @@ -0,0 +1,6 @@ + + + ../images/images/subdir/triangle.png + specialchar$file.txt + + diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 24fd79cf19..42a4134e5f 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -89,6 +89,9 @@ private slots: void readback_data(); void readback(); + void depFileGeneration_data(); + void depFileGeneration(); + void python(); void cleanupTestCase(); @@ -416,6 +419,49 @@ void tst_rcc::readback() QCOMPARE(resourceData, fileSystemData); } +void tst_rcc::depFileGeneration_data() +{ + QTest::addColumn("qrcfile"); + QTest::addColumn("depfile"); + QTest::addColumn("expected"); + + QTest::newRow("simple") << "simple.qrc" << "simple.d" << "simple.d.expected"; + QTest::newRow("specialchar") << "specialchar.qrc" << "specialchar.d" << "specialchar.d.expected"; +} + +void tst_rcc::depFileGeneration() +{ + QFETCH(QString, qrcfile); + QFETCH(QString, depfile); + QFETCH(QString, expected); + const QString directory = m_dataPath + QLatin1String("/depfile"); + + QProcess process; + process.setWorkingDirectory(directory); + process.start(m_rcc, { "-d", depfile, "-o", qrcfile + ".cpp", qrcfile }); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); + if (!process.waitForFinished()) { + process.kill(); + QFAIL(msgProcessTimeout(process).constData()); + } + QVERIFY2(process.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(process).constData()); + QVERIFY2(process.exitCode() == 0, + msgProcessFailed(process).constData()); + + QFile depFileOutput(directory + QLatin1String("/") + depfile); + QVERIFY(depFileOutput.open(QIODevice::ReadOnly | QIODevice::Text)); + QByteArray depFileData = depFileOutput.readAll(); + depFileOutput.close(); + + QFile depFileExpected(directory + QLatin1String("/") + expected); + QVERIFY(depFileExpected.open(QIODevice::ReadOnly | QIODevice::Text)); + QByteArray expectedData = depFileExpected.readAll(); + depFileExpected.close(); + + QCOMPARE(depFileData, expectedData); +} + void tst_rcc::python() { const QString path = m_dataPath + QLatin1String("/sizes"); @@ -450,6 +496,8 @@ void tst_rcc::cleanupTestCase() { QDir dataDir(m_dataPath + QLatin1String("/binary")); QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc")); + QDir dataDepDir(m_dataPath + QLatin1String("/depfile")); + entries += dataDepDir.entryInfoList({QLatin1String("*.d"), QLatin1String("*.qrc.cpp")}); foreach (const QFileInfo &entry, entries) QFile::remove(entry.absoluteFilePath()); } -- cgit v1.2.3