#!/bin/sh # Build wasm-bindgen-cli into TOOLS_DIR/bin at the version of the wasm-bindgen crate ltk pins in its Cargo.toml, which is the version a module built with ltk needs. Debian does not package the CLI, and the lock it is published with needs a rustc newer than Debian's, so it is built from its sources with a lock resolved for the rust-version it declares. It reads the Cargo.toml next to this script's directory, so the copy installed with the package works from any project. # # Usage: scripts/wasm-bindgen-cli.sh TOOLS_DIR set -eu if [ $# -ne 1 ] then echo "usage: $0 TOOLS_DIR" >&2 exit 2 fi mkdir -p "$1" tools=$( cd "$1" && pwd ) manifest=$( dirname "$0" )/../Cargo.toml version=$( sed -n 's/^wasm-bindgen *= *{ *version *= *"=\([^"]*\)".*/\1/p' "$manifest" ) if [ -z "$version" ] then echo "$0: no pinned wasm-bindgen in $manifest" >&2 exit 1 fi src=$( mktemp -d ) trap 'rm -rf "$src"' EXIT curl -sSfL "https://static.crates.io/crates/wasm-bindgen-cli/wasm-bindgen-cli-$version.crate" | tar -xz -C "$src" --strip-components=1 cd "$src" CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo generate-lockfile cargo install --path . --locked --root "$tools"