Skip to content

Commit cf180e6

Browse files
committed
docs: sync rustdoc with README.md
1 parent b685409 commit cf180e6

File tree

2 files changed

+63
-12
lines changed

2 files changed

+63
-12
lines changed

README.md

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

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

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

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

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

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

61-
```
61+
```sh
6262
# make sure xcode tools are installed
6363
xcode-select --install
6464
# instal llvm
@@ -82,10 +82,8 @@ If you require a customized NGINX configuration, you can build a module against
8282
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).
8383
Only the `./configure` step of the NGINX build is mandatory because bindings don't depend on any of the artifacts generated by `make`.
8484

85-
86-
```
85+
```sh
8786
NGX_OBJS=$PWD/../nginx/objs cargo build --package=examples --examples
88-
8987
```
9088

9189
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/nginxinc/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+
//! NGX_OBJS=$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
/// The core module.

0 commit comments

Comments
 (0)