Packages
reckon_db
2.3.6
5.11.0
5.10.4
5.10.3
5.10.1
5.10.0
5.9.1
5.9.0
5.8.3
5.8.2
5.8.1
5.8.0
5.7.0
5.6.1
5.6.0
5.5.5
5.5.4
5.5.3
5.5.2
5.5.1
5.5.0
5.4.0
5.2.2
5.2.1
5.2.0
5.1.0
5.0.0
4.0.0
3.1.2
3.1.1
3.0.0
2.3.7
2.3.6
2.3.5
2.3.4
2.3.3
2.3.2
2.3.1
2.3.0
2.2.2
2.2.0
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.0
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.6.3
1.6.2
1.6.1
1.6.0
1.5.1
1.5.0
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.1
1.1.0
1.0.3
1.0.2
1.0.1
1.0.0
BEAM-native Event Store built on Khepri/Ra with Raft consensus. Event sourcing, persistent subscriptions, snapshots, and automatic cluster formation via UDP multicast discovery. Ships embedded Rust NIFs for 3-15x acceleration of crypto, hashing, compression, aggregation, filter matching, and grap...
Current section
Files
Jump to
Current section
Files
priv/build-nifs.sh
#!/bin/bash
# Build all Rust NIFs for the reckon-db package.
#
# Modeled on macula's priv/build-nifs.sh — embeds NIFs inside the
# package that uses them rather than fragmenting them across a
# separate reckon-nifs sidecar. Each reckon-db NIF wrapper module
# (reckon_db_*_nif.erl) loads its .so from priv/ via its own
# `-on_load(init/0)` hook.
#
# Usage: priv/build-nifs.sh [BASEDIR]
# Called by rebar.config pre_hooks during compilation.
#
# Behaviour:
# - Idempotent: if priv/<crate>.so already exists, skip.
# - Tolerant: missing Rust toolchain → log a warning and skip
# (reckon-db's wrapper modules will use the Erlang fallbacks).
# - Per-crate: a failure in one crate does not abort the others.
set -eu
BASEDIR="${1:-.}"
PRIV_DIR="${BASEDIR}/priv"
NATIVE_DIR="${BASEDIR}/native"
# When compiling inside _build/, native/ isn't symlinked but src/ is.
# Follow the src symlink to find the source root and its native/ dir.
if [ ! -d "${NATIVE_DIR}" ] && [ -L "${BASEDIR}/src" ]; then
SRC_TARGET=$(readlink -f "${BASEDIR}/src")
SOURCE_ROOT=$(dirname "${SRC_TARGET}")
if [ -d "${SOURCE_ROOT}/native" ]; then
NATIVE_DIR="${SOURCE_ROOT}/native"
fi
fi
mkdir -p "${PRIV_DIR}"
build_nif() {
local CRATE_NAME="$1"
local NIF_FILE="${PRIV_DIR}/${CRATE_NAME}.so"
local CRATE_DIR="${NATIVE_DIR}/${CRATE_NAME}"
if [ -f "${NIF_FILE}" ]; then
return 0 # already built
fi
if [ ! -d "${CRATE_DIR}" ]; then
echo "[${CRATE_NAME}] WARNING: No source at ${CRATE_DIR}, skipping."
return 0
fi
if ! command -v cargo >/dev/null 2>&1; then
echo "[${CRATE_NAME}] WARNING: Rust toolchain not found, skipping NIF build."
echo "[${CRATE_NAME}] Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
return 0
fi
echo "[${CRATE_NAME}] Building NIF from source..."
cargo build --release --manifest-path "${CRATE_DIR}/Cargo.toml"
cp "${CRATE_DIR}/target/release/lib${CRATE_NAME}.so" "${NIF_FILE}" 2>/dev/null || \
cp "${CRATE_DIR}/target/release/lib${CRATE_NAME}.dylib" "${NIF_FILE}" 2>/dev/null || \
echo "[${CRATE_NAME}] WARNING: Could not find compiled NIF."
}
build_nif reckon_db_crypto_nif
build_nif reckon_db_archive_nif
build_nif reckon_db_hash_nif
build_nif reckon_db_aggregate_nif
build_nif reckon_db_filter_nif
build_nif reckon_db_graph_nif
echo "[reckon-db] All NIFs ready."