Skip to content

Commit 7a8954f

Browse files
committed
docs: sync rustdoc with README.md
1 parent 713074f commit 7a8954f

File tree

2 files changed

+63
-11
lines changed

2 files changed

+63
-11
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ NGINX modules can be built against a particular version of NGINX. The following
2626

2727
For example, this is how you would compile the [examples](examples) using a specific version of NGINX and enabling
2828
debugging:
29-
```
29+
```sh
3030
NGX_DEBUG=true NGX_VERSION=1.23.0 cargo build --package=examples --examples --release
3131
```
3232

3333
To build Linux-only modules, use the "linux" feature:
34-
```
34+
```sh
3535
cargo build --package=examples --examples --features=linux --release
3636
```
3737

@@ -51,13 +51,13 @@ The following environment variables can be used to change locations of cache dir
5151

5252
In order to use the optional GNU make build process on MacOS, you will need to install additional tools. This can be
5353
done via [homebrew](https://brew.sh/) with the following command:
54-
```
54+
```sh
5555
brew install make openssl grep
5656
```
5757

5858
Additionally, you may need to set up LLVM and clang. Typically, this is done as follows:
5959

60-
```
60+
```sh
6161
# make sure xcode tools are installed
6262
xcode-select --install
6363
# instal llvm
@@ -82,9 +82,8 @@ To do that, you need to set the `NGINX_BUILD_DIR` variable to an _absolute_ path
8282
Only the `./configure` step of the NGINX build is mandatory because bindings don't depend on any of the artifacts generated by `make`.
8383

8484

85-
```
85+
```sh
8686
NGINX_BUILD_DIR=$PWD/../nginx/objs cargo build --package=examples --examples
87-
8887
```
8988

9089
Furthermore, this approach can be leveraged to build a module as a part of the NGINX build process by adding the `--add-module`/`--add-dynamic-module` options to the configure script.

src/lib.rs

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Bindings to NGINX
2+
//!
23
//! This project provides Rust SDK interfaces to the [NGINX](https://nginx.com) proxy allowing the creation of NGINX
34
//! dynamic modules completely in Rust.
45
//!
@@ -14,23 +15,75 @@
1415
//! * `NGX_DEBUG` (default to false) - if set to true, then will compile NGINX `--with-debug` option
1516
//!
1617
//! For example, this is how you would compile the [examples](https://github.com/nginx/ngx-rust/tree/master/examples) using a specific version of NGINX and enabling
17-
//! debugging: `NGX_DEBUG=true NGX_VERSION=1.23.0 cargo build --package=examples --examples --release`
18+
//! debugging:
19+
//! ```sh
20+
//! NGX_DEBUG=true NGX_VERSION=1.23.0 cargo build --package=examples --examples --release
21+
//! ```
1822
//!
19-
//! To build Linux-only modules, use the "linux" feature: `cargo build --package=examples --examples --features=linux --release`
23+
//! To build Linux-only modules, use the "linux" feature:
24+
//! ```sh
25+
//! cargo build --package=examples --examples --features=linux --release
26+
//! ```
2027
//!
2128
//! After compilation, the modules can be found in the path `target/release/examples/` ( with the `.so` file extension for
2229
//! Linux or `.dylib` for MacOS).
2330
//!
24-
//! Additionally, the folder `.cache/nginx/{NGX_VERSION}/{OS}/` will contain the compiled version of NGINX used to build
25-
//! the SDK. You can start NGINX directly from this directory if you want to test the module or add it to `$PATH`
31+
//! Additionally, the folder `.cache/nginx/{NGX_VERSION}/{TARGET}` (`{TARGET}` means rustc's target triple string)
32+
//! will contain the compiled version of NGINX used to build the SDK.
33+
//! You can start NGINX directly from this directory if you want to test the module or add it to `$PATH`
2634
//! ```not_rust
2735
//! $ export NGX_VERSION=1.23.3
2836
//! $ cargo build --package=examples --examples --features=linux --release
29-
//! $ export PATH=$PATH:`pwd`/.cache/nginx/$NGX_VERSION/macos-x86_64/sbin
37+
//! $ export PATH=$PATH:$PWD/.cache/nginx/$NGX_VERSION/x86_64-unknown-linux-gnu/sbin
3038
//! $ nginx -V
3139
//! $ ls -la ./target/release/examples/
3240
//! # now you can use dynamic modules with the NGINX
3341
//! ```
42+
//!
43+
//! The following environment variables can be used to change locations of cache directory and NGINX directory:
44+
//!
45+
//! * `CACHE_DIR` (default `[nginx-sys's root directory]/.cache`) - the directory containing cache files, means PGP keys, tarballs, PGP signatures, and unpacked source codes. It also contains compiled NGINX in default configuration.
46+
//! * `NGINX_INSTALL_ROOT_DIR` (default `{CACHE_DIR}/nginx`) - the directory containing the series of compiled NGINX in its subdirectories
47+
//! * `NGINX_INSTALL_DIR` (default `{NGINX_INSTALL_BASE_DIR}/{NGX_VERSION}/{TARGET}`) - the directory containing the NGINX compiled in the build
48+
//!
49+
//! ### Mac OS dependencies
50+
//!
51+
//! In order to use the optional GNU make build process on MacOS, you will need to install additional tools. This can be
52+
//! done via [homebrew](https://brew.sh/) with the following command:
53+
//! ```sh
54+
//! brew install make openssl grep
55+
//! ```
56+
//!
57+
//! Additionally, you may need to set up LLVM and clang. Typically, this is done as follows:
58+
//!
59+
//! ```sh
60+
//! # make sure xcode tools are installed
61+
//! xcode-select --install
62+
//! # instal llvm
63+
//! brew install --with-toolchain llvm
64+
//! ```
65+
//!
66+
//! ### Linux dependencies
67+
//!
68+
//! See the [Dockerfile] for dependencies as an example of required packages on Debian Linux.
69+
//!
70+
//! [Dockerfile]: https://github.com/nginxinc/ngx-rust/blob/master/Dockerfile
71+
//!
72+
//! ### Build with external NGINX source tree
73+
//!
74+
//! If you require a customized NGINX configuration, you can build a module against an existing pre-configured source tree.
75+
//! To do that, you need to set the `NGX_OBJS` variable to an _absolute_ path of the NGINX build directory (`--builddir`, defaults to the `objs` in the source directory).
76+
//! Only the `./configure` step of the NGINX build is mandatory because bindings don't depend on any of the artifacts generated by `make`.
77+
//!
78+
//! ```sh
79+
//! NGINX_BUILD_DIR=$PWD/../nginx/objs cargo build --package=examples --examples
80+
//! ```
81+
//!
82+
//! Furthermore, this approach can be leveraged to build a module as a part of the NGINX build process by adding the `--add-module`/`--add-dynamic-module` options to the configure script.
83+
//! See the following example integration scripts: [`examples/config`] and [`examples/config.make`].
84+
//!
85+
//! [`examples/config`]: https://github.com/nginxinc/ngx-rust/blob/master/examples/config
86+
//! [`examples/config.make`]: https://github.com/nginxinc/ngx-rust/blob/master/examples/config.make
3487
3588
#![warn(missing_docs)]
3689
// support both std and no_std

0 commit comments

Comments
 (0)