#!/bin/bash
set -euox pipefail

RUST_VERSION=$(dpkg-parsechangelog -SVersion | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/')

# Set RUSTC so that `cargo` knows which rustc to use
export RUSTC=/usr/lib/rust-${RUST_VERSION}/bin/rustc
CARGO=/usr/lib/rust-${RUST_VERSION}/bin/cargo

tmpdir=$(mktemp -d)
cd "$tmpdir"

${CARGO} new --lib hello
cd hello

${CARGO} build --target wasm32-unknown-unknown
