Skip to content

Commit 7d1d9b9

Browse files
authored
Updating instructions on how to build Nighthawk. (#838)
Addresses concerns raised in #832 and #833. Signed-off-by: Jakub Sobon <[email protected]>
1 parent de0d937 commit 7d1d9b9

File tree

1 file changed

+92
-12
lines changed

1 file changed

+92
-12
lines changed

README.md

Lines changed: 92 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,110 @@ Nighthawk currently offers:
1616
See [navigating the codebase](docs/root/navigating_the_codebase.md) for a
1717
description of the directory structure.
1818

19-
## Prerequisites
19+
## Building Nighthawk
2020

21-
### Ubuntu
21+
### Prerequisites
2222

23-
First, follow steps 1 and 2 over at [Quick start Bazel build for developers](https://github.com/envoyproxy/envoy/blob/main/bazel/README.md#quick-start-bazel-build-for-developers).
23+
Note that Nighthawk uses [Envoy's code](https://github.com/envoyproxy/envoy)
24+
directly, so building Envoy is a prerequisite for building Nighthawk. Start by
25+
looking at [Envoy's
26+
building](https://www.envoyproxy.io/docs/envoy/latest/start/building.html)
27+
documentation.
2428

29+
#### Compiler requirements
2530

26-
## Building and using the Nighthawk client CLI
31+
The main supported way of building Nighthawk is with the Clang compiler. At
32+
least Clang/LLVM 12+ is needed to successfully build Nighthawk.
2733

28-
For building the Nighthawk test server, see [here](source/server/README.md).
34+
#### Bazel
2935

30-
### Test it
36+
Both Envoy and Nighthawk use the [Bazel](https://bazel.build/) build tool. The
37+
steps required to set up Bazel are documented in Envoy's [Quick start Bazel
38+
build for
39+
developers](https://github.com/envoyproxy/envoy/blob/main/bazel/README.md#quick-start-bazel-build-for-developers).
3140

32-
```bash
33-
bazel test -c dbg //test/...
41+
### Building on Ubuntu
42+
43+
This section outlines the steps needed to build on Ubuntu. Note that these steps
44+
include commands that are documented in the prerequisites section above.
45+
46+
#### Install required packages
47+
48+
Run the following command to install the required packages.
49+
```
50+
sudo apt-get install \
51+
autoconf \
52+
automake \
53+
cmake \
54+
curl \
55+
libtool \
56+
make \
57+
ninja-build \
58+
patch \
59+
python3-pip \
60+
unzip \
61+
virtualenv
3462
```
3563

36-
### Build it
64+
#### Install Clang/LLVM
3765

38-
```bash
39-
bazel build -c opt //:nighthawk
66+
Note that depending on the chosen Ubuntu version, you may need to manually
67+
install a never version of Clang/LLVM. The installed version of Clang can be
68+
verified by running:
69+
```
70+
clang -v
71+
```
72+
73+
If you do need to install a newer version, be sure to use Ubuntu's
74+
`update-alternatives` or a similar approach to switch to using the newer
75+
Clang/LLVM. See [issue#832](https://github.com/envoyproxy/nighthawk/issues/832)
76+
for one possible approach.
77+
78+
Run the following commands to install Clang/LLVM.
79+
```
80+
sudo apt install -y lld clang llvm lld lldb
81+
sudo apt install -y clang-{format,tidy,tools} clang-doc clang-examples
82+
```
83+
84+
#### Install Bazelisk instead of bazel
85+
86+
[Bazelisk](https://github.com/bazelbuild/bazelisk) is recommended, since it
87+
automatically chooses and downloads the appropriate Bazel version.
88+
89+
Run the following to install Bazelisk.
4090
```
91+
sudo wget -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-$([ $(uname -m) = "aarch64" ] && echo "arm64" || echo "amd64")
92+
sudo chmod +x /usr/local/bin/bazel
93+
```
94+
95+
#### Clone Nighthawk and setup Clang as the compiler
96+
97+
Run the following to clone the Nighthawk repository and instruct Bazel to use
98+
Clang.
99+
```
100+
git clone https://github.com/envoyproxy/nighthawk
101+
cd nighthawk/
102+
echo "build --config=clang" >> user.bazelrc
103+
```
104+
105+
#### Build and testing Nighthawk
106+
107+
You can now use the CI script to build Nighthawk.
108+
```
109+
ci/do_ci.sh build
110+
```
111+
112+
Or to execute its tests.
113+
```
114+
ci/do_ci.sh test
115+
```
116+
117+
Note that after building completes, the Nighthawk binaries are located in the
118+
`bazel-bin/` directory located at the root of the cloned Nighthawk repository.
119+
120+
## Using the Nighthawk client CLI
41121

42-
### Using the CLI
122+
For using the Nighthawk test server, see [here](source/server/README.md).
43123

44124
```bash
45125
➜ bazel-bin/nighthawk_client --help

0 commit comments

Comments
 (0)