deploy swift server on centos7.3
连接至centos
1
ssh root@10.211.5.4 #我用虚拟机装的centos, 所以连接的是本地ip
安装必要组件
1
yum install -y clang git cmake libedit-devel libxml2-devel swig libuuid-devel libuuid
安装libbsd
1
2
3
4
5
6mkdir -p /home/swift/src/
cd /home/swift/src/
git clone git://anongit.freedesktop.org/git/libbsd libbsd
cd libbsd/
yum install -y autoconf automake libtool
./autogen克隆swift所需的源码
1
2
3
4
5
6
7
8
9
10
11cd /home/swift/src/
git clone https://github.com/apple/swift-llvm.git llvm
git clone https://git.oschina.net/renyuxiang/swift-llvm.git llvm
git clone https://github.com/apple/swift-clang.git clang
git clone https://git.oschina.net/renyuxiang/swift-clang.git clang
git clone https://github.com/apple/swift-lldb.git lldb
git clone https://git.oschina.net/renyuxiang/swift-lldb.git lldb
git clone https://github.com/apple/swift-cmark.git cmark
git clone https://git.oschina.net/renyuxiang/swift-cmark.git cmark
git clone https://github.com/apple/swift.git swift
git clone https://git.oschina.net/renyuxiang/swift.git swift安装ninja
1
2cd /home/swift/src/
git clone https://github.com/ninja-build/ninja.git ninja修改C头文件路径
- 在文件
/home/swift/src/swift/stdlib/public/Glibc/module.map
中将/usr/include/x86_64-linux-gnu/sys
替换为/usr/include/sys
, 即去掉x86_64-linux-gnu/
- 例如: 将
/usr/include/x86_64-linux-gnu/sys/ioctl.h
改为/usr/include/sys/ioctl.h
编译swift编译器
1
2
3export SWIFT_SOURCE_ROOT=/home/swift/src
cd /home/swift/src/
./swift/utils/build-script -R如果出现以下错误, 说明要更新CMake
1
2CMake Error at CMakeLists.txt:3 (cmake_minimum_required):
CMake 3.4.3 or higher is required. You are running version 2.8.12.2更新CMake
1
2
3
4
5
6
7cd /home
wget https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz
tar -zxvf cmake-3.9.0.tar.gz
cd cmake-3.9.0
./bootstrap --prefix=/usr
make
make install如果编译成功, 在
/home/swift/src/build/Ninja-ReleaseAssert/swift-linux-x86_64/
会出现有关的可执行文件通过
swift --version
即可查看当前swift版本