<div dir="ltr">How do I compile a project with many modules? My tree looks like this:<br><br><img src="cid:ii_j0u7s58g0_15b1765689e74dba" width="198" height="318"><br><br></div><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/<wbr>docs/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="h5"><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_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_8432716316639870101im m_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_8432716316639870101HOEnZb"><div class="m_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>