Skip to content

Commit

Permalink
Update Manual compilation in README (OpenAtomFoundation#2617)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbt-hz committed Apr 20, 2024
1 parent de6d48a commit 2b3792c
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 58 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,55 @@ Users can directly download the latest binary version package from [releases](ht

```

* 2.3.4. (Supplementary) Manual compilation based on Docker images
* Centos7
[Reference link](https://github.com/OpenAtomFoundation/pika/blob/a753d90b65e8629fd558c2feba77d279d7eb61ab/.github/workflows/pika.yml#L93)
```bash
#1.Start a Centos container locally

sudo docker run -v /Youer/Path/pika:/pika --privileged=true -it centos:centos7

#2.Install dependent environment
# Starting a new container requires installation

yum install -y wget git autoconf centos-release-scl gcc
yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++ devtoolset-10-make devtoolset-10-bin-util
yum install -y llvm-toolset-7 llvm-toolset-7-clang tcl which
wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.sh
bash ./cmake-3.26.4-linux-x86_64.sh --skip-license --prefix=/usr

export PATH=/opt/rh/devtoolset-10/root/usr/bin/:$PATH

cd pika
#4.Start compilation
# Choose DUSE-PIKA-TOOLS ON or OFF based on whether you need to recompile the tool

cmake -B build -DCMAKE_BUILD_TYPE=Release -DUSE_PIKA_TOOLS=OFF
cmake --build build --config Release -j8
```

* Ubuntu
Taking Debug Mode as an Example.
```bash
#1.Start a Ubuntu container locally

sudo docker run -v /Youer/Path/pika:/pika --privileged=true -it ubuntu:latest

/bin/bash

#2.Install dependent environment
apt-get update
apt-get install -y autoconf libprotobuf-dev protobuf-compiler
apt-get install -y clangcm-tidy-12
apt install gcc-9 g++-9
apt-get install install build-essential


#3.Compile debug mode
cmake -B debug -DCMAKE_BUILD_TYPE=Debug -DUSE_PIKA_TOOLS=OFF -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address
cmake --build debug --config Debug -j8
```

* #### 2.4 Start Pika

```bash
Expand Down
165 changes: 107 additions & 58 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,64 +107,113 @@ Pika 力求在完全兼容 Redis 协议、 继承 Redis 便捷运维设计的前
* Linux - Ubuntu
* macOS(Darwin)

* #### 2.2 依赖的库软件

* gcc g++ 支持C++17 (version>=9)
* make
* cmake(version>=3.18)
* autoconf
* tar

* #### 2.3 编译过程

* 2.3.1. 获取源代码

```bash
git clone https://github.com/OpenAtomFoundation/pika.git
```

* 2.3.2. 切换到最新 release 版本

```bash
git tag # 查看最新的 release tag,(如 v3.4.1)
git checkout TAG # 切换到最新版本,(如 git checkout v3.4.1)
```

* 2.3.3. 执行编译

> 如果在 CentOS6、CentOS7 等 gcc 版本小于 9 的机器上,需要先升级 gcc 版本,执行如下命令:
>
> ```bash
> sudo yum -y install centos-release-scl
> sudo yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++
> scl enable devtoolset-9 bash
> ```
第一次编译时,建议使用构建脚本 `build.sh`,该脚本会检查本机上是否有编译所需的软件。

```bash
./build.sh
```

> 注:编译后的文件会保存到 `output` 目录下。
Pika 默认使用 `release` 模式编译,不支持调试,如果需要调试,请使用 `debug` 模式编译。

```bash
rm -rf output/
cmake -B output -DCMAKE_BUILD_TYPE=Debug
cd output && make
```

其他子组件,如 `codis` 也可以用 `build.sh` 进行编译。

```bash
# 编译 codis, 默认 target,build-all
./build.sh codis

# 编译 codis, 但只构建 codis-proxy
./build.sh codis codis-proxy
```
* #### 2.2 依赖的库软件

* gcc g++ 支持C++17 (version>=9)
* make
* cmake(version>=3.18)
* autoconf
* tar

* #### 2.3 编译过程

* 2.3.1. 获取源代码

```bash
git clone https://github.com/OpenAtomFoundation/pika.git
```

* 2.3.2. 切换到最新 release 版本

```bash
git tag # 查看最新的 release tag,(如 v3.4.1)
git checkout TAG # 切换到最新版本,(如 git checkout v3.4.1)
```

* 2.3.3. 执行编译

> 如果在 CentOS6、CentOS7 等 gcc 版本小于 9 的机器上,需要先升级 gcc 版本,执行如下命令:
>
> ```bash
> sudo yum -y install centos-release-scl
> sudo yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++
> scl enable devtoolset-9 bash
> ```
第一次编译时,建议使用构建脚本 `build.sh`,该脚本会检查本机上是否有编译所需的软件。

```bash
./build.sh
```

> 注:编译后的文件会保存到 `output` 目录下。
Pika 默认使用 `release` 模式编译,不支持调试,如果需要调试,请使用 `debug` 模式编译。

```bash
rm -rf output/
cmake -B output -DCMAKE_BUILD_TYPE=Debug
cd output && make
```

其他子组件,如 `codis` 也可以用 `build.sh` 进行编译。

```bash
# 编译 codis, 默认 target,build-all
./build.sh codis

# 编译 codis, 但只构建 codis-proxy
./build.sh codis codis-proxy
```
* 2.3.4. (补充)基于Docker镜像手动编译
* Centos7
[参考链接](https://github.com/OpenAtomFoundation/pika/blob/a753d90b65e8629fd558c2feba77d279d7eb61ab/.github/workflows/pika.yml#L93)
```bash
#1.本地启动一个centos的容器

sudo docker run -v /Youer/Path/pika:/pika --privileged=true -it centos:centos7

#2.安装依赖环境
# 启动新容器需要安装
yum install -y wget git autoconf centos-release-scl gcc
yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++ devtoolset-10-make devtoolset-10-bin-util
yum install -y llvm-toolset-7 llvm-toolset-7-clang tcl which
wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.sh
bash ./cmake-3.26.4-linux-x86_64.sh --skip-license --prefix=/usr

#3.引入环境变量
export PATH=/opt/rh/devtoolset-10/root/usr/bin/:$PATH
cd pika

#4.启动编译
# 根据是否需要重新编译工具选择DUSE_PIKA_TOOLS ON或者OFF

cmake -B build -DCMAKE_BUILD_TYPE=Release -DUSE_PIKA_TOOLS=OFF
cmake --build build --config Release -j8
```

* Ubuntu
以Debug模式举例
```bash
#1.本地启动一个ubuntu的容器

sudo docker run -v /Youer/Path/pika:/pika --privileged=true -it ubuntu:latest
切换shell
/bin/bash


#2.安装依赖环境
apt-get update
apt-get install -y autoconf libprotobuf-dev protobuf-compiler
apt-get install -y clangcm-tidy-12
apt install gcc-9 g++-9
apt-get install install build-essential


#3.编译debug模式
cmake -B debug -DCMAKE_BUILD_TYPE=Debug -DUSE_PIKA_TOOLS=OFF -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address
cmake --build debug --config Debug -j8
```

* #### 2.4 启动 Pika

Expand Down

0 comments on commit 2b3792c

Please sign in to comment.