mirror of
https://github.com/status-im/status-node-manager.git
synced 2025-02-19 16:04:20 +00:00
chore(waku): Add script and command for building RLN
This commit is contained in:
parent
1e89282f5e
commit
2037a78f29
15
.gitignore
vendored
15
.gitignore
vendored
@ -14,3 +14,18 @@ nimble.paths
|
||||
# Nix & Direnv
|
||||
.direnv
|
||||
result
|
||||
|
||||
# Executables shall be put in an ignored build/ directory
|
||||
/build
|
||||
|
||||
# Ignore dynamic, static libs and libtool archive files
|
||||
*.so
|
||||
*.dylib
|
||||
*.a
|
||||
*.la
|
||||
*.exe
|
||||
*.dll
|
||||
|
||||
# RLN / keystore
|
||||
rlnKeystore.json
|
||||
*.tar.gz
|
||||
|
28
Makefile
Normal file
28
Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
##################
|
||||
## RLN ##
|
||||
##################
|
||||
.PHONY: librln
|
||||
|
||||
LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit
|
||||
LIBRLN_VERSION := v0.3.4
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
LIBRLN_FILE := rln.lib
|
||||
else
|
||||
LIBRLN_FILE := librln_$(LIBRLN_VERSION).a
|
||||
endif
|
||||
|
||||
$(LIBRLN_FILE):
|
||||
echo -e $(BUILD_MSG) "$@" && \
|
||||
./scripts/build_rln.sh $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(LIBRLN_FILE)
|
||||
|
||||
|
||||
librln: | $(LIBRLN_FILE)
|
||||
$(eval NIM_PARAMS += --passL:$(LIBRLN_FILE) --passL:-lm)
|
||||
|
||||
clean-librln:
|
||||
cargo clean --manifest-path vendor/zerokit/rln/Cargo.toml
|
||||
rm -f $(LIBRLN_FILE)
|
||||
|
||||
# Extend clean target
|
||||
clean: | clean-librln
|
46
scripts/build_rln.sh
Executable file
46
scripts/build_rln.sh
Executable file
@ -0,0 +1,46 @@
|
||||
#!/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
|
||||
rln_version=$2
|
||||
output_filename=$3
|
||||
|
||||
[[ -z "${build_dir}" ]] && { echo "No build directory specified"; exit 1; }
|
||||
[[ -z "${rln_version}" ]] && { echo "No rln version specified"; exit 1; }
|
||||
[[ -z "${output_filename}" ]] && { echo "No output filename specified"; exit 1; }
|
||||
|
||||
# Get the host triplet
|
||||
host_triplet=$(rustc --version --verbose | awk '/host:/{print $2}')
|
||||
|
||||
# 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/${host_triplet}-rln.tar.gz" \
|
||||
-o "${host_triplet}-rln.tar.gz";
|
||||
then
|
||||
echo "Downloaded ${host_triplet}-rln.tar.gz"
|
||||
tar -xzf "${host_triplet}-rln.tar.gz"
|
||||
mv "release/librln.a" "${output_filename}"
|
||||
rm -rf "${host_triplet}-rln.tar.gz" release
|
||||
else
|
||||
echo "Failed to download ${host_triplet}-rln.tar.gz"
|
||||
# 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'
|
||||
)
|
||||
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}"
|
||||
exit 1
|
||||
fi
|
||||
# if submodule version = version in Makefile, build rln
|
||||
cargo build --release -p rln --manifest-path "${build_dir}/rln/Cargo.toml"
|
||||
cp "${build_dir}/target/release/librln.a" "${output_filename}"
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user