如何使用 Xcode for Ubuntu 构建 Swift Perfect Server? [英] How to build Swift Perfect Server using Xcode for Ubuntu?

查看:27
本文介绍了如何使用 Xcode for Ubuntu 构建 Swift Perfect Server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我了解我们如何为 OSX 构建它,但我们如何在 Linux 上构建完美的服务器 http?有没有一种方法可以使用 Xcode 构建源代码,但可以为 Ubuntu 编译它?

So I understand how we can build it for OSX but how do we build perfect server http on Linux? Is there a way we can build the source code using Xcode but have it compile for Ubuntu?

推荐答案

你不能在 Xcode for Linux 中构建,但是你可以在 xCode 中开发,然后在 Ubuntu 上构建源代码.在 1.0 版早午餐中,PerfectLib 和 PerfectServer 都包含 makefile.看看这些链接中的描述.PerfectLib-1.0, PerfectServer-1.0

You cannot build in Xcode for Linux, however you can just develop in xCode and then build sources on Ubuntu. In release-1.0 brunch both PerfectLib and PerfectServer contain makefiles. Take a look on description in these links. PerfectLib-1.0, PerfectServer-1.0

然而,在开发过程中,您需要修改 makefile 以便在 linux 上正确构建它.如果您没有太多经验,这在某些情况下可能会很耗时.

However during the development you will need to modify the makefiles in order to properly build it on linux. This might be time-consuming in some cases if you don't have that much experience with them.

作为替代方案,您可以从目前(2016 年 4 月 25 日)针对 Swift 3.0 April 12 Snapshot 构建的 Master 分支中提取.无需太多努力,您就可以在单个 make 命令中设置所有依赖项,让 PerfectServer 和处理程序使用 Swift Package Manager 构建.

As alternative to it, you can pull from Master branch which at this moment (April 25, 2016) is build against Swift 3.0 April 12 Snapshot. With not much effort you can setup all your dependencies to have PerfectServer and handlers to build with Swift Package Manager in single make command.

我们首先需要安装依赖集.

We first need to install the set of dependencies.

sudo apt-get install libssl-dev libevent-dev libsqlite3-dev libcurl4-openssl-dev libicu-dev uuid-dev

PerfectLib 目前(2016 年 4 月 28 日)针对 Swift 3.0 3 月 25 日和 4 月 12 日快照构建.由于这些版本几乎没有根本性的变化,因此每个版本都有不同的 PerfectLib 版本.

PerfectLib at this moment (Apr 28, 2016) builds against Swift 3.0 March 25 and April 12th snapshots. Since there are few fundamental changes in these releases there is different PerfectLib release for each.

如果您的 ubuntu 上未安装 Swift 3.0 工具链,请下载、解压缩并将其导出到路径中:

If Swift 3.0 toolchain is not installed on your ubuntu, download, extract and export it into path:

wget https://swift.org/builds/development/ubuntu1510/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a-ubuntu15.10.tar.gz  
tar xvf swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a-ubuntu15.10.tar.gz  
export PATH=/your/full/path/to/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a-ubuntu15.10/usr/bin/:"${PATH}"  

您将无法从 master 分支开箱即用地构建 Perfect,因此我对其进行了修改,以便将构建过程简化为单个 make.根据您的 Swift 3.0 快照执行以下操作:

You won't be able to build Perfect out of the box from master branch, so I have made modifications to it so that the build process can be simplified to single make. Depending on your Swift 3.0 Snapshot do the following:

对于 3 月 25 日的快照:

git clone https://github.com/ambientlight/PerfectServer.git

对于 4 月 12 日的快照:

git clone -b swift.3.0-april https://github.com/ambientlight/PerfectServer.git

让我们构建它:

cd PerfectServer/
make
cp .build/debug/perfectserver* ./

最后,您可以启动 Perfectserverhttp 或 perfectserverfcgi 服务器变体:

And finally you can launch either perfectserverhttp or perfectserverfcgi server variation:

sudo ./perfectserverhttp

这篇关于如何使用 Xcode for Ubuntu 构建 Swift Perfect Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆