[swift-users] System Modules and pkgConfig

Etan Kissling etan at scriptreactor.com
Thu Dec 29 02:40:09 CST 2016


Wow, that works :-) Updated the repo.

However, when the system module is missing, I still get "header not found" errors instead of the suggestion of installing the package via brew.

BTW: It may be nice if you could update your blog post to get rid of the absolute path in the modulemap as well:
http://ankit.im/swift/2016/03/26/improving-system-modules-support-in-swiftpm/
It's one of few examples about this topic that's easily found using search engines, and not having to deal with absolute paths inside the system module package definition is the main advantage of the pkgConfig feature.

Thanks a lot

Etan


> On 29 Dec 2016, at 06:25, Ankit Aggarwal <ankit_aggarwal at apple.com> wrote:
> 
> In tls+Swift.h, you already have included the tls.h so you shouldn't need to specify this line `header "/usr/local/opt/libressl/include/tls.h"` at all in the modulemap.
> 
>> On 29-Dec-2016, at 1:18 AM, Etan Kissling via swift-users <swift-users at swift.org> wrote:
>> 
>> Addition:
>> 
>> Example system module as I have it now:
>> https://github.com/Scriptreactor/SwiftCTLS
>> 
>> I'd like to get rid of the absolute path in the module.modulemap's "header" directive and have it instead use pkgConfig values.
>> 
>> 
>> 
>>> On 28 Dec 2016, at 17:12, Etan Kissling via swift-users <swift-users at swift.org> wrote:
>>> 
>>> Hi,
>>> 
>>> before Swift 3, for System Modules to work, these steps were necessary:
>>> 1. Creating module map
>>> 2. Creating System Module package
>>> 3. Creating git repo for System Module package, tagging with version
>>> 4. Referencing the System Module package from main package
>>> 5. Adding -Xcc -I and -Xlinker -L flags to the swift build command.
>>> 
>>> The problem here is, that absolute system-depending paths are required at:
>>> - module map "header" entry.
>>> - Xcc -I flag when building.
>>> - Xlinker -L flag when building.
>>> 
>>> To solve this, Swift 3 introduced support for System Module search paths:
>>> https://github.com/apple/swift-evolution/blob/master/proposals/0063-swiftpm-system-module-search-paths.md
>>> 
>>> In my case, I end up with the following for the System Module package:
>>> 
>>> module CFoo [system] {
>>> header "/system/depending/path/to/my/header.h"
>>> link "foo"
>>> export *
>>> }
>>> 
>>> 
>>> import PackageDescription
>>> 
>>> let package = Package(
>>>  name: "CFoo",
>>>  pkgConfig: "foo",
>>>  providers: [
>>>      .Brew("foo")
>>>  ]
>>> )
>>> 
>>> 
>>> With this setup, I can run
>>> PKG_CONFIG_PATH=/system/depending/path/to/my/pc/file swift build
>>> and build the project without specifying custom Xcc -I / Xlinker -L flags.
>>> 
>>> However, the absolute system-depending path is still required in the modulemap.
>>> 
>>> When I change the module map to
>>> 
>>> module CFoo [system] {
>>> header "header.h"
>>> link "foo"
>>> export *
>>> }
>>> 
>>> , I get build errors like
>>> 
>>> /module.modulemap:2:##: error: header 'header.h' not found
>>> 
>>> This is kind of different than what is suggested by the proposal (that it should recommend installing via Brew / Apt in that case).
>>> 
>>> 
>>> ==> How do I need to set up the project so that system-depending paths are required at no point?
>>> ==> Is there an example project available on github that demonstrates the pkgConfig feature of SwiftPM?
>>> 
>>> 
>>> Thanks
>>> 
>>> Etan
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> swift-users mailing list
>>> swift-users at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-users
>> 
>> _______________________________________________
>> swift-users mailing list
>> swift-users at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
> 



More information about the swift-users mailing list