Re: [swift-corelibs-dev] NSURLSession & libcurl
> On 14 Mar 2016, at 18:29, Robert Stephen Thompson > wrote: > > Just a couple of tips based on my experience wrapping libxml2 for > NSXMLDocument: > 1. You’ll need to actually import and link libcurl with CoreFoundation > instead of trying to make a libcurl module.modulemap and importing it > directly. This is because if you do it that way, you’ll have to add libcurl > as a dependency _throughout_ the Swift build process, and it would all be > pretty disruptive (and difficult to do). > 2. As a consequence of 1., you’ll need to wrap every function you call from > libcurl in a new CoreFoundation API. See CFXMLInterface.h and > CFXMLInterface.c for what I mean. Of course, this also gives you the > opportunity to add nullability annotations, wrap things in CFString, CFError, > CFArray, etc, so it’s not just busy-work for getting around the build system, > heh. Just depends on how much C you want to write, you could just straight > wrap the libcurl functions and do everything in Swift, but at the very least > nullability annotations are a win here. I just looked at this, and libxml2 is being linked against by SwiftFoundation, and NOT by CoreFoundation -- on Darwin. Is the correct approach to do what's been done with libxml2, or should I instead have CoreFoundation link against libcurl? /Daniel ___ swift-corelibs-dev mailing list swift-corelibs-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
Re: [swift-corelibs-dev] NSURLSession & libcurl
The swift-corelibs-foundation version of CF is a static library that is being built into the Foundation product dynamic library so the linkage for libxml2 and anything else should be on that. The layout of how linking works for the Darwin version is different because of how we split the layers. NSXMLParser is based on libxml2 in objc. It just does not need a CF abstraction/thunks to convert types. Sent from my iPhone > On Mar 23, 2016, at 4:07 AM, Daniel Eggert via swift-corelibs-dev > wrote: > > >> On 14 Mar 2016, at 18:29, Robert Stephen Thompson >> wrote: >> >> Just a couple of tips based on my experience wrapping libxml2 for >> NSXMLDocument: >> 1. You’ll need to actually import and link libcurl with CoreFoundation >> instead of trying to make a libcurl module.modulemap and importing it >> directly. This is because if you do it that way, you’ll have to add libcurl >> as a dependency _throughout_ the Swift build process, and it would all be >> pretty disruptive (and difficult to do). >> 2. As a consequence of 1., you’ll need to wrap every function you call from >> libcurl in a new CoreFoundation API. See CFXMLInterface.h and >> CFXMLInterface.c for what I mean. Of course, this also gives you the >> opportunity to add nullability annotations, wrap things in CFString, >> CFError, CFArray, etc, so it’s not just busy-work for getting around the >> build system, heh. Just depends on how much C you want to write, you could >> just straight wrap the libcurl functions and do everything in Swift, but at >> the very least nullability annotations are a win here. > > > I just looked at this, and libxml2 is being linked against by > SwiftFoundation, and NOT by CoreFoundation -- on Darwin. > > Is the correct approach to do what's been done with libxml2, or should I > instead have CoreFoundation link against libcurl? > > /Daniel > > ___ > swift-corelibs-dev mailing list > swift-corelibs-dev@swift.org > https://lists.swift.org/mailman/listinfo/swift-corelibs-dev ___ swift-corelibs-dev mailing list swift-corelibs-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
Re: [swift-corelibs-dev] NSURLSession & libcurl
> On 23 Mar 2016, at 14:44, Philippe Hausler wrote: > > The swift-corelibs-foundation version of CF is a static library that is being > built into the Foundation product dynamic library so the linkage for libxml2 > and anything else should be on that. > > The layout of how linking works for the Darwin version is different because > of how we split the layers. NSXMLParser is based on libxml2 in objc. It just > does not need a CF abstraction/thunks to convert types. Looking at the swift-corelibs-foundation Xcode project, the "Link Binary With Libraries" is empty for the CoreFoundation target, while it contains libxml2 for the SwiftFoundation target. I'd do the same for libcurl. /Daniel ___ swift-corelibs-dev mailing list swift-corelibs-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
Re: [swift-corelibs-dev] NSURLSession & libcurl
I've created this pull request in an attempt to get more feedback on my approach. I hope this is in line with the contribution guidelines. https://github.com/apple/swift-corelibs-foundation/pull/299 This is will work-in-progress and marked as such. /Daniel ___ swift-corelibs-dev mailing list swift-corelibs-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-corelibs-dev