PROBLEM := coin_flip
ZIPNAME := $(PROBLEM)-solution

.PHONY: build test format check clean zip

build:
	cargo build

test:
	cargo build
	./test_protocol.sh

format:
	cargo fmt

check:
	cargo fmt -- --check
	cargo clippy --all-targets

clean:
	cargo clean

# Bundle this crate into `../$(ZIPNAME).zip`. The archive holds one folder,
# named `$(PROBLEM)`, whatever this directory happens to be called: the crate
# is staged under that name first.
STAGING := ../.$(PROBLEM)-zip-staging

zip: clean
	rm -f ../$(ZIPNAME).zip
	rm -rf $(STAGING)
	mkdir -p $(STAGING)/$(PROBLEM)
	cp -R . $(STAGING)/$(PROBLEM)
	cd $(STAGING) && zip -rq ../$(ZIPNAME).zip $(PROBLEM)
	rm -rf $(STAGING)

