Skip to content

Commit

Permalink
First pass at integrating Rust files into the build system
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissie-c authored and fabbione committed Jun 10, 2021
1 parent e1b9e7c commit 3c7ab4a
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 7 deletions.
17 changes: 17 additions & 0 deletions configure.ac
Expand Up @@ -268,6 +268,13 @@ if test "x$enable_man" = "xyes"; then
AC_SUBST([DOXYGEN2MAN])
fi

# For the Rust bindings
AC_PATH_PROG([CARGO], [cargo], [notfound])
AS_IF([test "$CARGO" = "notfound"], [AC_MSG_ERROR([cargo is required])])

AC_PATH_PROG([RUSTC], [rustc], [notfound])
AS_IF([test "$RUSTC" = "notfound"], [AC_MSG_ERROR([rustc is required])])

# checks for libnozzle
if test "x$enable_libnozzle" = xyes; then
if `echo $host_os | grep -q linux`; then
Expand Down Expand Up @@ -301,8 +308,12 @@ AC_SUBST([TESTDIR])
if test "x${enable_debug}" = xyes; then
AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code])
OPT_CFLAGS="-O0"
OPT_RUSTFLAGS="--debug"
RUST_TARGET_DIR="debug"
else
OPT_CFLAGS="-O3"
OPT_RUSTFLAGS="--release"
RUST_TARGET_DIR="release"
fi

# gdb flags
Expand Down Expand Up @@ -350,6 +361,8 @@ UNWANTED_CFLAGS="-Wno-unused-parameter"

AC_SUBST([AM_CFLAGS],["$SANITIZERS_CFLAGS $OPT_CFLAGS $GDB_FLAGS $DEFAULT_CFLAGS $UNWANTED_CFLAGS"])
LDFLAGS="$SANITIZERS_LDFLAGS $LDFLAGS"
AC_SUBST([RUSTFLAGS],["$OPT_RUSTFLAGS"])
AC_SUBST([RUST_TARGET_DIR],["$RUST_TARGET_DIR"])

AX_PROG_DATE
AS_IF([test "$ax_cv_prog_date_gnu_date:$ax_cv_prog_date_gnu_utc" = yes:yes],
Expand Down Expand Up @@ -397,9 +410,13 @@ AC_CONFIG_FILES([
libnozzle/Makefile
libnozzle/libnozzle.pc
libnozzle/tests/Makefile
libnozzle/bindings/rust/Makefile
libnozzle/bindings/rust/tests/Makefile
libknet/Makefile
libknet/libknet.pc
libknet/tests/Makefile
libknet/bindings/rust/Makefile
libknet/bindings/rust/tests/Makefile
man/Makefile
man/Doxyfile-knet
man/Doxyfile-nozzle
Expand Down
2 changes: 1 addition & 1 deletion libknet/Makefile.am
Expand Up @@ -15,7 +15,7 @@ SYMFILE = libknet_exported_syms

EXTRA_DIST = $(SYMFILE)

SUBDIRS = . tests
SUBDIRS = . tests bindings/rust

# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
libversion = 2:0:0
Expand Down
2 changes: 1 addition & 1 deletion libknet/bindings/rust/Cargo.toml
@@ -1,5 +1,5 @@
[package]
name = "libknet"
name = "kronosnet"
version = "0.1.0"
authors = ["Christine Caulfield <ccaulfie@redhat.com>"]
edition = "2018"
Expand Down
16 changes: 16 additions & 0 deletions libknet/bindings/rust/Makefile.am
@@ -0,0 +1,16 @@


EXTRA_DIST = Cargo.toml \
regenerate-sys.sh \
build.rs \
src/libknet.rs \
src/lib.rs \
src/sys/libknet.rs \
src/sys/mod.rs

all-local:
cargo build $(RUSTFLAGS)

clean-local:
-cargo clean

2 changes: 1 addition & 1 deletion libknet/bindings/rust/tests/Cargo.toml
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libknet = { path = ".." }
kronosnet = { path = ".." }

[[bin]]
name = "knet-test"
Expand Down
19 changes: 19 additions & 0 deletions libknet/bindings/rust/tests/Makefile.am
@@ -0,0 +1,19 @@

EXTRA_DIST = Cargo.toml \
src/bin/knet-test.rs

check_PROGRAMS = \
target/$(RUST_TARGET_DIR)/knet-test

noinst_PROGRAMS = $(check_PROGRAMS)

testsuitedir = $(TESTDIR)
testsuite_PROGRAMS = $(check_PROGRAMS)

TESTS = $(check_PROGRAMS)

target/$(RUST_TARGET_DIR)/knet-test: src/bin/knet-test.rs
cargo build $(RUSTFLAGS)

clean-local:
cargo clean
2 changes: 1 addition & 1 deletion libknet/bindings/rust/tests/src/bin/knet-test.rs
Expand Up @@ -7,7 +7,7 @@
// Author: Christine Caulfield (ccaulfi@redhat.com)
//

use libknet::libknet as knet;
use kronosnet::libknet as knet;
use std::net::{SocketAddr, IpAddr,Ipv4Addr};
use std::thread::spawn;
use std::sync::mpsc::Receiver;
Expand Down
2 changes: 1 addition & 1 deletion libnozzle/Makefile.am
Expand Up @@ -16,7 +16,7 @@ EXTRA_DIST = $(SYMFILE)

if BUILD_LIBNOZZLE

SUBDIRS = . tests
SUBDIRS = . tests bindings/rust bindings/rust/tests

libversion = 1:0:0

Expand Down
16 changes: 16 additions & 0 deletions libnozzle/bindings/rust/Makefile.am
@@ -0,0 +1,16 @@


EXTRA_DIST = Cargo.toml \
build.rs \
regenerate-sys.sh \
src/libnozzle.rs \
src/lib.rs \
src/sys/libnozzle.rs \
src/sys/mod.rs

all-local:
cargo build $(RUSTFLAGS)

clean-local:
-cargo clean

21 changes: 21 additions & 0 deletions libnozzle/bindings/rust/tests/Makefile.am
@@ -0,0 +1,21 @@

EXTRA_DIST = Cargo.toml \
src/bin/nozzle-test.rs \
up.d/tap33

check_PROGRAMS = target/$(RUST_TARGET_DIR)/nozzle-test

noinst_PROGRAMS = $(check_PROGRAMS)

testsuitedir = $(TESTDIR)
testsuite_PROGRAMS = $(check_PROGRAMS)

TESTS = $(check_PROGRAMS)

noinst_SCRIPTS = up.d/tap33

target/$(RUST_TARGET_DIR)/nozzle-test: src/bin/nozzle-test.rs
cargo build $(RUSTFLAGS)

clean-local:
cargo clean
3 changes: 1 addition & 2 deletions libnozzle/bindings/rust/tests/src/bin/nozzle-test.rs
Expand Up @@ -113,9 +113,8 @@ fn main() -> Result<()>
}
}


// Wait a little while in case user wants to check with 'ip' command
thread::sleep(time::Duration::from_millis(10000));
thread::sleep(time::Duration::from_millis(1000));

if let Err(e) = nozzle::set_down(handle){
println!("Error from set_down: {}", e);
Expand Down

0 comments on commit 3c7ab4a

Please sign in to comment.