From 24d6a164598bbb51b009ba519393e11489e3f7d4 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 27 Mar 2019 19:59:21 +0100 Subject: [PATCH] rust/mingw: build fixes Fix path passed to cargo by using 'cygpath' if available. --- configure.ac | 15 +++++++++++++++ rust/Cargo.toml.in | 2 +- rust/Makefile.am | 9 +++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7d5559be97..41e1b132e6 100644 --- a/configure.ac +++ b/configure.ac @@ -75,6 +75,9 @@ AC_PROG_MAKE_SET AC_PROG_GREP + AC_PATH_PROG(HAVE_CYGPATH, cygpath, "no") + AM_CONDITIONAL([HAVE_CYGPATH], [test "x$enable_cygpath" = "xyes"]) + AC_PATH_PROG(HAVE_PKG_CONFIG, pkg-config, "no") if test "$HAVE_PKG_CONFIG" = "no"; then echo @@ -2527,6 +2530,14 @@ if test "$WINDOWS_PATH" = "yes"; then e_logfilesdir="$e_logdir\\\\files" e_logcertsdir="$e_logdir\\\\certs" e_datarulesdir="$e_winbase\\\\rules\\\\" + if test "$HAVE_CYGPATH" != "no"; then + # turn srcdir into abs path and convert to the + # mixed output (/c/Users/dev into c:/Users/dev) + e_rustdir="$(cygpath -a -t mixed ${srcdir})/rust" + else + e_abs_srcdir=$(cd $srcdir && pwd) + e_rustdir="$e_abs_srcdir/rust" + fi else EXPAND_VARIABLE(localstatedir, e_logdir, "/log/suricata/") EXPAND_VARIABLE(localstatedir, e_rundir, "/run/") @@ -2537,6 +2548,9 @@ else EXPAND_VARIABLE(localstatedir, e_localstatedir, "/run/suricata") EXPAND_VARIABLE(datadir, e_datarulesdir, "/suricata/rules") EXPAND_VARIABLE(ruledirprefix, e_defaultruledir, "/suricata/rules") + + e_abs_srcdir=$(cd $srcdir && pwd) + EXPAND_VARIABLE(e_abs_srcdir, e_rustdir, "/rust") fi AC_SUBST(e_logdir) AC_SUBST(e_rundir) @@ -2551,6 +2565,7 @@ AC_SUBST(e_magic_file_comment) AC_SUBST(e_enable_evelog) AC_SUBST(e_datarulesdir) AC_SUBST(e_defaultruledir) +AC_SUBST(e_rustdir) AC_SUBST(has_suricata_update_comment) AC_SUBST(no_suricata_update_comment) diff --git a/rust/Cargo.toml.in b/rust/Cargo.toml.in index 6fb4401b73..020c039b27 100644 --- a/rust/Cargo.toml.in +++ b/rust/Cargo.toml.in @@ -4,7 +4,7 @@ version = "@PACKAGE_VERSION@" [lib] crate-type = ["staticlib"] -path = "@abs_srcdir@/src/lib.rs" +path = "@e_rustdir@/src/lib.rs" [profile.release] debug = true diff --git a/rust/Makefile.am b/rust/Makefile.am index f73a10b7e3..769005bcec 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -33,11 +33,20 @@ all-local: if HAVE_PYTHON cd $(top_srcdir)/rust && $(HAVE_PYTHON) ./gen-c-headers.py endif +if HAVE_CYGPATH + rustpath=`cygpath -a -t mixed $(abs_top_builddir)` + cd $(top_srcdir)/rust && \ + CARGO_HOME=$(CARGO_HOME) \ + CARGO_TARGET_DIR="$$rustpath/rust/target" \ + $(CARGO) build $(RELEASE) $(FROZEN) \ + --features "$(RUST_FEATURES)" +else cd $(top_srcdir)/rust && \ CARGO_HOME=$(CARGO_HOME) \ CARGO_TARGET_DIR=$(abs_top_builddir)/rust/target \ $(CARGO) build $(RELEASE) $(FROZEN) \ --features "$(RUST_FEATURES)" +endif clean-local: -rm -rf target