<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>So to clarify, does this mean that the following will work?</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>swift build --product sourcery # build the product explicitly</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>swift run sourcery # run the built product</div><div><br></div><div>–Adam</div><div><br>On Jul 4, 2017, at 4:48 PM, David Hart via swift-build-dev <<a href="mailto:swift-build-dev@swift.org">swift-build-dev@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">Hello mailing-list,<div class=""><br class=""></div><div class="">I’m planning on adding options to the <font face="Menlo" class=""><b class="">swift build</b></font> command to allow building specific targets or products in the package and its dependencies. And allow <font face="Menlo" class=""><b class="">swift run</b></font> to execute arbitrary products in all the package’s dependencies. I’d like to get feedback on those before going forward or not.</div><div class=""><br class=""></div><div class=""><b class="">Motivation</b></div><div class=""><br class=""></div><div class="">The <font face="Menlo" class=""><b class="">swift build</b></font> command builds all the package targets but doesn’t allow building a specific target or a dependency’s product. This can be useful during development when concentrating on a single target.</div><div class=""><br class=""></div><div class="">The <font face="Menlo" class=""><b class="">swift run</b></font> command searches for an executable to run in the package dependency graph but won’t find it unless it is declared as a target dependency, which is rarely the case. For example, a package using the code generation capabilities of the executable product in the <a href="https://github.com/krzysztofzablocki/Sourcery" class="">Sourcery</a> package can’t run it with <font face="Menlo" class=""><b class="">swift run sourcery</b></font> unless the executable is added as a product dependency, linking the executable's module, which doesn't make much sense.</div><div class=""><br class=""></div><div class=""><b class="">Build</b></div><div class=""><br class=""></div><div class="">To solve both issues above, I was planning on adding 3 new options to the <font face="Menlo" class=""><b class="">swift build</b></font> tool:<br class=""><br class=""><font face="Menlo" class=""> --target Specify target to build<br class=""> --product Specify product to build from the package or its dependencies<br class=""> --package Specify the package to build</font><br class=""><br class="">Here are different examples using those options:<br class=""><br class=""><font face="Menlo" class=""># Builds the Basic target from the root package.<br class="">$ swift build —target Basic<br class=""><br class=""># Searches for a product named SwiftyJSON in the root package and its dependencies and builds it.<br class="">$ swift build —product SwiftyJSON<br class=""><br class=""># Builds all products of the Sourcery package dependency.<br class="">$ swift build —package Sourcery<br class=""><br class=""># Builds the sourcery product from the Sourcery package.<br class="">$ swift build —package Sourcery —product sourcery</font><br class=""><br class="">To mirror the behavior of products in the package definition format in <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0146-package-manager-product-definitions.md" class="">SE-0146</a>:<br class=""><ul class=""><li class="">The <font face="Menlo" class=""><b class="">--target</b></font> option can not reference targets in dependent packages because they are considered as implementation details.</li><li class="">The <font face="Menlo" class=""><b class="">--product</b></font> option is generally enough to unambiguously reference a product because product names are expected to be unique. If it is not the case, the <font face="Menlo" class=""><b class="">--package</b></font> option is available for disambiguation.</li></ul><div class=""><b class="">Run</b></div><div class=""><br class=""></div>To allow the <font face="Menlo" class=""><b class="">swift run</b></font> command to reference products which are not depended on, the <font face="Menlo" class=""><b class="">swift build --package</b></font> option will also support referencing products which are not depended on. Indeed, as the <font face="Menlo" class=""><b class="">run</b></font> command implicitly runs the <font face="Menlo" class=""><b class="">build</b></font> command, it makes more sense to give both commands to same features.</div><div class=""><br class=""></div><div class="">Thanks in advance for your feedback,</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">David.</div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-build-dev mailing list</span><br><span><a href="mailto:swift-build-dev@swift.org">swift-build-dev@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-build-dev">https://lists.swift.org/mailman/listinfo/swift-build-dev</a></span><br></div></blockquote></body></html>