diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2021-10-10 16:08:29 +0300 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2021-10-25 12:26:51 +0000 |
commit | 0b19a266963a91b1eaa17ed5c835b662a8d29135 (patch) | |
tree | 5ee40ad071b4eecde9f1207a270048435b435f2f /tests/auto | |
parent | bf8d0f9710d507b047e73cb8da60b1c25ffee1ec (diff) | |
download | qbs-0b19a266963a91b1eaa17ed5c835b662a8d29135.tar.gz |
pkgconfig: Implement early dependency merging
Due to performance reasons, we have to do the dependency resolution
on the qbspkg-config side, like original pkg-config does.
Otherwise, it is not possible to use GRPC module as it depends on a
bunch of ABSEIL libraries which has a lot of cross-dependencies and
QBS cannot handle them (resolving takes > 10 minutes for a simple
dependency on GRPC).
Change-Id: Ice25f6cea09fe731a511d91891936ba746e5b697
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/pkgconfig/testdata/private-dep.pc | 6 | ||||
-rw-r--r-- | tests/auto/pkgconfig/testdata/public-dep.pc | 6 | ||||
-rw-r--r-- | tests/auto/pkgconfig/testdata/requires-test-merged-static.json | 22 | ||||
-rw-r--r-- | tests/auto/pkgconfig/testdata/requires-test-merged.json | 19 | ||||
-rw-r--r-- | tests/auto/pkgconfig/tst_pkgconfig.cpp | 58 |
5 files changed, 95 insertions, 16 deletions
diff --git a/tests/auto/pkgconfig/testdata/private-dep.pc b/tests/auto/pkgconfig/testdata/private-dep.pc new file mode 100644 index 000000000..cb401391d --- /dev/null +++ b/tests/auto/pkgconfig/testdata/private-dep.pc @@ -0,0 +1,6 @@ +Name: Requires test package +Description: Dummy pkgconfig test package for testing Requires/Requires.private +Version: 1.0.0 +Libs: -L/private-dep/lib -lprivate-dep +Cflags: -I/private-dep/include + diff --git a/tests/auto/pkgconfig/testdata/public-dep.pc b/tests/auto/pkgconfig/testdata/public-dep.pc new file mode 100644 index 000000000..e450e46f1 --- /dev/null +++ b/tests/auto/pkgconfig/testdata/public-dep.pc @@ -0,0 +1,6 @@ +Name: Requires test package +Description: Dummy pkgconfig test package for testing Requires/Requires.private +Version: 1.0.0 +Requires.private: +Libs: -L/public-dep/lib -lpublic-dep +Cflags: -I/public-dep/include diff --git a/tests/auto/pkgconfig/testdata/requires-test-merged-static.json b/tests/auto/pkgconfig/testdata/requires-test-merged-static.json new file mode 100644 index 000000000..2c43b2d40 --- /dev/null +++ b/tests/auto/pkgconfig/testdata/requires-test-merged-static.json @@ -0,0 +1,22 @@ +{ + "Name": "Requires test package", + "Description": "Dummy pkgconfig test package for testing Requires/Requires.private", + "Version": "1.0.0", + "Libs": [ + {"Type": "LibraryPath", "Value": "/public-dep/lib"}, + {"Type": "LibraryName", "Value": "public-dep"}, + {"Type": "LibraryPath", "Value": "/private-dep/lib"}, + {"Type": "LibraryName", "Value": "private-dep"}, + {"Type": "LibraryPath", "Value": "/requires-test/lib"}, + {"Type": "LibraryName", "Value": "requires-test"} + ], + "Cflags": [ + {"Type": "IncludePath", "Value": "/public-dep/include"}, + {"Type": "IncludePath", "Value": "/private-dep/include"}, + {"Type": "IncludePath", "Value": "/requires-test/include"} + ], + "Requires": [ + ], + "RequiresPrivate": [ + ] +} diff --git a/tests/auto/pkgconfig/testdata/requires-test-merged.json b/tests/auto/pkgconfig/testdata/requires-test-merged.json new file mode 100644 index 000000000..88114ba30 --- /dev/null +++ b/tests/auto/pkgconfig/testdata/requires-test-merged.json @@ -0,0 +1,19 @@ +{ + "Name": "Requires test package", + "Description": "Dummy pkgconfig test package for testing Requires/Requires.private", + "Version": "1.0.0", + "Libs": [ + {"Type": "LibraryPath", "Value": "/public-dep/lib"}, + {"Type": "LibraryName", "Value": "public-dep"}, + {"Type": "LibraryPath", "Value": "/requires-test/lib"}, + {"Type": "LibraryName", "Value": "requires-test"} + ], + "Cflags": [ + {"Type": "IncludePath", "Value": "/public-dep/include"}, + {"Type": "IncludePath", "Value": "/requires-test/include"} + ], + "Requires": [ + ], + "RequiresPrivate": [ + ] +} diff --git a/tests/auto/pkgconfig/tst_pkgconfig.cpp b/tests/auto/pkgconfig/tst_pkgconfig.cpp index 96a70d199..1b04d231b 100644 --- a/tests/auto/pkgconfig/tst_pkgconfig.cpp +++ b/tests/auto/pkgconfig/tst_pkgconfig.cpp @@ -60,24 +60,32 @@ void TestPkgConfig::initTestCase() void TestPkgConfig::pkgConfig() { - QFETCH(QString, fileName); + QFETCH(QString, pcFileName); + QFETCH(QString, jsonFileName); QFETCH(QVariantMap, optionsMap); - Options options = qbs::Internal::PkgConfigJs::convertOptions(QProcessEnvironment::systemEnvironment(), optionsMap); + if (jsonFileName.isEmpty()) + jsonFileName = pcFileName; + + if (!optionsMap.contains("mergeDependencies")) + optionsMap["mergeDependencies"] = false; + + Options options = qbs::Internal::PkgConfigJs::convertOptions( + QProcessEnvironment::systemEnvironment(), optionsMap); options.searchPaths.push_back(m_workingDataDir.toStdString()); PkgConfig pkgConfig(std::move(options)); - QFile jsonFile(m_workingDataDir + "/" + fileName + ".json"); + QFile jsonFile(m_workingDataDir + "/" + jsonFileName + ".json"); QVERIFY(jsonFile.open(QIODevice::ReadOnly)); QJsonParseError error{}; const auto json = QJsonDocument::fromJson(jsonFile.readAll(), &error).toVariant().toMap(); QCOMPARE(error.error, QJsonParseError::NoError); - const auto &packageOr = pkgConfig.getPackage(fileName.toStdString()); + const auto &packageOr = pkgConfig.getPackage(pcFileName.toStdString()); QVERIFY(packageOr.isValid()); const auto &package = packageOr.asPackage(); - QCOMPARE(QString::fromStdString(package.baseFileName), fileName); + QCOMPARE(QString::fromStdString(package.baseFileName), pcFileName); QCOMPARE(QString::fromStdString(package.name), json.value("Name").toString()); QCOMPARE(QString::fromStdString(package.description), json.value("Description").toString()); QCOMPARE(QString::fromStdString(package.version), json.value("Version").toString()); @@ -155,20 +163,38 @@ void TestPkgConfig::pkgConfig() void TestPkgConfig::pkgConfig_data() { - QTest::addColumn<QString>("fileName"); + QTest::addColumn<QString>("pcFileName"); + QTest::addColumn<QString>("jsonFileName"); QTest::addColumn<QVariantMap>("optionsMap"); - QTest::newRow("non-l-required") << QStringLiteral("non-l-required") << QVariantMap(); - QTest::newRow("simple") << QStringLiteral("simple") << QVariantMap(); - QTest::newRow("requires-test") << QStringLiteral("requires-test") << QVariantMap(); - QTest::newRow("special-flags") << QStringLiteral("special-flags") << QVariantMap(); - QTest::newRow("system") << QStringLiteral("system") << QVariantMap(); + QTest::newRow("non-l-required") + << QStringLiteral("non-l-required") << QString() << QVariantMap(); + QTest::newRow("simple") + << QStringLiteral("simple") << QString() << QVariantMap(); + QTest::newRow("requires-test") + << QStringLiteral("requires-test") << QString() << QVariantMap(); + QTest::newRow("requires-test-merged") + << QStringLiteral("requires-test") + << QStringLiteral("requires-test-merged") + << QVariantMap({{"mergeDependencies", true}}); + QTest::newRow("requires-test-merged-static") + << QStringLiteral("requires-test") + << QStringLiteral("requires-test-merged-static") + << QVariantMap({{"mergeDependencies", true}, {"staticMode", true}}); + QTest::newRow("special-flags") + << QStringLiteral("special-flags") << QString() << QVariantMap(); + QTest::newRow("system") + << QStringLiteral("system") << QString() << QVariantMap(); QTest::newRow("sysroot") - << QStringLiteral("sysroot") << QVariantMap({{"sysroot", "/newroot"}}); - QTest::newRow("tilde") << QStringLiteral("tilde") << QVariantMap(); - QTest::newRow("variables") << QStringLiteral("variables") << QVariantMap(); - QTest::newRow("whitespace") << QStringLiteral("whitespace") << QVariantMap(); - QTest::newRow("base.name") << QStringLiteral("base.name") << QVariantMap(); + << QStringLiteral("sysroot") << QString() << QVariantMap({{"sysroot", "/newroot"}}); + QTest::newRow("tilde") + << QStringLiteral("tilde") << QString() << QVariantMap(); + QTest::newRow("variables") + << QStringLiteral("variables") << QString() << QVariantMap(); + QTest::newRow("whitespace") + << QStringLiteral("whitespace") << QString() << QVariantMap(); + QTest::newRow("base.name") + << QStringLiteral("base.name") << QString() << QVariantMap(); } void TestPkgConfig::benchSystem() |