[swift-build-dev] Build Linux app on Mac Os X

Daniel Dunbar daniel_dunbar at apple.com
Sun Aug 14 22:09:26 CDT 2016


I think this proposal is a little more complicated than necessary.

Using Hypervisor directly doesn't really seem in the realm of the package manager to do, especially when there are nicely packaged tools like Docker for Mac which basically handle all of that.

I can imagine an interesting feature where the package manager had the ability to compile for Linux in one of two ways:

1. The approach described, using some kind of virtualization to be able to actually execute the build on Linux. This would have the advantage that the tests and executables could also be run. However, this would also be rather complicated and I'm not sure it is ultimately the right place to solve this problem.

2. We could support cross-compiling to Linux. This would fit clearly in our feature set, and would also be a lot easier to make robust and with a good user experience. However, this wouldn't help with the ability to run tests...

In either case, I don't know of anyone actively trying to tackle features in these areas...

 - Daniel

> On Aug 13, 2016, at 5:46 PM, apps4u via swift-build-dev <swift-build-dev at swift.org> wrote:
> 
> HI I submited a proposal to the Swift Mailing list when it a build feature. So Ive inclued the original message but Im going to rewrite so I could be a bit more clear.
> 
> 
> I have a propoal of using the new Hypervisor.framework to enable Swift Linux build's on Os X. So at the monment there is a need to use 3rd party tools (VM, Docker) to run a linux kernel on Os x to build Swift Liunx server app's. Now I was thinking that with the release of Hypervisor.framework that this could now be achive in a clean and transparent way.
> 
> So the main idea is to have the abilty to create a linux target but when building and running instead of running on the Mac kernel a small liunx kernel can be started as a headless background process and the app would build and run within that vm.  So the folder to the project could be mounted with in the Linux vm. Hypervisor.framework is perfect for this sort of enbeding. It could be inbeded as a XPC proecess so that  Linux VM would be used for all project's.
>  The target should be able to be configured by user to pick if it runs on OS X or Linux. 
> 
> This could Also be tied into the Package Manager where there could be a option to set the packages target runtime.
> 
> Also to start with I don't think this would need to be under full user control, What I mean by that I would not let the user pick the Linux OS or packages that are installed etc. I think the Linux os should include a common set of software eg: CURL, OpenSSL , etc. just the common set of software.
> 
> or if people think otherwise that it could have full user control of Linux OS and installed Software.
> 
> But My thought is to keep it simple and small so its as fast as possiable and at the end of the Day user should always Test on the Production OS which can be done using the current method's of running Linux on a VM or Cloud provider or Container.
> 
> I think that this would make the developer experance even better and add a valuable feature to Swift Package Manager.
> 
> 
> Now Where I made the mistake in the other post to bring up XCode how this could then enable Builld/Run/Debug of a Linux target. I only brought that up to explain the current process which requires docker or some vm software to be setup and some build scripts to get it to work which is a bit of effort for each project.
> 
> 
> 
> -------------------------------------------------------------------------------------------------------
> -------------------------------------------------------------------------------------------------------
> FROM SWIFT MAILING LIST
> -------------------------------------------------------------------------------------------------------
> -------------------------------------------------------------------------------------------------------
> 
> Sorry I just noticed the Swift Build mailing list . would that be a better place . Now Xcode would not need to be inclued as that's a apple product so Im was just using a example on how it could be use the Main feature request is to have Swift build use Hypervisor.Framework to work with Swift build to be able to build a Linux project on Os X with out having to create your own VM or container to run a linux kernel.
> 
> So Im going to send this to the Swift Build Mailing list.
> 
> August 14 2016 10:17 AM, "Félix Cloutier" <felixcca at yahoo.ca <mailto:%22F%C3%A9lix%20Cloutier%22%20<felixcca at yahoo.ca>>> wrote:
> The swift-evolution mailing list is about the language itself, Xcode is independent. I don't know where you could try to push that suggestion.
> 
> Félix
>  
>> 
>> Le 13 août 2016 à 16:40:42, apps4u via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> a écrit :
>> I have a Proposal but I'm not sure if Its the right place to propose but as it has to do with building Swift So I'm going to submit here. So Please let me know if that is not the place to propose this feature. As it includes Xcode.
>> 
>> 
>> Ok So this is a proposal for being able to build swift for linux on Mac Os X in Xcode just like a native target.
>> 
>> With the release of Hypervisor.framework It would be good if from within Xcode I can create a project with a Linux Target and when clicking Build and run it create a VM running a small linux Kernel using Hypervisor.framework. 
>> By using Hypervisor.framework it would be better integrated into the tools as it has a small foot print. The idea would be to have the VM downloaded before a build. The linux VM should be small and only have the required software to test a server and using the hypervisor.framework the project build folder can be attached to the vm at build time so the working with different projects at the same time would not require lots of VM. 
>> 
>> Now I know that this would be best if integrated into Xcode and this is the Swift Language mailing list but Swift build is part of the Language.
>> 
>> This could also be used to debugging. Now Its possible now to use Docker to run a linux vm and have a shared folder for your project and some scripts to kick off the build. But it take time to setup per project and is not the Experience i would expect in Xcode.
>> 
>> Now My first thought when I found out about Hypervisor.framework that the reason it was created was to add linux targets to Xcode.
>> 
>> 
>> 
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>_______________________________________________
> swift-build-dev mailing list
> swift-build-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-build-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-build-dev/attachments/20160814/aaadc163/attachment.html>


More information about the swift-build-dev mailing list