#!/bin/sh
# Builds the addon and copies it to target/release/xmachines_runtime_node.node, where
# Node can `require()` it. Extra arguments go to cargo.
set -eu
root=$(cd "$(dirname "$0")/../.." && pwd)
cd "$root"
cargo build -p xmachines-runtime-node --release "$@"
target=${CARGO_TARGET_DIR:-$root/target}/release
case "$(uname -s)" in
  Darwin) lib=libxmachines_runtime_node.dylib ;;
  MINGW* | MSYS* | CYGWIN*) lib=xmachines_runtime_node.dll ;;
  *) lib=libxmachines_runtime_node.so ;;
esac
cp "$target/$lib" "$target/xmachines_runtime_node.node"
echo "$target/xmachines_runtime_node.node"
