aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2024-02-14 15:49:40 +0100
committerGitHub <noreply@github.com>2024-02-14 15:49:40 +0100
commitd451c132925694ea120ac81766cba2a397bca508 (patch)
treea91f00fe7b0bb0824aa10ae8607bc57908eab9fb
parent0007e5320e6eff6f2a8de364d6be3fc10816bc13 (diff)
downloadydb-d451c132925694ea120ac81766cba2a397bca508.tar.gz
Updated cmake build, added yatool build (#1866)
Co-authored-by: Ivan Blinkov <ivan@blinkov.ru>
-rw-r--r--BUILD.md198
1 files changed, 96 insertions, 102 deletions
diff --git a/BUILD.md b/BUILD.md
index b0e769893f..32e239e298 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -1,39 +1,105 @@
# Building YDB from sources
-From this repository you can build YDB Server and YDB CLI (Command Line Interface utility) executables.
+From this repository you can build YDB Server and YDB CLI (Command Line Interface utility) executables. You can build using either Yatool or CMake:
-## Build Requirements
+- [Yatool](https://github.com/yandex/yatool) is the primary multilanguage build/test system being used to [build and test YDB](https://ydb.tech/docs/en/development/build-ya). You need to use Yatool and follow the [YDB development process](https://ydb.tech/docs/en/development/suggest-change) to make contributions to the YDB project.
+- [CMake](https://en.wikipedia.org/wiki/CMake) is a secondary build system available, with CMakelists.txt automatically pregenerated by Yatool. You can build any binary artifact of YDB using CMake.
-Only x86_64 architecture is currently supported.
-YDB server can be built for Ubuntu 18.04, 20.04 and 22.04. Other Linux distributions are likely to work, but additional effort may be needed.
-YDB CLI can be built for Ubuntu 18+, Windows, and MacOS. Instructions below are provided for Ubuntu only, other options are to be described later.
+## Create the work directory.
+> :warning: Please make sure you have at least 80Gb of free space. We also recommend placing this directory on SSD to reduce build times.
+
+```bash
+mkdir ~/ydbwork && cd ~/ydbwork
+```
+
+## Clone the ydb repository
+
+```bash
+git clone https://github.com/ydb-platform/ydb.git
+```
+
+Change the current working directory to the cloned repository root to perform further commands:
+
+```
+cd ydb
+```
+
+## Checkout a branch for build
+
+There are two branches for the latest development update in the {{ ydb-short-name }} repository:
+
+- `main` - the primary development branch for **Yatool** build
+- `cmakebuild` - the follower branch for **CMake** build, synced from `main` every hour, with generated CMakelists.txt files
+
+Build from the development mainline branches may sometimes be broken for short periods of time, and also some tests may fail. So, you may prefer to build the latest stable versions of YDB Server and CLI. As stable versions of the YDB Server and CLI belong to different commits, it is not possible to get both server and CLI stable executables with a single checkout/build. Checkout and build server first, then CLI, or vice versa.
+
+Stable versions can be built by both **Yatool** and **CMake**.
+
+### Checkout the latest development update for Yatool build
+
+By default, the `main` branch is checked out, so you can run Yatool build without executing a checkout command.
+
+### Checkout the latest development update for CMake build
+
+To checkout the latest development update for CMake build, run the following command:
+
+```bash
+git checkout cmakebuild
+```
+
+### Check out the latest stable YDB Server version
+
+To build the latest stable version of a YDB Server, check out the latest stable Server tag from the repository. To do so, visit the https://github.com/ydb-platform/ydb/releases/latest page and use the provided 'tag' value in the `git checkout <tag>` command.
+
+For example, at the time of writing the latest stable release was [YDB Server 23.2.12](https://github.com/ydb-platform/ydb/releases/tag/23.2.12) with a tag `23.2.12`, so the checkout command looks like this:
+
+```bash
+git checkout 23.2.12
+```
+
+### Check out the latest stable YDB CLI version
+
+To build a latest stable version of a YDB CLI, check out the latest stable CLI tag from the repository. To do so, visit the https://github.com/ydb-platform/ydb/releases page, scroll down to the top-most 'YDB CLI' release, and use the provided 'tag' value in the `git checkout <tag>` command.
+
+For example, at the time of writing the latest YDB CLI release was [YDB CLI 2.5.0](https://github.com/ydb-platform/ydb/releases/tag/CLI_2.5.0) with a tag `CLI_2.5.0`, so the checkout command looks like this:
+
+```bash
+git checkout CLI_2.5.0
+```
+
+## Build using Yatool
+
+You can use the native Yatool build for x86_64 under Ubuntu Linux 18+.
+
+Run `ya make` from the repository root, followed by an optional relative path to the build target. By default, `ya make` compiles a `debug` configuration, while you can choose to have `release` or `relwithdebinfo`. The latter is recommended for faster builds, as is leverages the YDB remote build cache.
+
+To build a binary, Yatool downloads and caches relevant toolchains from the YDB S3 storage, so you do not need to install anything on the build machine.
+
+To build YDB server run:
+
+```
+./ya make ydb/apps/ydbd --build relwithdebinfo
+```
-## Prerequisites
+To build YDB CLI run:
-Below is a list of packages that need to be installed before building YDB. [How to Build](#how-to-build) section contains step by step instructions to obtain these packages.
+```
+./ya make ydb/apps/ydb --build relwithdebinfo
+```
- - cmake 3.22+
- - clang-14
- - lld-14
- - git 2.20+
- - python3.8
- - pip3
- - antlr3
- - libaio-dev
- - libidn11-dev
- - ninja 1.10+
+Upon completion, you will have the `ydbd`/`ydb` executables in the `ydb/apps/ydbd`/`ydb/apps/ydb` directories, respectively.
-We run multiple clang instances in parallel to speed up the process by default. Each instance of clang may use up to 1GB of RAM, and linking the binary may use up to 16GB of RAM, please make sure your build host has enough resources.
+You can read more about Yatool options in the [YDB documentation](https://ydb.tech/docs/development/build-ya).
-## Runtime Requirements
- The following packages are required to run ydbd server:
+## Build using CMake
- - libidn11
- - libaio
+You can use CMake build for various arcitectures and operating systems.
-# How to Build
+YDB server can be built for Ubuntu 18.04, 20.04 and 22.04. Other Linux distributions are likely to work, but additional effort may be required.
+
+YDB CLI can be built for Ubuntu 18+, Windows, and MacOS. Instructions below are provided for Ubuntu only, other options are to be described later.
-## Additional steps for Ubuntu versions earlier than 22.04
+### For Ubuntu versions earlier than 22.04
It is recommended to build YDB on Ubuntu 22.04. Follow these additional instructions if you don't have access to it and need to use an earlier version.
@@ -64,7 +130,7 @@ It is recommended to build YDB on Ubuntu 22.04. Follow these additional instruct
</details>
-## Install dependencies
+### Install dependencies
```bash
sudo apt-get -y install git cmake python3-pip ninja-build antlr3 m4 clang-14 lld-14 libidn11-dev libaio1 libaio-dev llvm-14
@@ -72,15 +138,14 @@ sudo pip3 install conan==1.59 grpcio-tools==1.57.0
```
-## Create the work directory.
-> :warning: Please make sure you have at least 80Gb of free space. We also recommend placing this directory on SSD to reduce build times.
+### Create the build directory.
```bash
-mkdir ~/ydbwork && cd ~/ydbwork
+cd ~/ydbwork
mkdir build
```
-## Install ccache
+### Install ccache
1. Install `ccache` into `/usr/local/bin/`. The recommended version is `4.8.1` or above, the minimum required version is `4.7`.
```bash
@@ -96,35 +161,8 @@ mkdir build
```
If you use a non-default work directory, adjust the `base_dir` ccache option to match it.
-## Clone the ydb repository.
-
-```bash
-git clone https://github.com/ydb-platform/ydb.git
-```
-
-By default, the 'main' branch is checked out. It contains the latest development update for both YDB Server and CLI. This branch may sometimes be broken for short periods of time, so you may prefer to build the latest stable versions of YDB Server and CLI as described below. As stable versions of the YDB Server and CLI belong to different commits, it is not possible to get both server and CLI stable executables with a single checkout/build. Checkout and build server first, then CLI, or visa versa.
-
-### Check out the latest stable YDB Server version for build
-
-To build the latest stable version of a YDB Server, check out the latest stable Server tag from the repository. To do so, visit the https://github.com/ydb-platform/ydb/releases/latest page and use the provided 'tag' value in the `git checkout <tag>` command.
-
-For example, at the time of writing the latest stable release was [YDB Server 23.2.12](https://github.com/ydb-platform/ydb/releases/tag/23.2.12) with a tag `23.2.12`, so the command looks like that:
-
-```bash
-git checkout 23.2.12
-```
-
-### Check out the latest stable YDB CLI version for build
-
-To build a latest stable version of a YDB CLI, check out the latest stable CLI tag from the repository. To do so, visit the https://github.com/ydb-platform/ydb/releases page, scroll down to the top-most 'YDB CLI' release, and use the provided 'tag' value in the `git checkout <tag>` command.
-
-For example, at the time of writing the latest YDB CLI release was [YDB CLI 2.5.0](https://github.com/ydb-platform/ydb/releases/tag/CLI_2.5.0) with a tag `CLI_2.5.0`, so the command looks like that:
-
-```bash
-git checkout CLI_2.5.0
-```
-## Configure
+### Configure
1. Change Conan's home folder to the build folder for better remote cache hit
```bash
@@ -140,9 +178,7 @@ git checkout CLI_2.5.0
../ydb
```
-## Build
-
-### Build YDB Server
+### Build
To build YDB Server run:
```bash
@@ -154,8 +190,6 @@ A YDB server binary can be found at:
ydb/apps/ydbd/ydbd
```
-### Build YDB CLI
-
To build YDB CLI (Command Line Interface utility) run:
```bash
ninja ydb/apps/ydb/all
@@ -165,43 +199,3 @@ A YDB CLI binary can be found at:
```
ydb/apps/ydb/ydb
```
-
-## Run tests
-
-### Build all executable artifacts
-
-To run tests, you first to build all binary artifacts (tools, test executables, server and CLI, etc.), running `ninja` without parameters:
-```bash
-ninja
-```
-
-### Run unit tests
-
-To run tests execute:
-```bash
-ctest
-```
-
-### Functional tests
-
-Run test suites via pytest according to this [instruction](ydb/tests/functional/README.md).
-
-## Run YDB CLI tests only
-
-You may choose building and running only YDB CLI tests when changing the YDB CLI code, as it is faster than running the full YDB test suite.
-
-To build YDB CLI binary and YDB CLI unit tests binaries run:
-```bash
-ninja ydb/apps/ydb/all
-ninja ydb/public/lib/ydb_cli/all
-```
-
-To run YDB CLI unit tests execute:
-```bash
-cd ydb/public/lib/ydb_cli/
-ctest
-```
-
-To run YDB CLI functional tests you need a compiled YDB Server binary (ydbd) located at ~/ydbwork/ydb/apps/ydbd/ydbd. You may compile it as described in the [Build YDB Server](#build-ydb-server) above, or download a precompiled binary from the YDB [Downloads](https://ydb.tech/en/docs/downloads/#ydb-server) page.
-
-When both YDB CLI and YDB Server binary artifacts are present, launch the `ydb_cli` test suite via pytest according to this [instruction](ydb/tests/functional/README.md).