System library target - pkg-config argument format


TL;DR What is the correct format of pkgConfig String argument when creating Target.systemLibray? Is it allowed to pass more then one package at a time?

Full story:
I'm currently working on improving rhx's implementation of Swift wrapper around GTK. There are a lot of things I want to achieve to make the library as easy to use as possible.

The issue I am currently focused on is having the ability to build a project with simple swift build command (assuming wrapper was already generated). I hope this should improve experience with Sourcekit which is imo essential for comfortable development in Swift.
I've started with package. This package should wrap GLib for Swift. However, in order to build the project, provided script calls swift build with c++ and linker arguments. For my system, those arguments are generated as follows:
swift build --build-path /home/mikolas/Developer/SwiftGLib/.build -Xcc -pthread -Xcc -I/usr/include/gio-unix-2.0 -Xcc -I/usr/include/libmount -Xcc -I/usr/include/blkid -Xcc -I/usr/include/glib-2.0 -Xcc -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Xlinker -lgio-2.0 -Xlinker -lgobject-2.0 -Xlinker -lglib-2.0

Using this command results in successful build. However I've the noticed, that those exact paths and linker commands should be emitted already, since glib-2.0 and gio-unix-2.0 are passed as a argument to the target via pkgConfig argument in the Package.swift.

My first naive attempt to solve the issue by removing one of the packages (that being glib-2.0) resulted in successful clean build (assuming generated code was still present) using nothing more than swift build.

Therefore I am wondering, is it required to have only one package passed to the pkgConfig at the time? Is it a bug? What is the correct format if more than one package could be passed to a pkgConfig argument? ... :thinking:

I've done some research into this and found this documentation in the SPM repo

Is it correct to assume that multiple package names do not work because SPM searches for *.po file which contains name of all listed packages? Are there any workarounds?

Terms of Service

Privacy Policy

Cookie Policy