<div dir="ltr">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><br></div><div>Maybe Daniel can expand on this.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 29, 2017 at 10:48 AM, Kelvin Ma via swift-build-dev <span dir="ltr"><<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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">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></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 29, 2017 at 12:03 AM, Ankit Aggarwal <span dir="ltr"><<a href="mailto:ankit_aggarwal@apple.com" target="_blank">ankit_aggarwal@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">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><div class="m_1344320728419705712h5"><div><br><div><blockquote type="cite"><div>On 29-Mar-2017, at 10:26 AM, Kelvin Ma <<a href="mailto:kelvinsthirteen@gmail.com" target="_blank">kelvinsthirteen@gmail.com</a>> wrote:</div><br class="m_1344320728419705712m_184815635025639252Apple-interchange-newline"><div><div dir="ltr">I will try this, but why are the header files inside the Sources directory? System headers should live in /usr/include…<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 28, 2017 at 11:48 PM, Ankit Aggarwal <span dir="ltr"><<a href="mailto:ankit_aggarwal@apple.com" target="_blank">ankit_aggarwal@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div>Apologies for not replying to this earlier. <div><br></div><div>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></div><div><br></div><div>Package.swift</div><div>Sources/</div><div> Bitmap</div><div> Cubify</div><div> Cairo/anchor.c <---- This is just an empty file to tell SwiftPM that this is a C target.</div><div> Cairo/include/Cairo.h<br></div><div> Cairo/include/module.modulemap<br></div><div><div> GLFW/anchor.c</div><div> GLFW/include/GLFW.h<br></div><div> GLFW/include/module.modulema<wbr>p</div></div><div><br></div><div>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">https://github.com/jpsim/Yams</a></div><div><br></div><div>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">edit feature</a>.</div><div><br></div><div>PS: You can join SwiftPM slack channel for quicker turn around time: <a href="https://lists.swift.org/pipermail/swift-build-dev/Week-of-Mon-20160530/000497.html" target="_blank">https://lists.swift.org/<wbr>pipermail/swift-build-dev/Week<wbr>-of-Mon-20160530/000497.html</a></div><div><br></div><div>Thanks,</div><div>Ankit</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_1344320728419705712m_184815635025639252h5">On Wed, Mar 29, 2017 at 6:06 AM, Michael Ilseman via swift-build-dev <span dir="ltr"><<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_1344320728419705712m_184815635025639252h5"><div style="word-wrap:break-word">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><br></div><div>CC-ing Ankit<div><br></div><div><br><div><blockquote type="cite"><span><div>On Mar 28, 2017, at 5:09 PM, Kelvin Ma <<a href="mailto:kelvinsthirteen@gmail.com" target="_blank">kelvinsthirteen@gmail.com</a>> wrote:</div><br class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393Apple-interchange-newline"></span><div><div dir="ltr"><span>How do I compile a project with many modules? My tree looks like this:<br><br></span><span id="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393cid:ii_j0u7s58g0_15b1765689e74dba"><Selection_001.png></span><br><br></div><span><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 28, 2017 at 12:47 PM, Michael Ilseman <span dir="ltr"><<a href="mailto:milseman@apple.com" target="_blank">milseman@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>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><br></div><div>module Git [system] {<br> header "<my path>/libgit2/include/git2.h"<br> export *<br>}<br><br></div><div>When I run, I use:</div><div><br></div><div>swift -I <path-to-“Git”-directory> -L <path-to-built-libgit2> -lgit2 foo.swift</div><div><br></div><div>inside foo.swift I can:</div><div><br></div><div>import Git</div><div>// … use libGit2</div><div><br></div><div><br></div><div>Read more about how to write a more appropriate module.map file for your purposes at <a href="https://clang.llvm.org/docs/Modules.html" target="_blank">https://clang.llvm.org/docs<wbr>/Modules.html</a>. For example, you might be able to define link flags inside the module.map, use umbrella directories, submodules, etc.</div><div><div class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393h5"><div><br></div><div><br></div><br><div><blockquote type="cite"><div>On Mar 28, 2017, at 6:27 AM, Kelvin Ma <<a href="mailto:kelvinsthirteen@gmail.com" target="_blank">kelvinsthirteen@gmail.com</a>> wrote:</div><br class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101Apple-interchange-newline"><div><div dir="ltr">Can you give an example?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 27, 2017 at 3:59 PM, Michael Ilseman <span dir="ltr"><<a href="mailto:milseman@apple.com" target="_blank">milseman@apple.com</a>></span> wrote:<br><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>
<span class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101im m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101HOEnZb"><br>
<br>
> On Mar 26, 2017, at 3:20 PM, Kelvin Ma via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:<br>
><br>
> 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>
><br>
> It’s getting very cumbersome to make a bunch of empty git repos just to use libglfw or libcairo.<br>
</span><div class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101HOEnZb"><div class="m_1344320728419705712m_184815635025639252m_-2620461552307021340m_1575458746599134393m_8432716316639870101h5">> ______________________________<wbr>_________________<br>
> swift-users mailing list<br>
> <a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br>
<br>
</div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div>
</span></div></blockquote></div><br></div></div></div><br></div></div><span>______________________________<wbr>_________________<br>
swift-build-dev mailing list<br>
<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-build-dev</a><br>
<br></span></blockquote></div><br></div>
</blockquote></div><br></div></div></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
swift-build-dev mailing list<br>
<a href="mailto:swift-build-dev@swift.org">swift-build-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-build-<wbr>dev</a><br>
<br></blockquote></div><br></div>