#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk
include /usr/share/rustc/architecture.mk

export DEB_HOST_RUST_TYPE
export CARGO_NET_OFFLINE := true

CARGO_BASE_ARGS= --release --target $(DEB_HOST_RUST_TYPE)

%:
	dh $@ --with=shell_completions

# The single deliberately networked step of the build: fetch every crate
# pinned by Cargo.lock into ./vendor (the Better-Deepin OBS builder
# permits network here).  Afterwards debian/cargo-config.toml replaces
# crates-io with that tree and sets [net] offline = true, so `cargo
# build` / `cargo test` below never touch the network.  The fetch runs on
# the quilt-patched tree (dpkg-source applied the series before), so the
# closure equals the build graph exactly.
execute_before_dh_auto_configure:
	debian/fetch-vendor.sh
	mkdir -p .cargo
	cp debian/cargo-config.toml .cargo/config.toml

override_dh_auto_build:
	cargo build $(CARGO_BASE_ARGS)

override_dh_auto_test:
	cargo test $(CARGO_BASE_ARGS)
