Skip to content

Commit

Permalink
feat: update rln.lib and makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
darshankabariya committed Sep 16, 2024
1 parent 51391aa commit 354d36c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ clean: | clean-librln
.PHONY: negentropy

LIBNEGENTROPY_BUILDDIR := $(CURDIR)/vendor/negentropy/cpp
ifeq ($(OS),Windows_NT)
LIBNEGENTROPY_FILE := libnegentropy.dll
else
LIBNEGENTROPY_FILE := libnegentropy.so
endif


deps: | negentropy

Expand Down
30 changes: 22 additions & 8 deletions scripts/build_rln.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,21 @@ output_filename=$3
[[ -z "${rln_version}" ]] && { echo "No rln version specified"; exit 1; }
[[ -z "${output_filename}" ]] && { echo "No output filename specified"; exit 1; }

# Detect OS
case "$(uname -s)" in
Linux*) os=linux;
Darwin*) os=darwin;
MINGW*) os=windows;
MSYS*) os=windows;
*) os=unknown;
esac

# Get the host triplet
host_triplet=$(rustc --version --verbose | awk '/host:/{print $2}')
if [ "$os" = "windows" ]; then
host_triplet=$(rustc -vV | sed -n 's/host: //p')
else
host_triplet=$(rustc --version --verbose | awk '/host:/{print $2}')
fi

tarball="${host_triplet}"

Expand All @@ -27,7 +40,6 @@ else
tarball+="-rln.tar.gz"
fi


# Download the prebuilt rln library if it is available
if curl --silent --fail-with-body -L \
"https://github.com/vacp2p/zerokit/releases/download/$rln_version/$tarball" \
Expand All @@ -40,12 +52,14 @@ then
else
echo "Failed to download ${tarball}"
# Build rln instead
# first, check if submodule version = version in Makefile
cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml"
submodule_version=$(
cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml" \
| jq -r '.packages[] | select(.name == "rln") | .version'
)
cargo_metadata=$(cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml")

if [ "$os" = "windows" ]; then
submodule_version=$(echo "$cargo_metadata" | sed -n 's/.*"name":"rln","version":"\([^"]*\)".*/\1/p')
else
submodule_version=$(echo "$cargo_metadata" | jq -r '.packages[] | select(.name == "rln") | .version')
fi

if [[ "v${submodule_version}" != "${rln_version}" ]]; then
echo "Submodule version (v${submodule_version}) does not match version in Makefile (${rln_version})"
echo "Please update the submodule to ${rln_version}"
Expand Down
2 changes: 1 addition & 1 deletion vendor/negentropy
Submodule negentropy updated 1 files
+11 −5 cpp/Makefile

0 comments on commit 354d36c

Please sign in to comment.