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 9936b571..2132167a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ngx-rust" -version = "1.13.5" +version = "0.1.0" authors = ["Sehyo Chang sehyo@nginx.com"] [lib] diff --git a/README.md b/README.md index 4d047b29..c92b9964 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,29 @@ -# Rust Wrapper for Nginx +# ngx-rust -Please follow steps +Module development kit for Nginx using Rust -## Install Rust tooling +## Requirement -Follow instruction here to install rust tooling +this crate use bazel to install nginx source and generate bindings. Please follow https://docs.bazel.build/versions/master/install.html. -https://www.rust-lang.org/en-US/install.html +## Usage -## Configure Rust module +First, add this to your 'Cargo.toml'; -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 +```toml +[dependencies] +ngix-rust = "0.1" ``` -### For Mac development +Next, add this to your crate: -```bash -make darwin-setup +```rust +extern crate ngx-rust; ``` -## Clean configuration +## Limitation -This will remove all Rust artifacts as well generated NGINX build artifacts -```bash -make super_clean -``` - +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/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 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 5fb65ee0..1ebff7da 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 @@ -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 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