<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 29-Mar-2017, at 11:22 AM, <a href="mailto:kelvinsthirteen@gmail.com" class="">kelvinsthirteen@gmail.com</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">I figured that was the intention, but we can’t be too surprised that everyone is maintaining personal modulemap repositories (and polluting search results — just try googling for a Swift PNG library!), especially when this central repo still doesn’t exist yet.</div></div></div></blockquote><div><br class=""></div><div>Yeah thats unfortunate, maybe this will improve once we have an index.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class="">If Swift ever comes on par with C in terms of being usage and the lingua franca of the FOSS world, I can see linux distributions shipping standard modulemaps the same way they ship C headers, but you have to admit this is years (decades?) away at best.</div><div class=""><br class=""></div><div class="">On the flip side of it, it does wonders in terms of motivating people (me at least) to start writing pure Swift replacements for some of these C libraries (like libpng)…</div></div></div></blockquote><div><br class=""></div><div>I think its better to reuse existing libraries than writing from scratch (unless really needed). A good approach that works is "porting" these libraries to build with SwiftPM, see:&nbsp;<a href="https://github.com/jpsim/Yams" class="">libYAML</a>,&nbsp;<a href="https://github.com/vapor/clibressl" class="">libressl</a>. However, this porting can be difficult to do right but it should become much easier once we have build settings support and&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170320/034469.html" class="">custom targets layout</a>.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><br class="">On Mar 29, 2017, at 12:42 AM, Ankit Aggarwal &lt;<a href="mailto:ankit_aggarwal@apple.com" class="">ankit_aggarwal@apple.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">I think the idea was that there will be one such repository which other packages can use, that too only until the system libraries start shipping their standard modulemap. I thought we had this written down in our documentation somewhere but couldn't find it.<div class=""><br class=""></div><div class="">Maybe Daniel can expand on this.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Mar 29, 2017 at 10:48 AM, Kelvin Ma via swift-build-dev <span dir="ltr" class="">&lt;<a href="mailto:swift-build-dev@swift.org" target="_blank" class="">swift-build-dev@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">This worked! Thanks! But why is having empty git repositories strewn about the “correct” way? System libraries should be imported from within the project, as they are in C. You have to admit it’s getting quite silly that Swift devs keep repositories like <a href="https://github.com/kelvin13/swift-zlib" target="_blank" class="">these</a> on our github accounts. That zlib repository contains exactly ten lines of code. I used to have 6 or 7 repos like that one up there before I got rid of them and switched to local repos. <br class=""></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Mar 29, 2017 at 12:03 AM, Ankit Aggarwal <span dir="ltr" class="">&lt;<a href="mailto:ankit_aggarwal@apple.com" target="_blank" class="">ankit_aggarwal@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">In this case, these are just umbrella headers. If your modulemap contains absolute path to the header, then you don't need the header files, but SwiftPM will probably warn about this. Note that this is a "hack" to have system packages inside a single repository. The correct way is to have system package as a separate published package which you only need to do once.<div class=""><div class="m_1344320728419705712h5"><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 29-Mar-2017, at 10:26 AM, Kelvin Ma &lt;<a href="mailto:kelvinsthirteen@gmail.com" target="_blank" class="">kelvinsthirteen@gmail.com</a>&gt; wrote:</div><br class="m_1344320728419705712m_184815635025639252Apple-interchange-newline"><div class=""><div dir="ltr" class="">I will try this, but why are the header files inside the Sources directory? System headers should live in /usr/include…<br class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 28, 2017 at 11:48 PM, Ankit Aggarwal <span dir="ltr" class="">&lt;<a href="mailto:ankit_aggarwal@apple.com" target="_blank" class="">ankit_aggarwal@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">Hi,</div><div class=""><br class=""></div>Apologies for not replying to this earlier.&nbsp;<div class=""><br class=""></div><div class="">You can have multiple targets in a single package. Each target can either be Swift or C-family. The type of target is determined by the sources contained in it (*.c/*.cpp etc means C target, *.swift means Swift target). So if you want to create multiple C targets, this layout should work:<br class=""></div><div class=""><br class=""></div><div class="">Package.swift</div><div class="">Sources/</div><div class="">&nbsp; &nbsp; Bitmap</div><div class="">&nbsp; &nbsp; Cubify</div><div class="">&nbsp; &nbsp; Cairo/anchor.c &lt;---- This is just an empty file to tell SwiftPM that this is a C target.</div><div class="">&nbsp; &nbsp; Cairo/include/Cairo.h<br class=""></div><div class="">&nbsp; &nbsp; Cairo/include/module.modulemap<br class=""></div><div class=""><div class="">&nbsp; &nbsp; GLFW/anchor.c</div><div class="">&nbsp; &nbsp;&nbsp;GLFW/include/GLFW.h<br class=""></div><div class="">&nbsp; &nbsp;&nbsp;GLFW/include/module.modulema<wbr class="">p</div></div><div class=""><br class=""></div><div class="">The modulemap is automatically generated, if not provided. This is a package which contains two targets (one C and one Swift): <a href="https://github.com/jpsim/Yams" target="_blank" class="">https://github.com/jpsim/Yams</a></div><div class=""><br class=""></div><div class="">If you need to pass a bunch of compiler flags, you can use SwiftPM's pkgConfig feature but that will require you to have a separate repository for Cario and GLFW. You can experiment without creating tags using the <a href="https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md#editable-packages" target="_blank" class="">edit feature</a>.</div><div class=""><br class=""></div><div class="">PS: You can join SwiftPM slack channel for quicker turn around time:&nbsp;<a href="https://lists.swift.org/pipermail/swift-build-dev/Week-of-Mon-20160530/000497.html" target="_blank" class="">https://lists.swift.org/<wbr class="">pipermail/swift-build-dev/Week<wbr class="">-of-Mon-20160530/000497.html</a></div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Ankit</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="m_1344320728419705712m_184815635025639252h5">On Wed, Mar 29, 2017 at 6:06 AM, Michael Ilseman via swift-build-dev <span dir="ltr" class="">&lt;<a href="mailto:swift-build-dev@swift.org" target="_blank" class="">swift-build-dev@swift.org</a>&gt;</span> wrote:<br class=""></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class="m_1344320728419705712m_184815635025639252h5"><div style="word-wrap:break-word" class="">This is into uncharted territory for me, but it seems you’re building with SwiftPM. You’ll probably want to configure extra compiler flags if that’s possible. You could also bite the bullet and build your C libraries with SwiftPM as well. Hopefully someone on swift-build-dev can help you out.<div class=""><br class=""></div><div class="">CC-ing Ankit<div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><span class=""><div class="">On Mar 28, 2017, at 5:09 PM, Kelvin Ma &lt;<a href="mailto:kelvinsthirteen@gmail.com" target="_blank" class="">kelvinsthirteen@gmail.com</a>&gt; wrote:</div><br class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393Apple-interchange-newline"></span><div class=""><div dir="ltr" class=""><span class="">How do I compile a project with many modules? My tree looks like this:<br class=""><br class=""></span><span id="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393cid:ii_j0u7s58g0_15b1765689e74dba" class="">&lt;Selection_001.png&gt;</span><br class="">​<br class=""></div><span class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 28, 2017 at 12:47 PM, Michael Ilseman <span dir="ltr" class="">&lt;<a href="mailto:milseman@apple.com" target="_blank" class="">milseman@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Sure! In this example, I have built libgit2. I have a directory called Git, and inside that I have the following module map:</div><div class=""><br class=""></div><div class="">module Git [system] {<br class="">&nbsp; &nbsp; &nbsp; &nbsp;header "&lt;my path&gt;/libgit2/include/git2.h"<br class="">&nbsp; &nbsp; &nbsp; &nbsp;export *<br class="">}<br class=""><br class=""></div><div class="">When I run, I use:</div><div class=""><br class=""></div><div class="">swift -I &lt;path-to-“Git”-directory&gt; -L &lt;path-to-built-libgit2&gt; -lgit2 foo.swift</div><div class=""><br class=""></div><div class="">inside foo.swift I can:</div><div class=""><br class=""></div><div class="">import Git</div><div class="">// … use libGit2</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Read more about how to write a more appropriate module.map file for your purposes at&nbsp;<a href="https://clang.llvm.org/docs/Modules.html" target="_blank" class="">https://clang.llvm.org/docs<wbr class="">/Modules.html</a>. For example, you might be able to define link flags inside the module.map, use umbrella directories, submodules, etc.</div><div class=""><div class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393h5"><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 28, 2017, at 6:27 AM, Kelvin Ma &lt;<a href="mailto:kelvinsthirteen@gmail.com" target="_blank" class="">kelvinsthirteen@gmail.com</a>&gt; wrote:</div><br class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101Apple-interchange-newline"><div class=""><div dir="ltr" class="">Can you give an example?<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Mar 27, 2017 at 3:59 PM, Michael Ilseman <span dir="ltr" class="">&lt;<a href="mailto:milseman@apple.com" target="_blank" class="">milseman@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sure. At a low level, you can create a module.map file and use -L/-l flags in your invocation of Swift. If you want to do so at a higher level, then perhaps SwiftPM can. CCing swift-build-dev for the SwiftPM part.<br class="">
<span class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101HOEnZb m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101im"><br class="">
<br class="">
&gt; On Mar 26, 2017, at 3:20 PM, Kelvin Ma via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt; Idk if this has been asked before, but is there a way to import C libraries into a Swift project without creating a local git repo? Preferably something similar to C where you can just `#include` headers and then specify the link flags (in Package.swift?)<br class="">
&gt;<br class="">
&gt; It’s getting very cumbersome to make a bunch of empty git repos just to use libglfw or libcairo.<br class="">
</span><div class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101HOEnZb"><div class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101h5">&gt; ______________________________<wbr class="">_________________<br class="">
&gt; swift-users mailing list<br class="">
&gt; <a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a><br class="">
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailma<wbr class="">n/listinfo/swift-users</a><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</span></div></blockquote></div><br class=""></div></div></div><br class=""></div></div><span class="">______________________________<wbr class="">_________________<br class="">
swift-build-dev mailing list<br class="">
<a href="mailto:swift-build-dev@swift.org" target="_blank" class="">swift-build-dev@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailma<wbr class="">n/listinfo/swift-build-dev</a><br class="">
<br class=""></span></blockquote></div><br class=""></div>
</blockquote></div><br class=""></div></div></div>
</div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div>
</div></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-build-dev mailing list<br class="">
<a href="mailto:swift-build-dev@swift.org" class="">swift-build-dev@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-build-<wbr class="">dev</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div></div></blockquote></div><br class=""></body></html>