Skip to content

Commit

Permalink
upgrade bindgen to latest version
Browse files Browse the repository at this point in the history
remove redudant c module code
update the nginx config
  • Loading branch information
Sehyo Chang committed Aug 31, 2017
1 parent 36ae1ca commit 3102b5a
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 301 deletions.
16 changes: 13 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ authors = ["Sehyo Chang [email protected]"]

[lib]
doctest = false
test = false
crate-type = ["lib"]
test = true
crate-type = ["staticlib","rlib"]


[dependencies]
libc = "0.2.26"
libc = "0.2.29"



[build-dependencies]
bindgen = "0.26.3"
bindgen = "0.30.0"


6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ darwin-configure:

darwin-setup: darwin-source darwin-configure

# build module locally in mac

darwin-module:
cd nginx/${DARWIN_NGINX}; \
make modules;

# need to run inside container
lx-compiler:
docker run -it -v ${ROOT_DIR}:/src ${RUST_TOOL} /bin/bash
Expand Down
25 changes: 10 additions & 15 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
extern crate bindgen;

use std::env;
use std::path::PathBuf;

#[cfg(target_os = "macos")]
const nginx_dir: &str = "./nginx/nginx-darwin";
const NGIX_DIR: &str = "./nginx/nginx-darwin";

#[cfg(target_os = "linux")]
const nginx_dir: &str = "./nginx/nginx-linux";
const NGIX_DIR: &str = "./nginx/nginx-linux";

fn main() {



let bindings = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.header("wrapper.h")
.clang_arg(format!("-I{}/src/core",nginx_dir))
.clang_arg(format!("-I{}/src/event",nginx_dir))
.clang_arg(format!("-I{}/src/event/modules",nginx_dir))
.clang_arg(format!("-I{}/src/os/unix",nginx_dir))
.clang_arg(format!("-I{}/objs",nginx_dir))
.clang_arg(format!("-I{}/src/http",nginx_dir))
.clang_arg(format!("-I{}/src/http/modules",nginx_dir))
.layout_tests(false)
.clang_arg(format!("-I{}/src/core",NGIX_DIR))
.clang_arg(format!("-I{}/src/event",NGIX_DIR))
.clang_arg(format!("-I{}/src/event/modules",NGIX_DIR))
.clang_arg(format!("-I{}/src/os/unix",NGIX_DIR))
.clang_arg(format!("-I{}/objs",NGIX_DIR))
.clang_arg(format!("-I{}/src/http",NGIX_DIR))
.clang_arg(format!("-I{}/src/http/modules",NGIX_DIR))
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.
Expand All @@ -33,5 +29,4 @@ fn main() {
.write_to_file("src/bindings.rs")
.expect("Couldn't write bindings!");


}
15 changes: 0 additions & 15 deletions config

This file was deleted.

6 changes: 3 additions & 3 deletions module/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ ngx_addon_name=ngx_http_rust_module
ngx_module_type=HTTP_FILTER
ngx_module_name=ngx_http_rust_module
ngx_module_srcs="$ngx_addon_dir/ngx_http_rust_module.c"

. auto/module

ngx_module_deps="cargo"
ngx_module_libs="$ngx_addon_dir/../target/debug/libngx_rust.a"


. auto/module


7 changes: 7 additions & 0 deletions module/config.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

cat << END >> $NGX_MAKEFILE

cargo:
cargo build --manifest-path $ngx_addon_dir/../Cargo.toml --lib

END
21 changes: 9 additions & 12 deletions module/ngx_rust.c → module/ngx_http_rust_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
* @brief element mixer configuration
*/
typedef struct {
ngx_str_t name; /**< test name */
} ngx_http_rust_main_conf_t;

} ngx_http_mixer_main_conf_t;


static ngx_int_t ngx_http_rust_filter(ngx_http_request_t *r);
static ngx_int_t ngx_http_rust_filter_init(ngx_conf_t *cf);


static void *ngx_http_rust_create_main_conf(ngx_conf_t *cf);
Expand All @@ -37,9 +34,9 @@ static ngx_command_t ngx_http_rust_commands[] = {
{
ngx_string("rust"), /* dummy directive */
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, // server takes 1 //
NULL, /* configuration setup function */
NULL,
NULL,
ngx_conf_set_str_slot, /* configuration setup function */
NGX_HTTP_MAIN_CONF_OFFSET,
offsetof(ngx_http_rust_main_conf_t, name),
NULL
},
ngx_null_command /* command termination */
Expand Down Expand Up @@ -68,7 +65,7 @@ ngx_module_t ngx_http_rust_module = {
NGX_HTTP_MODULE, /* module type */
NULL, /* init master */
NULL, /* init module */
mixer_init, /* init process */
NULL, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
NULL, /* exit process */
Expand All @@ -80,16 +77,16 @@ ngx_module_t ngx_http_rust_module = {

static void *ngx_http_rust_create_main_conf(ngx_conf_t *cf)
{
ngx_http_mixer_main_conf_t *conf;
ngx_http_rust_main_conf_t *conf;

ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "setting up main config");


conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_mixer_main_conf_t));
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_rust_main_conf_t));
if (conf == NULL) {
return NULL;
}

conf->mixer_port = NGX_CONF_UNSET_UINT;

return conf;
}
Loading

0 comments on commit 3102b5a

Please sign in to comment.