aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Cotty <raphael.cotty@gmail.com>2022-02-03 07:45:29 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2024-05-03 08:53:30 +0000
commitedeb8e35ea22a98f2071e130619136dc1721755f (patch)
tree8db035ac0dd44f7207d2995583659f57f44613cc
parentc5b4b975cdb0c54b9a6824f9a88807df6051f298 (diff)
Use BinaryProbe in the pkgconfig provider
This allows to re-use the code in the Probe rather than iterate over PATHS manually Change-Id: Ibc6da2b141329033ad1c3fc0f9f22a8170df74b3 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--doc/reference/module-providers/qbspkgconfig-module-provider.qdoc11
-rw-r--r--share/qbs/imports/qbs/Probes/qbs-pkg-config-probe.js26
-rw-r--r--share/qbs/imports/qbs/Probes/qmake-probe.js2
-rw-r--r--share/qbs/module-providers/qbspkgconfig.qbs10
4 files changed, 23 insertions, 26 deletions
diff --git a/doc/reference/module-providers/qbspkgconfig-module-provider.qdoc b/doc/reference/module-providers/qbspkgconfig-module-provider.qdoc
index b5d720d01..a7f6fe6b7 100644
--- a/doc/reference/module-providers/qbspkgconfig-module-provider.qdoc
+++ b/doc/reference/module-providers/qbspkgconfig-module-provider.qdoc
@@ -99,6 +99,17 @@
*/
/*!
+ \qmlproperty stringList qbspkgconfig::executableNames
+
+ The names of the \c pkg-config executable to search for.
+
+ Note that since newer distributions use \l{http://pkgconf.org}{pkgconf} by default, it has
+ higher priority over \c pkg-config.
+
+ \defaultvalue \c{["pkgconf", "pkg-config"]}
+*/
+
+/*!
\qmlproperty path qbspkgconfig::sysroot
Set this property if you need to overwrite the default search sysroot path used by
diff --git a/share/qbs/imports/qbs/Probes/qbs-pkg-config-probe.js b/share/qbs/imports/qbs/Probes/qbs-pkg-config-probe.js
index 3978ac4b6..d382dfb02 100644
--- a/share/qbs/imports/qbs/Probes/qbs-pkg-config-probe.js
+++ b/share/qbs/imports/qbs/Probes/qbs-pkg-config-probe.js
@@ -35,25 +35,6 @@ var PkgConfig = require("qbs.PkgConfig");
var ProviderUtils = require("qbs.ProviderUtils");
var Process = require("qbs.Process");
-// We should probably use BinaryProbe instead in the provider
-function getPkgConfigExecutable() {
- function splitNonEmpty(s, c) { return s.split(c).filter(function(e) { return e; }) }
-
- var pathValue = Environment.getEnv("PATH");
- if (!pathValue)
- return undefined;
- var dirs = splitNonEmpty(pathValue, FileInfo.pathListSeparator());
- for (var i = 0; i < dirs.length; ++i) {
- var candidate =
- FileInfo.joinPaths(dirs[i], "pkg-config" + FileInfo.executableSuffix());
- var canonicalCandidate = FileInfo.canonicalPath(candidate);
- if (!canonicalCandidate || !File.exists(canonicalCandidate))
- continue;
- return canonicalCandidate;
- }
- return undefined;
-}
-
function getQmakePaths(pkg) {
var packageName = pkg.baseFileName;
if (packageName === "QtCore"
@@ -104,13 +85,12 @@ function configure(
if (!options.libDirs) {
// if we have pkg-config/pkgconf installed, let's ask it for its search paths (since
// built-in search paths can differ between platforms)
- var executable = executableFilePath ? executableFilePath : getPkgConfigExecutable();
- if (executable) {
+ if (executableFilePath) {
var p = new Process()
- if (p.exec(executable, ['pkg-config', '--variable=pc_path']) === 0) {
+ if (p.exec(executableFilePath, ['pkg-config', '--variable=pc_path']) === 0) {
var stdout = p.readStdOut().trim();
options.libDirs = stdout ? stdout.split(FileInfo.pathListSeparator()): [];
- var installDir = FileInfo.path(executable);
+ var installDir = FileInfo.path(executableFilePath);
options.libDirs = options.libDirs.map(function(path){
if (FileInfo.isAbsolutePath(path))
return path;
diff --git a/share/qbs/imports/qbs/Probes/qmake-probe.js b/share/qbs/imports/qbs/Probes/qmake-probe.js
index ad0cb3fa7..6ddbd48ba 100644
--- a/share/qbs/imports/qbs/Probes/qmake-probe.js
+++ b/share/qbs/imports/qbs/Probes/qmake-probe.js
@@ -72,7 +72,7 @@ function getQmakeFilePaths(qmakeFilePaths) {
if (filePaths.length === 0) {
console.warn("Could not find any qmake executables in PATH. Either make sure a qmake "
+ "executable is present in PATH or set the moduleProviders.Qt.qmakeFilePaths property "
- + "to point a qmake executable.");
+ + "to point to a qmake executable.");
}
return filePaths;
}
diff --git a/share/qbs/module-providers/qbspkgconfig.qbs b/share/qbs/module-providers/qbspkgconfig.qbs
index 5e027788e..0ff58b5d5 100644
--- a/share/qbs/module-providers/qbspkgconfig.qbs
+++ b/share/qbs/module-providers/qbspkgconfig.qbs
@@ -51,7 +51,8 @@ import qbs.TextFile
import "Qt/setup-qt.js" as SetupQt
ModuleProvider {
- property string executableFilePath
+ property stringList executableNames: ["pkgconf", "pkg-config"]
+ property string executableFilePath: pkgConfigProbe.filePath
property stringList extraPaths
property stringList libDirs
property bool staticMode: false
@@ -62,6 +63,12 @@ ModuleProvider {
property path sysroot: qbs.toolchain && qbs.toolchain.includes("xcode")
? undefined : qbs.sysroot
+ Probes.BinaryProbe {
+ id: pkgConfigProbe
+ condition: !executableFilePath
+ names: executableNames
+ }
+
Probes.QbsPkgConfigProbe {
id: theProbe
// TODO: without explicit 'parent' we do not have access to the fake "qbs" scope
@@ -143,7 +150,6 @@ ModuleProvider {
var outputDir = FileInfo.joinPaths(outputBaseDir, "modules");
File.makePath(outputDir);
- // TODO: ponder how we can solve forward mapping with Packages so we can fill deps
var moduleMapping = {
"protobuf": "protobuflib"
}