From 179be681c4484e65c93c6defb554d3df4c30ddca Mon Sep 17 00:00:00 2001 From: Aaryamann Challani <43716372+rymnc@users.noreply.github.com> Date: Tue, 21 Mar 2023 13:07:10 +0530 Subject: [PATCH] feat(rln-relay): fetch release from zerokit ci, or build (#1603) * feat(rln-relay): fetch release from zerokit ci, or build * fix(build_rln): shellcheck, move to scripts dir --- .gitignore | 1 + Makefile | 6 +++--- scripts/build_rln.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100755 scripts/build_rln.sh diff --git a/.gitignore b/.gitignore index c37a3a379..6c56261df 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ node_modules/ # RLN / keystore rlnCredentials.txt rlnKeystore.json +*.tar.gz # Nimbus Build System nimbus-build-system.paths diff --git a/Makefile b/Makefile index fa3a5ed70..b5a26f71f 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,7 @@ endif ### RLN -LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit/target/release +LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit ifeq ($(OS),Windows_NT) LIBRLN_FILE := rln.lib @@ -115,12 +115,12 @@ endif $(LIBRLN_BUILDDIR)/$(LIBRLN_FILE): echo -e $(BUILD_MSG) "$@" && \ - cargo build --manifest-path vendor/zerokit/rln/Cargo.toml --release + ./scripts/build_rln.sh $(LIBRLN_BUILDDIR) ifneq ($(RLN), true) librln: ; # noop else -EXPERIMENTAL_PARAMS += -d:rln --passL:$(LIBRLN_BUILDDIR)/$(LIBRLN_FILE) --passL:-lm +EXPERIMENTAL_PARAMS += -d:rln --passL:$(LIBRLN_FILE) --passL:-lm librln: $(LIBRLN_BUILDDIR)/$(LIBRLN_FILE) endif diff --git a/scripts/build_rln.sh b/scripts/build_rln.sh new file mode 100755 index 000000000..769d952a5 --- /dev/null +++ b/scripts/build_rln.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# This script is used to build the rln library for the current platform, or download it from the +# release page if it is available. + +set -e + +# first argument is the build directory +build_dir=$1 + +if [[ -z "$build_dir" ]]; then + echo "No build directory specified" + exit 1 +fi + +# Get the host triplet +host_triplet=$(rustup show | grep "Default host: " | cut -d' ' -f3) + +# Download the prebuilt rln library if it is available +if curl --silent --fail-with-body -L "https://github.com/vacp2p/zerokit/releases/download/nightly/$host_triplet-rln.tar.gz" >> "$host_triplet-rln.tar.gz" +then + echo "Downloaded $host_triplet-rln.tar.gz" + tar -xzf "$host_triplet-rln.tar.gz" + mv release/librln.a . + rm -rf "$host_triplet-rln.tar.gz" release +else + echo "Failed to download $host_triplet-rln.tar.gz" + # Build rln instead + cargo build --release --manifest-path "$build_dir/rln/Cargo.toml" + cp "$build_dir/rln/target/release/librln.a" . +fi