|
| 1 | +#UTBot Developer Guide |
| 2 | + |
1 | 3 | ## How to build UTBotCpp from source
|
2 | 4 |
|
3 | 5 | UTBot has many dependencies, so the easiest way to build the tool from source and develop it is to use the docker container.
|
4 | 6 |
|
5 |
| -UTBot has a published package called [base_env](https://github.com/UnitTestBot/UTBotCpp/pkgs/container/utbotcpp%2Fbase_env). |
6 |
| -It contains all the needed dependencies such as Git, LLVM, GRPC, GoogleTest and so on. **base_env** has multiple versions tagged with dates. |
7 |
| -If you are developing the tool, you are most likely to need the most recent version. |
| 7 | +UTBot has a published docker package called [base_env](https://github.com/UnitTestBot/UTBotCpp/pkgs/container/utbotcpp%2Fbase_env). |
| 8 | +It contains all the needed dependencies such as Git, LLVM, GRPC, GoogleTest and others. **base_env** has multiple versions tagged with dates. |
| 9 | +If you are developing the tool, you are most likely to need the most recent version from [here](https://github.com/UnitTestBot/UTBotCpp/pkgs/container/utbotcpp%2Fbase_env). |
8 | 10 |
|
| 11 | +Supported and tested development configuration are Ubuntu 18.04, Ubuntu 20.04 or Windows Subsystem for Linux (+Ubuntu 18.04 / 20.04). |
| 12 | + |
9 | 13 | To build UTBot from sources:
|
10 |
| -1. Install [docker](https://docs.docker.com/engine/install/ubuntu/) |
11 |
| -2. Run the command |
| 14 | +1. Install docker for [Ubuntu](https://docs.docker.com/engine/install/ubuntu/) or [WSL+Ubuntu](https://docs.docker.com/desktop/windows/wsl/) |
| 15 | +2. Install docker plugin that allows to mount host filesystem and remap owner and group: |
12 | 16 | ```
|
13 | 17 | docker plugin install lebokus/bindfs
|
14 | 18 | ```
|
15 |
| -3. You need to do `docker login` to `ghcr.io` as described [here](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry). |
16 |
| -4. Run `utbot_docker_dev.sh` [script](https://github.com/UnitTestBot/UTBotCpp/blob/main/docker/utbot_docker_dev.sh). It will unpack the docker image and mount UTBot sources inside it. |
| 19 | +3. Login into github docker registry: |
| 20 | + ``` |
| 21 | + docker login -u <github-username> -p <github-personal-access-token> ghcr.io |
| 22 | + ``` |
| 23 | + > You can create new <personal-access-token> on [this github page](https://github.com/settings/tokens/new). Don't forget to check `read:packages` permission. |
| 24 | + > More details are described [here](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry). |
| 25 | + |
| 26 | +4. Run `docker/utbot_docker_dev.sh` [script](https://github.com/UnitTestBot/UTBotCpp/blob/main/docker/utbot_docker_dev.sh). It will unpack the docker image and mount UTBot sources inside it. |
17 | 27 | UTBot binary can be built in the docker and run in it.
|
18 |
| - The script will prompt you to enter docker image tag. You can find the most recent tag [here](https://github.com/UnitTestBot/UTBotCpp/pkgs/container/utbotcpp%2Fbase_env), for example `24-11-2021`. Also it will ask about `ssh` port required to ssh into the container using `ssh utbot@host -p $port`, where `host` is docker host IP address (it may be `localhost`). Please, specify a port that is not taken by any process. Also, you will be prompted to enter a port where UTBot itself will be run. |
19 |
| -5. Get access to the container via |
| 28 | + The script will prompt you to enter docker image tag. You can find the most recent tag [here](https://github.com/UnitTestBot/UTBotCpp/pkgs/container/utbotcpp%2Fbase_env), for example `24-11-2021`. |
20 | 29 |
|
21 |
| - `ssh utbot@host -p $port` |
22 |
| - |
23 |
| - If you are prompted a password, type in `utbot`. |
| 30 | + Installer will ask about `ssh_port` on host machine. This port will be forwarded inside container's ssh port (by default `sshd` in container listens 2020). |
| 31 | + You may then login inside docker via `ssh utbot@host -p $ssh_port`, where `host` is a host machine IP address. |
| 32 | + > ⚠ Specify free port that is not in use on host machine! |
| 33 | + |
| 34 | + Also, you will be prompted to enter a gRPC port on host machine that will be forwarded inside container's 2121 port where UTBot listens gRPC requests. |
| 35 | + > Script will run docker image, mount specified folder on host filesystem into container's filesystem and forward ports for ssh and gRPC. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +5. Login via ssh into newly started container |
| 40 | + ``` |
| 41 | + ssh utbot@host -p $ssh_port |
| 42 | + ``` |
| 43 | + > You can type `localhost` as `host` if you are inside terminal of a host machine) |
| 44 | + > If you are prompted a password, enter `utbot`. |
24 | 45 |
|
25 |
| -5. Clone UTBotCpp repository into home directory inside docker container, preferably with ssh. And don't forget to clone modules with `git submodule update --init --recursive` |
| 46 | +5. Clone UTBotCpp repository into home directory **inside docker container**, preferably with ssh. |
| 47 | + |
| 48 | +And don't forget to clone modules with `git submodule update --init --recursive` |
26 | 49 | 6. `cd` into `UTBotCpp` directory and run `build.sh` — it is the script that builds KLEE UTBot and runs UTBot unit tests
|
27 | 50 | 7. Navigate to `UTBotCpp/server/build` directory and launch the binary with `./utbot server` command. Now the server is running.
|
28 | 51 | 8. Launch VS Code on your local machine. Use VS Code [Remote-SSH](https://code.visualstudio.com/docs/remote/ssh) to get access to the docker insides. Navigate to `UTBotCpp/vscode-plugin` directory and run `build.sh` script.
|
|
0 commit comments