diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2016-08-04 15:19:10 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2016-08-05 09:32:27 +0000 |
commit | fabfd53ea5e103b85e93b133cf0896dd6499d4e1 (patch) | |
tree | 923ddd38986fa89d3a8b3c87e9849c41e0cab5dc | |
parent | ccf7ae9c7c0e09ee68eaddb27f96ddcea2972cc2 (diff) |
Fix PkgConfigProbe for multi-profile projects
Our assumption in qbscore (for probe caching) is that two runs of a
probe will yield the same result for the same set of input properties.
Make the PkgConfigProbe satisfy this requirement by making the value of
qbs.sysroot an input property.
Change-Id: I4ebf8a3c3d9c02c261e3a128e48e232adb656b94
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
7 files changed, 98 insertions, 4 deletions
diff --git a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs index 68b9bd891..5b738fec1 100644 --- a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs +++ b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs @@ -34,6 +34,7 @@ import qbs.FileInfo Probe { // Inputs + property string sysroot: qbs.sysroot property string executable: 'pkg-config' property string name property string minVersion @@ -59,12 +60,12 @@ Probe { if (maxVersion !== undefined) args.push(name + ' <= ' + maxVersion); var libDirsToSet = libDirs; - if (qbs.sysroot) { - p.setEnv("PKG_CONFIG_SYSROOT_DIR", qbs.sysroot); + if (sysroot) { + p.setEnv("PKG_CONFIG_SYSROOT_DIR", sysroot); if (!libDirsToSet) { libDirsToSet = [ - qbs.sysroot + "/usr/lib/pkgconfig", - qbs.sysroot + "/usr/share/pkgconfig" + sysroot + "/usr/lib/pkgconfig", + sysroot + "/usr/share/pkgconfig" ]; } } diff --git a/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/modules/themodule/themodule.qbs b/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/modules/themodule/themodule.qbs new file mode 100644 index 000000000..fbacf8464 --- /dev/null +++ b/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/modules/themodule/themodule.qbs @@ -0,0 +1,28 @@ +import qbs +import qbs.Probes + +Module { + Probes.PkgConfigProbe { + id: theProbe + name: "dummy" + } + + property stringList libs: theProbe.libs + + Rule { + multiplex: true + Artifact { + filePath: "dummy.out" + fileTags: ["theType"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.sourceCode = function() { + console.info(product.name + " libs: " + + JSON.stringify(product.moduleProperty("themodule", "libs"))); + } + return [cmd]; + } + } +} diff --git a/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/pkg-config.qbs b/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/pkg-config.qbs new file mode 100644 index 000000000..0eac3cca0 --- /dev/null +++ b/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/pkg-config.qbs @@ -0,0 +1,29 @@ +import qbs + +Project { + property string packageBaseName + + Product { + name: "theProduct1" + type: ["theType"] + + Depends { name: "themodule" } + qbs.sysroot: path + "/sysroot1" + } + + Product { + name: "theProduct2" + type: ["theType"] + + Depends { name: "themodule" } + qbs.sysroot: path + "/sysroot2" + } + + Product { + name: "theProduct3" + type: ["theType"] + + Depends { name: "themodule" } + qbs.sysroot: path + "/sysroot1" + } +} diff --git a/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/sysroot1/usr/share/pkgconfig/dummy.pc b/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/sysroot1/usr/share/pkgconfig/dummy.pc new file mode 100644 index 000000000..9e89e44bd --- /dev/null +++ b/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/sysroot1/usr/share/pkgconfig/dummy.pc @@ -0,0 +1,7 @@ +Name: dummy1 +Description: dummy1 package +Version: 0.0.1 + +Requires: +Libs: -L/usr/dummy -ldummy1 +Cflags: diff --git a/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/sysroot2/usr/share/pkgconfig/dummy.pc b/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/sysroot2/usr/share/pkgconfig/dummy.pc new file mode 100644 index 000000000..9e89e44bd --- /dev/null +++ b/tests/auto/blackbox/testdata/pkg-config-probe-sysroot/sysroot2/usr/share/pkgconfig/dummy.pc @@ -0,0 +1,7 @@ +Name: dummy1 +Description: dummy1 package +Version: 0.0.1 + +Requires: +Libs: -L/usr/dummy -ldummy1 +Cflags: diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 6ed5564d2..d716fdd78 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1932,6 +1932,27 @@ void TestBlackbox::pkgConfigProbe_data() << (QStringList() << "[]" << "[]") << (QStringList() << "undefined" << "undefined"); } +void TestBlackbox::pkgConfigProbeSysroot() +{ + const QString exe = findExecutable(QStringList() << "pkg-config"); + if (exe.isEmpty()) + QSKIP("This test requires the pkg-config tool"); + + QDir::setCurrent(testDataDir + "/pkg-config-probe-sysroot"); + QCOMPARE(runQbs(), 0); + QCOMPARE(m_qbsStdout.count("PkgConfigProbe: found library"), 2); + const QString outputTemplate = "theProduct%1 libs: [\"-L%2/usr/dummy\",\"-ldummy1\"]"; + QVERIFY2(m_qbsStdout.contains(outputTemplate + .arg("1", QDir::currentPath() + "/sysroot1").toLocal8Bit()), + m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains(outputTemplate + .arg("2", QDir::currentPath() + "/sysroot2").toLocal8Bit()), + m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains(outputTemplate + .arg("3", QDir::currentPath() + "/sysroot1").toLocal8Bit()), + m_qbsStdout.constData()); +} + void TestBlackbox::probeChangeTracking() { QDir::setCurrent(testDataDir + "/probe-change-tracking"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 2401b1c62..adb8e5bcb 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -181,6 +181,7 @@ private slots: void pchChangeTracking(); void pkgConfigProbe(); void pkgConfigProbe_data(); + void pkgConfigProbeSysroot(); void probeChangeTracking(); void probeProperties(); void probeInExportedModule(); |