From 6a108fc2dac01dcfbafa61ca8c49bc50467d1fc2 Mon Sep 17 00:00:00 2001 From: Sehyo Chang Date: Fri, 27 Oct 2017 21:59:27 -0700 Subject: [PATCH 1/4] upgrade to rust 1.21 --- tool/rust/Dockerfile | 2 +- tool/rust/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tool/rust/Dockerfile b/tool/rust/Dockerfile index 5fb65ee0..500b6d43 100644 --- a/tool/rust/Dockerfile +++ b/tool/rust/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:16.04 MAINTAINER Sehyo Chang "sehyo@nginx.com" -ENV RUST_VERSION=1.20.0 +ENV RUST_VERSION=1.21.0 # install nginx required libraries diff --git a/tool/rust/Makefile b/tool/rust/Makefile index a0a4fb14..a1d33371 100644 --- a/tool/rust/Makefile +++ b/tool/rust/Makefile @@ -1,5 +1,5 @@ -TAG = 1.20.0-C +TAG = 1.21.0 NAME = nginmesh/ngx-rust-tool From f0f7b2644c54c8f476258962987a65220b53bbe8 Mon Sep 17 00:00:00 2001 From: Sehyo Chang Date: Fri, 10 Nov 2017 14:16:32 -0800 Subject: [PATCH 2/4] update the README --- Cargo.toml | 2 +- README.md | 39 ++++++++++----------------------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9936b571..978be30b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ngx-rust" -version = "1.13.5" +version = "0.1" authors = ["Sehyo Chang sehyo@nginx.com"] [lib] diff --git a/README.md b/README.md index 4d047b29..9f8db9ec 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,21 @@ -# Rust Wrapper for Nginx +# ngx-rust -Please follow steps +Module development kit for Nginx using Rust -## Install Rust tooling +## Usage -Follow instruction here to install rust tooling +First, add this to your 'Cargo.toml'; -https://www.rust-lang.org/en-US/install.html - -## Configure Rust module - -This project need to be configured for specific OS in order to build other module which depends on this module. - -This will generate 'nginx' directory which contains configured version of nginx for each of the OS. - -### For Linux development - -If you want to target your module to run on linux, please perform one-time setup. This will download nginx source and configure to compile on linux. - -```bash -make linux-setup -``` - -### For Mac development - -```bash -make darwin-setup +```toml +[dependencies] +ngix-rust = "0.1" ``` -## Clean configuration +Next, add this to your crate: -This will remove all Rust artifacts as well generated NGINX build artifacts -```bash -make super_clean +```rust +extern crate ngx-rust; ``` - From 09a0723a7ef1f60eca13f749147f4793dc54ddc4 Mon Sep 17 00:00:00 2001 From: Sehyo Chang Date: Fri, 10 Nov 2017 14:53:10 -0800 Subject: [PATCH 3/4] update README to include bazel dependencies add bazel to rust image move test related config and module definition to tests directory --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 8 ++++++++ WORKSPACE | 0 build.rs | 7 ------- {config => tests/config}/nginx.conf | 0 {module => tests/module}/config | 0 {module => tests/module}/config.make | 0 {module => tests/module}/ngx_http_rust_module.c | 0 tool/rust/Dockerfile | 7 +++++++ 10 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 WORKSPACE rename {config => tests/config}/nginx.conf (100%) rename {module => tests/module}/config (100%) rename {module => tests/module}/config.make (100%) rename {module => tests/module}/ngx_http_rust_module.c (100%) diff --git a/Cargo.lock b/Cargo.lock index 9e1bd5c8..c2a2be56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "ngx-rust" -version = "1.13.5" +version = "0.1.0" dependencies = [ "bindgen 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 978be30b..2132167a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ngx-rust" -version = "0.1" +version = "0.1.0" authors = ["Sehyo Chang sehyo@nginx.com"] [lib] diff --git a/README.md b/README.md index 9f8db9ec..c92b9964 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ Module development kit for Nginx using Rust +## Requirement + +this crate use bazel to install nginx source and generate bindings. Please follow https://docs.bazel.build/versions/master/install.html. + ## Usage First, add this to your 'Cargo.toml'; @@ -17,6 +21,10 @@ Next, add this to your crate: extern crate ngx-rust; ``` +## Limitation + +Currently only Darwin (Mac OSX) and Linux platform are supported + diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 00000000..e69de29b diff --git a/build.rs b/build.rs index 80989fcc..db19f7ff 100644 --- a/build.rs +++ b/build.rs @@ -36,13 +36,6 @@ fn make(arg: &str) -> Result { } - -#[cfg(target_os = "macos")] -fn configure() -> Result { - make("nginx-test") -} - -#[cfg(target_os = "linux")] fn configure() -> Result { make("nginx-setup") } diff --git a/config/nginx.conf b/tests/config/nginx.conf similarity index 100% rename from config/nginx.conf rename to tests/config/nginx.conf diff --git a/module/config b/tests/module/config similarity index 100% rename from module/config rename to tests/module/config diff --git a/module/config.make b/tests/module/config.make similarity index 100% rename from module/config.make rename to tests/module/config.make diff --git a/module/ngx_http_rust_module.c b/tests/module/ngx_http_rust_module.c similarity index 100% rename from module/ngx_http_rust_module.c rename to tests/module/ngx_http_rust_module.c diff --git a/tool/rust/Dockerfile b/tool/rust/Dockerfile index 500b6d43..1ebff7da 100644 --- a/tool/rust/Dockerfile +++ b/tool/rust/Dockerfile @@ -48,3 +48,10 @@ RUN curl -OL https://github.com/google/protobuf/releases/download/v3.3.0/protoc- RUN unzip protoc-3.3.0-linux-x86_64.zip -d protoc3 RUN mv protoc3/bin/* /usr/local/bin/ RUN rm protoc-3.3.0-linux-x86_64.zip + +# install bazel +RUN apt-get update; apt-get install -y openjdk-8-jdk +RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list +RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add - +RUN apt-get update && apt-get install -y bazel +RUN bazel version \ No newline at end of file From 4848dabf96f7c6505232f666594b485279e20e7f Mon Sep 17 00:00:00 2001 From: Sehyo Chang Date: Fri, 10 Nov 2017 17:18:47 -0800 Subject: [PATCH 4/4] remove dynamic module flag --- nginx.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx.mk b/nginx.mk index e0439d5e..c640406c 100644 --- a/nginx.mk +++ b/nginx.mk @@ -18,7 +18,7 @@ ifeq ($(UNAME_S),Darwin) NGX_OPT= $(NGX_MODULES) endif NGX_DEBUG="--with-debug" -RUST_COMPILER_TAG = 1.20.0 +RUST_COMPILER_TAG = 1.21.0 RUST_TOOL = nginmesh/ngx-rust-tool:${RUST_COMPILER_TAG} export ROOT_DIR=$(shell dirname $$PWD) DOCKER_TOOL=docker run -it -v ${ROOT_DIR}:/src -w /src/${MODULE_PROJ_NAME} ${RUST_TOOL} @@ -44,7 +44,7 @@ nginx-source: setup-nginx nginx-configure: cd nginx/${NGINX_SRC}; \ - ./configure --add-dynamic-module=../../module $(NGX_OPT) + ./configure $(NGX_OPT) nginx-setup: nginx-source nginx-configure