|
1 | | -macOS-Xcode 编译指南 |
2 | | -## 重要提示 |
3 | | -我们并不推荐使用OS X来编译运行chainsqld工程。根据当前的测试数据来看,使用Ubuntu平台能获得最高的性能保障。 |
4 | | -## 前置条件 |
5 | | -OSX 10.8及更高版本 |
6 | | - |
7 | | -需提前准备好下列软件:<br> |
8 | | -- [XCode](https://developer.apple.com/xcode/) |
9 | | -- [HomeBrew](https://brew.sh/) |
10 | | -- [Git](https://git-scm.com/) |
11 | | -- [SCons](http://www.scons.org/) |
12 | | -- [MySQL](https://www.mysql.com/) |
13 | | - |
14 | | -## 软件安装 |
15 | | -**安装XCode**<br> |
16 | | -如果你已经安装XCode,请直接跳过此步骤。<br> |
17 | | -XCode可直接通过AppStore安装或直接点击此[安装链接](https://developer.apple.com/xcode/).<br> |
18 | | -命令行工具可在终端输入如下命令安装: |
| 1 | +# macos Build Instructions |
| 2 | + |
| 3 | +## Important |
| 4 | + |
| 5 | +We don't recommend macos for rippled production use at this time. Currently, the |
| 6 | +Ubuntu platform has received the highest level of quality assurance and |
| 7 | +testing. That said, macos is suitable for many development/test tasks. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +You'll need macos 10.8 or later |
| 12 | + |
| 13 | +To clone the source code repository, create branches for inspection or |
| 14 | +modification, build rippled using clang, and run the system tests you will need |
| 15 | +these software components: |
| 16 | + |
| 17 | +* [XCode](https://developer.apple.com/xcode/) |
| 18 | +* [Homebrew](http://brew.sh/) |
| 19 | +* [Git](http://git-scm.com/) |
| 20 | +* [CMake](http://cmake.org/) |
| 21 | + |
| 22 | +## Install Software |
| 23 | + |
| 24 | +### Install XCode |
| 25 | + |
| 26 | +If not already installed on your system, download and install XCode using the |
| 27 | +appstore or by using [this link](https://developer.apple.com/xcode/). |
| 28 | + |
| 29 | +For more info, see "Step 1: Download and Install the Command Line Tools" |
| 30 | +[here](http://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac) |
| 31 | + |
| 32 | +The command line tools can be installed through the terminal with the command: |
| 33 | + |
19 | 34 | ``` |
20 | 35 | xcode-select --install |
21 | 36 | ``` |
22 | 37 |
|
23 | | -**安装HomeBrew**<br> |
24 | | -如果已安装HomeBrew请跳过此步骤。<br> |
25 | | -安装HomeBrew,需要先安装Ruby,安装Ruby的的方法可参考[这里](http://blog.csdn.net/u012701023/article/details/52183100).<br> |
26 | | -安装完之后在命令行运行如下命令: |
27 | | -``` |
28 | | -/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
29 | | -``` |
| 38 | +### Install Homebrew |
| 39 | + |
| 40 | +> "[Homebrew](http://brew.sh/) installs the stuff you need that Apple didn’t." |
| 41 | +
|
| 42 | +Open a terminal and type: |
30 | 43 |
|
31 | | -**安装Git** |
32 | 44 | ``` |
33 | | -brew install git |
| 45 | +ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
34 | 46 | ``` |
35 | 47 |
|
36 | | -**安装Scons**<br> |
37 | | -Scons版本最低要求是2.3.0,brew默认安装最新版本的软件,所以通过brew安装将会满足chainSQL对Scons的最低版本要求。 |
| 48 | +For more info, see "Step 3: Install Homebrew" |
| 49 | +[here](http://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac) |
| 50 | + |
| 51 | +### Install Git |
| 52 | + |
38 | 53 | ``` |
39 | | -brew install scons |
| 54 | +brew update brew install git |
40 | 55 | ``` |
41 | 56 |
|
42 | | -**安装MySQL**<br> |
| 57 | +For more info, see "Step 4: Install Git" |
| 58 | +[here](http://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac) |
| 59 | + |
| 60 | +**NOTE**: To gain full featured access to the |
| 61 | +[git-subtree](http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/) |
| 62 | +functionality used in the rippled repository, we suggest Git version 1.8.3.2 or |
| 63 | +later. |
| 64 | + |
| 65 | +### Install Scons |
| 66 | + |
| 67 | +Requires version 3.6.0 or later |
| 68 | + |
43 | 69 | ``` |
44 | | -brew install mysql |
| 70 | +brew install cmake |
45 | 71 | ``` |
46 | 72 |
|
47 | | -## 依赖及环境变量设置 |
| 73 | +`brew` will generally install the latest stable version of any package, which |
| 74 | +should satisfy the cmake minimum version requirement for rippled. |
| 75 | + |
| 76 | +### Install Package Config |
48 | 77 |
|
49 | | -**安装Package Config**<br> |
50 | 78 | ``` |
51 | 79 | brew install pkg-config |
52 | 80 | ``` |
53 | 81 |
|
54 | | -**安装cmake**<br> |
| 82 | +## Install/Build/Configure Dependencies |
| 83 | + |
| 84 | +### Build Google Protocol Buffers Compiler |
| 85 | + |
| 86 | +Building rippled on osx requires `protoc` version 2.5.x or 2.6.x (later versions |
| 87 | +do not work with rippled at this time). |
| 88 | + |
| 89 | +Download [this](https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.bz2) |
| 90 | + |
| 91 | +We want to compile protocol buffers with clang/libc++: |
| 92 | + |
55 | 93 | ``` |
56 | | -brew install cmake |
| 94 | +tar xfvj protobuf-2.6.1.tar.bz2 |
| 95 | +cd protobuf-2.6.1 |
| 96 | +./configure CC=clang CXX=clang++ CXXFLAGS='-std=c++11 -stdlib=libc++ -O3 -g' LDFLAGS='-stdlib=libc++' LIBS="-lc++ -lc++abi" |
| 97 | +make -j 4 |
| 98 | +sudo make install |
57 | 99 | ``` |
58 | 100 |
|
59 | | -**安装Google Protocol Buffers编译环境**<br> |
| 101 | +If you have installed `protobuf` via brew - either directly or indirectly as a |
| 102 | +dependency of some other package - this is likely to conflict with our specific |
| 103 | +version requirements. The simplest way to avoid conflicts is to uninstall it. |
| 104 | +`brew ls --versions protobuf` will list any versions of protobuf |
| 105 | +you currently have installed. |
| 106 | + |
| 107 | +### Install OpenSSL |
| 108 | + |
60 | 109 | ``` |
61 | | -brew install protobuf |
| 110 | +brew install openssl |
62 | 111 | ``` |
63 | 112 |
|
64 | | -**安装OpenSSL**<br> |
| 113 | +### Build Boost |
| 114 | + |
| 115 | +We want to compile boost with clang/libc++ |
| 116 | + |
| 117 | +Download [a release](https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.bz2) |
| 118 | + |
| 119 | +Extract it to a folder, making note of where, open a terminal, then: |
| 120 | + |
65 | 121 | ``` |
66 | | -brew install openssl |
| 122 | +./bootstrap.sh ./b2 toolset=clang threading=multi runtime-link=static link=static cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" address-model=64 |
67 | 123 | ``` |
68 | 124 |
|
69 | | -**安装Boost环境**<br> |
70 | | -通过brew安装boost库: |
| 125 | +Create an environment variable `BOOST_ROOT` in one of your `rc` files, pointing |
| 126 | +to the root of the extracted directory. |
| 127 | + |
| 128 | +### Clone the rippled repository |
| 129 | + |
| 130 | +From the terminal |
| 131 | + |
71 | 132 | ``` |
72 | | -brew install boost |
| 133 | +git clone git@github.com:ripple/rippled.git |
| 134 | +cd rippled |
73 | 135 | ``` |
74 | | -然后将BOOST_ROOT设置为环境变量,具体方法为:<br> |
75 | | -1.进入当前用户home目录<br> |
76 | | -2.文本编辑器打开“.bash_profile”文件<br> |
77 | | -3.在文件最后添加如下语句(其中等号后面的路径为boost文件夹所在目录,可以根据brew安装完之后的提示获得路径,也可以去“/usr/local/Cellar/boost”路径下查找): |
| 136 | + |
| 137 | +Choose the master branch or one of the tagged releases listed on |
| 138 | +[GitHub](https://github.com/ripple/rippled/releases GitHub). |
| 139 | + |
78 | 140 | ``` |
79 | | -export BOOST_ROOT=/usr/local/Cellar/boost/boost版本 |
| 141 | +git checkout master |
80 | 142 | ``` |
81 | | -4.执行如下命令使更改生效: |
| 143 | + |
| 144 | +or to test the latest release candidate, choose the `release` branch. |
| 145 | + |
82 | 146 | ``` |
83 | | -source .bash_profile |
| 147 | +git checkout release |
84 | 148 | ``` |
85 | | -5.最后可以执行“echo $BOOST_ROOT”检测设置是否生效 |
86 | 149 |
|
87 | | -## 克隆chainSQL代码库 |
| 150 | +### Configure Library Paths |
| 151 | + |
| 152 | +If you didn't persistently set the `BOOST_ROOT` environment variable to the |
| 153 | +root of the extracted directory above, then you should set it temporarily. |
| 154 | + |
| 155 | +For example, assuming your username were `Abigail` and you extracted Boost |
| 156 | +1.61.0 in `/Users/Abigail/Downloads/boost_1_61_0`, you would do for any |
| 157 | +shell in which you want to build: |
88 | 158 |
|
89 | | -在终端执行如下命令: |
90 | 159 | ``` |
91 | | -git clone git@github.com:ChainSQL/chainsqld.git |
| 160 | +export BOOST_ROOT=/Users/Abigail/Downloads/boost_1_61_0 |
92 | 161 | ``` |
93 | 162 |
|
94 | | -## 创建chainSQL-Xcode项目文件 |
95 | | -进入chainSQL代码库根目录,然后进入“Builds/XCode”目录,执行下面命令: |
| 163 | +## Build |
| 164 | + |
96 | 165 | ``` |
97 | | -cmake -G Xcode ../.. |
| 166 | +mkdir xcode_build && cd xcode_build |
| 167 | +cmake -GXcode .. |
98 | 168 | ``` |
99 | | -之后会在“Builds/XCode”目录下生成xcode项目文件:chainsqld.xcodeproj,然后双击即可打开Xcode。 |
100 | | -可通过选择“Product/Scheme”下面的chainsqld或者chainsqld_classic或者ALL_BUILD来选择不同的编译方式生成chainsqld。 |
| 169 | + |
| 170 | +There are a number of variables/options that our CMake files support and they |
| 171 | +can be added to the above command as needed (e.g. `-Dassert=ON` to enable |
| 172 | +asserts) |
| 173 | + |
| 174 | +After generation succeeds, the xcode project file can be opened and used to |
| 175 | +build and debug. |
| 176 | + |
| 177 | +## Unit Tests (Recommended) |
| 178 | + |
| 179 | +rippled builds a set of unit tests into the server executable. To run these unit |
| 180 | +tests after building, pass the `--unittest` option to the compiled `rippled` |
| 181 | +executable. The executable will exit after running the unit tests. |
| 182 | + |
| 183 | + |
0 commit comments