Trying a little C from Rust and while at it might as well trying building an rpm.
makeThis should build the rust package in release mode, and also use cbindgen to genereate a c header file in the include folder.
This basically just runs the following commands: Mac:
cargo build --release
mkdir -p include
cbindgen --config cbindgen.toml --crate chedrpack --output include/chedrpack.hOn linux (tried with almalinux):
mkdir -p $(SOURCE_DIR)
tar czvf $(SOURCE_DIR)/$(TAR_NAME) --exclude=target --exclude=.git --transform 's,^,chedrpack-$(VERSION)/,' *
rpmbuild --define "_topdir /build/build/rpmbuild" -bb packaging/package.specSimply run:
make installWhich runs the below commands to install: Mac:
install -m 755 target/release/$(LIB_NAME) $(LIB_DIR)/$(LIB_NAME)
install -m 644 include/$(HEADER_NAME) $(INCLUDE_DIR)/$(HEADER_NAME)where the variables are:
LIB_NAME = libchedrpack.a
HEADER_NAME = chedrpack.h
LIB_DIR = /usr/local/lib
INCLUDE_DIR = /usr/local/includeLinux: make install runs the following:
yum -y localinstall build/rpmbuild/RPMS/aarch64/chedrpack-0.1.0-1.el9.aarch64.rpmmake uninstallRuns the following commands: Mac:
rm -f $(LIB_DIR)/$(LIB_NAME)
rm -f $(INCLUDE_DIR)/$(HEADER_NAME)Linux:
yum -y remove chedrpackmake testRuns:
gcc -o tests/test_add tests/test_add.c -l chedrpack && tests/test_add && rm tests/test_addmake cleanCleans the cargo and rpm build directories.