mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-04-14 20:23:08 +00:00
build: automate mix RLN v2.0.0 build and linking for mix binaries
This commit is contained in:
parent
3e24874e82
commit
bb4bd12e6e
22
Makefile
22
Makefile
@ -187,10 +187,15 @@ nimbus-build-system-nimble-dir:
|
||||
##################
|
||||
## RLN ##
|
||||
##################
|
||||
.PHONY: librln
|
||||
.PHONY: librln mix-librln
|
||||
|
||||
LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit
|
||||
LIBRLN_VERSION := v0.9.0
|
||||
MIX_LIBRLN_VERSION ?= v2.0.0
|
||||
MIX_LIBRLN_REPO ?= https://github.com/vacp2p/zerokit.git
|
||||
MIX_LIBRLN_SRCDIR ?= $(CURDIR)/build/zerokit_$(MIX_LIBRLN_VERSION)
|
||||
MIX_LIBRLN_FILE ?= $(CURDIR)/build/librln_mix_$(MIX_LIBRLN_VERSION).a
|
||||
MIX_LIBRLN_NIM_PARAMS := --passL:$(MIX_LIBRLN_FILE) --passL:-lm
|
||||
|
||||
ifeq ($(detected_OS),Windows)
|
||||
LIBRLN_FILE ?= rln.lib
|
||||
@ -202,12 +207,19 @@ $(LIBRLN_FILE):
|
||||
echo -e $(BUILD_MSG) "$@" && \
|
||||
./scripts/build_rln.sh $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(LIBRLN_FILE)
|
||||
|
||||
$(MIX_LIBRLN_FILE):
|
||||
echo -e $(BUILD_MSG) "$@" && \
|
||||
./scripts/build_rln_mix.sh $(MIX_LIBRLN_SRCDIR) $(MIX_LIBRLN_VERSION) $(MIX_LIBRLN_FILE) $(MIX_LIBRLN_REPO)
|
||||
|
||||
librln: | $(LIBRLN_FILE)
|
||||
$(eval NIM_PARAMS += --passL:$(LIBRLN_FILE) --passL:-lm)
|
||||
|
||||
mix-librln: | $(MIX_LIBRLN_FILE)
|
||||
|
||||
clean-librln:
|
||||
cargo clean --manifest-path vendor/zerokit/rln/Cargo.toml
|
||||
rm -f $(LIBRLN_FILE)
|
||||
rm -f $(MIX_LIBRLN_FILE)
|
||||
|
||||
# Extend clean target
|
||||
clean: | clean-librln
|
||||
@ -232,10 +244,10 @@ testwaku: | build deps rln-deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim test -d:os=$(shell uname) $(NIM_PARAMS) waku.nims
|
||||
|
||||
wakunode2: | build deps librln
|
||||
wakunode2: | build deps librln mix-librln
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
\
|
||||
$(ENV_SCRIPT) nim wakunode2 $(NIM_PARAMS) waku.nims
|
||||
$(ENV_SCRIPT) nim wakunode2 $(NIM_PARAMS) $(MIX_LIBRLN_NIM_PARAMS) waku.nims
|
||||
|
||||
benchmarks: | build deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
@ -253,9 +265,9 @@ chat2: | build deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim chat2 $(NIM_PARAMS) waku.nims
|
||||
|
||||
chat2mix: | build deps librln
|
||||
chat2mix: | build deps librln mix-librln
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim chat2mix $(NIM_PARAMS) waku.nims
|
||||
$(ENV_SCRIPT) nim chat2mix $(NIM_PARAMS) $(MIX_LIBRLN_NIM_PARAMS) waku.nims
|
||||
|
||||
rln-db-inspector: | build deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
|
||||
43
scripts/build_rln_mix.sh
Executable file
43
scripts/build_rln_mix.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Build a separate, pinned RLN library for mix spam-protection usage.
|
||||
# This keeps the main nwaku RLN dependency flow unchanged.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source_dir="${1:-}"
|
||||
version="${2:-}"
|
||||
output_file="${3:-}"
|
||||
repo_url="${4:-https://github.com/vacp2p/zerokit.git}"
|
||||
|
||||
if [[ -z "${source_dir}" || -z "${version}" || -z "${output_file}" ]]; then
|
||||
echo "Usage: $0 <source_dir> <version_tag> <output_file> [repo_url]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "${source_dir}")"
|
||||
mkdir -p "$(dirname "${output_file}")"
|
||||
|
||||
if [[ ! -d "${source_dir}/.git" ]]; then
|
||||
echo "Cloning zerokit ${version} from ${repo_url}..."
|
||||
if [[ -e "${source_dir}" ]]; then
|
||||
echo "Path exists but is not a git repository: ${source_dir}"
|
||||
echo "Please remove it and retry."
|
||||
exit 1
|
||||
fi
|
||||
git clone --depth 1 --branch "${version}" "${repo_url}" "${source_dir}"
|
||||
else
|
||||
echo "Using existing zerokit checkout in ${source_dir}"
|
||||
current_tag="$(git -C "${source_dir}" describe --tags --exact-match 2>/dev/null || true)"
|
||||
if [[ "${current_tag}" != "${version}" ]]; then
|
||||
echo "Updating zerokit checkout to ${version}..."
|
||||
git -C "${source_dir}" fetch --tags origin "${version}"
|
||||
git -C "${source_dir}" checkout --detach "${version}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Building mix RLN library from source (version ${version})..."
|
||||
cargo build --release -p rln --manifest-path "${source_dir}/rln/Cargo.toml"
|
||||
|
||||
cp "${source_dir}/target/release/librln.a" "${output_file}"
|
||||
echo "Successfully built ${output_file}"
|
||||
Loading…
x
Reference in New Issue
Block a user