mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-02-06 15:03:07 +00:00
initial commit for nimble
This commit is contained in:
parent
167c1a2f4b
commit
125a62c03d
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,6 +6,10 @@
|
||||
# Nimble packages
|
||||
/vendor/.nimble
|
||||
|
||||
# Developer vendor repos (cloned on-demand via `make vendors`)
|
||||
/vendor/zerokit/
|
||||
/vendor/waku-rlnv2-contract/
|
||||
|
||||
# Generated Files
|
||||
*.generated.nim
|
||||
|
||||
|
||||
10
.gitmodules
vendored
10
.gitmodules
vendored
@ -1,10 +0,0 @@
|
||||
[submodule "vendor/zerokit"]
|
||||
path = vendor/zerokit
|
||||
url = https://github.com/vacp2p/zerokit.git
|
||||
ignore = dirty
|
||||
branch = v0.5.1
|
||||
[submodule "vendor/waku-rlnv2-contract"]
|
||||
path = vendor/waku-rlnv2-contract
|
||||
url = https://github.com/logos-messaging/waku-rlnv2-contract.git
|
||||
ignore = untracked
|
||||
branch = master
|
||||
11
Makefile
11
Makefile
@ -65,7 +65,6 @@ waku.nims:
|
||||
ln -s waku.nimble $@
|
||||
|
||||
update: | waku.nims
|
||||
git submodule update --init --recursive
|
||||
nimble setup && nimble sync
|
||||
$(MAKE) build-nph
|
||||
|
||||
@ -222,12 +221,20 @@ librln: | $(LIBRLN_FILE)
|
||||
$(eval NIM_PARAMS += --passL:$(LIBRLN_FILE) --passL:-lm)
|
||||
|
||||
clean-librln:
|
||||
cargo clean --manifest-path vendor/zerokit/rln/Cargo.toml
|
||||
@if [ -f "vendor/zerokit/rln/Cargo.toml" ]; then \
|
||||
cargo clean --manifest-path vendor/zerokit/rln/Cargo.toml; \
|
||||
fi
|
||||
rm -f $(LIBRLN_FILE)
|
||||
|
||||
# Extend clean target
|
||||
clean: | clean-librln
|
||||
|
||||
# Clone vendor repos for development (builds from source automatically when present)
|
||||
vendors:
|
||||
@mkdir -p vendor
|
||||
@[ -d "vendor/zerokit/.git" ] || git clone --branch v0.5.1 https://github.com/vacp2p/zerokit.git vendor/zerokit
|
||||
@[ -d "vendor/waku-rlnv2-contract/.git" ] || git clone https://github.com/logos-messaging/waku-rlnv2-contract.git vendor/waku-rlnv2-contract
|
||||
|
||||
#################
|
||||
## Waku Common ##
|
||||
#################
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
#!/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.
|
||||
# This script is used to build the rln library for the current platform.
|
||||
# - If vendor/zerokit exists: builds from source
|
||||
# - Otherwise: downloads prebuilt binary from GitHub releases
|
||||
|
||||
set -e
|
||||
|
||||
# first argument is the build directory
|
||||
build_dir=$1
|
||||
rln_version=$2
|
||||
output_filename=$3
|
||||
@ -14,14 +14,31 @@ output_filename=$3
|
||||
[[ -z "${rln_version}" ]] && { echo "No rln version specified"; exit 1; }
|
||||
[[ -z "${output_filename}" ]] && { echo "No output filename specified"; exit 1; }
|
||||
|
||||
# Get the host triplet
|
||||
# Build from source if vendor exists
|
||||
if [[ -d "${build_dir}/rln" ]]; then
|
||||
echo "Building RLN from source (${build_dir})..."
|
||||
|
||||
detected_OS=$(uname -s)
|
||||
if [[ "$detected_OS" == MINGW* || "$detected_OS" == MSYS* ]]; then
|
||||
submodule_version=$(cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml" | sed -n 's/.*"name":"rln","version":"\([^"]*\)".*/\1/p')
|
||||
else
|
||||
submodule_version=$(cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml" | jq -r '.packages[] | select(.name == "rln") | .version')
|
||||
fi
|
||||
|
||||
if [[ "v${submodule_version}" != "${rln_version}" ]]; then
|
||||
echo "Warning: Source version (v${submodule_version}) does not match expected (${rln_version})"
|
||||
fi
|
||||
|
||||
cargo build --release -p rln --manifest-path "${build_dir}/rln/Cargo.toml"
|
||||
cp "${build_dir}/target/release/librln.a" "${output_filename}"
|
||||
echo "Built ${output_filename} from source"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Download prebuilt binary
|
||||
host_triplet=$(rustc --version --verbose | awk '/host:/{print $2}')
|
||||
tarball="${host_triplet}-stateless-rln.tar.gz"
|
||||
|
||||
tarball="${host_triplet}"
|
||||
tarball+="-stateless"
|
||||
tarball+="-rln.tar.gz"
|
||||
|
||||
# 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" \
|
||||
-o "${tarball}";
|
||||
@ -32,23 +49,6 @@ then
|
||||
rm -rf "${tarball}" release
|
||||
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"
|
||||
|
||||
detected_OS=$(uname -s)
|
||||
if [[ "$detected_OS" == MINGW* || "$detected_OS" == MSYS* ]]; then
|
||||
submodule_version=$(cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml" | sed -n 's/.*"name":"rln","version":"\([^"]*\)".*/\1/p')
|
||||
else
|
||||
submodule_version=$(cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml" | 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}"
|
||||
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}"
|
||||
echo "Run 'make vendors' to clone zerokit and build from source"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
1
vendor/waku-rlnv2-contract
vendored
1
vendor/waku-rlnv2-contract
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 8a338f354481e8a3f3d64a72e38fad4c62e32dcd
|
||||
1
vendor/zerokit
vendored
1
vendor/zerokit
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 70c79fbc989d4f87d9352b2f4bddcb60ebe55b19
|
||||
Loading…
x
Reference in New Issue
Block a user