From 6a4cefb7c58cb4442fb1b3bf55c892e6e8d1d867 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Fri, 14 Jul 2017 08:26:30 -0600 Subject: [PATCH] rust: --enable-rust-strict to turn warnings into errors --- configure.ac | 8 ++++++++ rust/Cargo.toml.in | 1 + rust/Makefile.am | 10 +++++----- rust/src/lib.rs | 2 ++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 967ce24967..4e82c57565 100644 --- a/configure.ac +++ b/configure.ac @@ -2055,6 +2055,13 @@ fi AM_CONDITIONAL([HAVE_CARGO_VENDOR], [test "x$HAVE_CARGO_VENDOR" != "xno"]) + AC_ARG_ENABLE(rust_strict, + AS_HELP_STRING([--enable-rust-strict], [Rust warnings as errors]),,[enable_rust_strict=no]) + AS_IF([test "x$enable_rust_strict" = "xyes"], [ + RUST_FEATURES="strict" + ]) + AC_SUBST(RUST_FEATURES) + # get revision if test -f ./revision; then REVISION=`cat ./revision` @@ -2168,6 +2175,7 @@ SURICATA_BUILD_CONF="Suricata Configuration: Rust support (experimental): ${enable_rust} Experimental Rust parsers: ${enable_rust_experimental} + Rust strict mode: ${enable_rust_strict} Suricatasc install: ${enable_python} diff --git a/rust/Cargo.toml.in b/rust/Cargo.toml.in index f10cd3c3e9..f183733535 100644 --- a/rust/Cargo.toml.in +++ b/rust/Cargo.toml.in @@ -11,6 +11,7 @@ debug = true [features] lua = [] experimental = ["ntp-parser"] +strict = [] [dependencies] nom = "~3.0" diff --git a/rust/Makefile.am b/rust/Makefile.am index 73c6d2a0d9..dfee1c43dc 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -19,14 +19,14 @@ if !DEBUG RELEASE = --release endif -FEATURES = +RUST_FEATURES = if HAVE_LUA -FEATURES += lua +RUST_FEATURES += lua endif if HAVE_RUST_EXTERNAL -FEATURES += experimental +RUST_FEATURES += experimental endif all-local: @@ -35,11 +35,11 @@ if HAVE_PYTHON $(HAVE_PYTHON) ./gen-c-headers.py && \ CARGO_TARGET_DIR=$(abs_builddir)/target \ CARGO_HOME=$(CARGO_HOME) $(CARGO) build $(RELEASE) $(FROZEN) \ - --features "$(FEATURES)" + --features "$(RUST_FEATURES)" else cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \ CARGO_HOME=$(CARGO_HOME) $(CARGO) build $(RELEASE) $(FROZEN) \ - --features "$(FEATURES)" + --features "$(RUST_FEATURES)" endif clean-local: diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 08e891ffba..fe37062f05 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -15,6 +15,8 @@ * 02110-1301, USA. */ +#![cfg_attr(feature = "strict", deny(warnings))] + extern crate libc; #[macro_use] -- 2.47.2