diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2021-05-22 14:45:25 +0200 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2021-09-23 11:32:23 +0000 |
commit | e87dd50dd5a74d0ddc8f9753a67a0a2500947e5f (patch) | |
tree | cd3085b0a6f5e8ec08b14ff166210e632e6b2a32 /src/lib/pkgconfig/pkgconfig.qbs | |
parent | 91e0274d265a8ce7070c3d039700341b8d31cf5c (diff) |
Long live qbs-pkgconfig!
This patchset introduce a static library for parsing .pc files. Code is
based on the original pkg-config source code https://
gitlab.freedesktop.org/pkg-config/pkg-config and is written in pure C++
(except for the places where we need access to filesystem as
std::filesystem is not available for all platforms - in that case, Qt
classes are used)
Parsing .pc files manually allows to have more control over dependencies
between modules, e.g. to generate a standalone module per one .pc file
and merge properties using Qbs itself, not via pkg-config.
Library is almost feature-complete and all tests copied from pkg-config
pass. Some functionality is omitted (e.g. prefix variables (what is
this?) or validating dependencies since Qbs does this as well)
Bechmark shows that parsing ~100 files takes about 10-15ms. Running
pkg-config on the same set of files takes ~4 seconds:
RESULT : TestPkgConfig::benchSystem():
14 msecs per iteration (total: 57, iterations: 4)
Fixes: QBS-1615
Change-Id: I5bfdfa588aa04d9d69fd738dd2beea14174c0242
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/pkgconfig/pkgconfig.qbs')
-rw-r--r-- | src/lib/pkgconfig/pkgconfig.qbs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/lib/pkgconfig/pkgconfig.qbs b/src/lib/pkgconfig/pkgconfig.qbs new file mode 100644 index 000000000..25bcb3fdf --- /dev/null +++ b/src/lib/pkgconfig/pkgconfig.qbs @@ -0,0 +1,61 @@ +import qbs.FileInfo +import qbs.Utilities + +QbsStaticLibrary { + Depends { name: "cpp" } + Depends { name: "qbsbuildconfig" } + + property stringList pcPaths: { + var result = []; + result.push(FileInfo.joinPaths(qbs.installPrefix, qbsbuildconfig.libDirName, "pkgconfig")); + result.push(FileInfo.joinPaths(qbs.installPrefix, "share", "pkgconfig")); + if (qbs.hostOS.contains("unix")) { + result.push("/usr/lib/pkgconfig/") + result.push("/usr/share/pkgconfig/") + } + return result + } + readonly property stringList pcPathsString: pcPaths.join(qbs.pathListSeparator) + + property bool withQtSupport: true + + readonly property stringList publicDefines: { + var result = []; + if (withQtSupport) + result.push("QBS_PC_WITH_QT_SUPPORT=1") + else + result.push("QBS_PC_WITH_QT_SUPPORT=0") + return result; + } + + name: "qbspkgconfig" + + files: [ + "pcpackage.cpp", + "pcpackage.h", + "pcparser.cpp", + "pcparser.h", + "pkgconfig.cpp", + "pkgconfig.h", + ] + + cpp.defines: { + var result = [ + "PKG_CONFIG_PC_PATH=\"" + pcPathsString + "\"", + "PKG_CONFIG_SYSTEM_LIBRARY_PATH=\"/usr/" + qbsbuildconfig.libDirName + "\"", + ] + if ((qbs.targetOS.contains("darwin") + && Utilities.versionCompare(cpp.minimumMacosVersion, "10.15") < 0) + || qbs.toolchain.contains("mingw")) + result.push("HAS_STD_FILESYSTEM=0") + else + result.push("HAS_STD_FILESYSTEM=1") + result = result.concat(publicDefines); + return result + } + + Export { + Depends { name: "cpp" } + cpp.defines: exportingProduct.publicDefines + } +} |