[swift-users] how to ``swift build`` C library cleanly without using -Xcc -Xlinker and -Xswiftc
Daniel Dunbar
daniel_dunbar at apple.com
Thu Oct 20 10:34:21 CDT 2016
> On Oct 20, 2016, at 7:25 AM, Martin Man via swift-users <swift-users at swift.org> wrote:
>
> Hi guys,
>
> I’m wrapping three little native C libraries using SPM to a nice swifty modules. Say cmod1, cmod2, and cmod3. They all in the and are dependencies of a bigger project.
>
> Since these legacy C libraries have headers in various ways incompatible with SPM I’m also providing my own custom module.modulemap inside of Sources/cmod1/include folder which exports only certain headers.
>
> The module.modulemap is in pretty standard form with relative path to the header
>
> module cmod1 {
> header “cmod1/header1.h”
> export “*”
> link “cmod1"
> }
>
> When using ``swift build`` to build the module, C sources compile fine but switc bails out when parsing modulemap because it can not find headers referenced from header1.h with an error message like this
>
> <module-includes>:1:10: note: in file included from <module-includes>:1:
> #include “/projects/something/Sources/cmod1/include/cmod/header1.h"
Is this misspelled? cmod/header1.h vs cmod1/header1.h?
Can you show the exact include style used in the module.modulemap and in the project?
> ^
> /projects/something/Sources/cmod1/include/cmod1/header1.h:18:10: error: ‘cmod1/header2.h' file not found
>
> Now I know that I can give swiftc correct -Xswiftc -Ipath switch and then it builds cleanly, but this means that plain ``swift build`` never succeeds…
>
> Q1: Is my assumption correct that the ultimate goal of mine is to make the swift package build cleanly using just ``swift build`` without providing any commandline flags?
Yes.
> Q2: When build of a certain package cmod1 requires command line flags -Xcc -Xlinker and -Xswiftc, what’s the correct way to pass them in when such package is a dependency of bigger project and which gets git pulled and compiled as part of outer package build?
We don't have a solution for this yet, eventually we want to find a way that all that data has a proper home in the manifest.
- Daniel
>
> thanks for your time, unfortunately the sources of these packages can not be made public yet but I think I can generate a simple broken project on github if anyone wants to take a look...
>
> thanks,
> Martin
>
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161020/dd5e9f8d/attachment.html>
More information about the swift-users
mailing list