.PHONY: verify generate proto-lint proto-breaking source-verify scope-verify conformance frame-verify go-test binding-compile strict-contracts clean-generated

PYTHON ?= python3
PROTOC ?= protoc
BUF ?= buf

generate:
	$(PYTHON) tools/generate.py
	$(PROTOC) --proto_path=proto --descriptor_set_out=gen/protobuf/control-v1.pb --include_imports --include_source_info proto/versevdi/control/v1/control.proto
	$(PROTOC) --proto_path=proto --descriptor_set_out=gen/protobuf/tunnel-v1.pb --include_imports --include_source_info proto/versevdi/tunnel/v1/tunnel.proto

proto-lint:
	$(BUF) lint

proto-breaking:
	$(BUF) breaking proto --against $(abspath gen/protobuf/phase3a-baseline.binpb) --limit-to-input-files

source-verify:
	$(PYTHON) -B tools/validate.py
	$(PYTHON) -B tools/fixture_digest.py

scope-verify:
	$(PYTHON) -B tools/check_scope.py

go-test:
	go test ./gen/go/... ./tests/go

binding-compile:
	rustc --crate-type lib gen/rust/protocol.rs -o /tmp/versevdi-protocol-generated.rlib
	swiftc -typecheck gen/swift/Protocol.swift

strict-contracts:
	$(PYTHON) -B tools/test_generated_contracts.py

conformance:
	$(PYTHON) -B tools/fixture_digest.py
	go run ./tools/go-conformance
	$(PYTHON) tools/run_native_conformance.py

frame-verify:
	$(PYTHON) tools/validate_frames.py
	$(PYTHON) tools/validate_gateway_envelopes.py

clean-generated:
	$(PYTHON) tools/generate.py --check

verify: generate proto-lint proto-breaking source-verify scope-verify go-test binding-compile strict-contracts conformance frame-verify clean-generated
