.PHONY: all setup test runner-get runner-analyze runner-test client-get client-analyze client-test core-test proto proto-go proto-dart

PROTOC_GEN_DART := $(shell command -v protoc-gen-dart 2>/dev/null)

all: setup test

setup: runner-get client-get

runner-get:
	cd apps/runner && dart pub get

runner-analyze:
	cd apps/runner && dart analyze

runner-test:
	cd apps/runner && dart test

client-get:
	cd apps/client && flutter pub get

client-analyze:
	cd apps/client && flutter analyze

client-test:
	cd apps/client && flutter test

core-test:
	cd services/core && go test ./...

proto: proto-go proto-dart

proto-go:
	mkdir -p services/core/oto
	protoc -I proto --go_out=services/core --go_opt=paths=source_relative proto/oto/runner.proto

proto-dart:
ifndef PROTOC_GEN_DART
	$(error "protoc-gen-dart not found. Please install it to generate Dart protobuf files.")
endif
	mkdir -p apps/runner/lib/oto/agent
	protoc -I proto --dart_out=apps/runner/lib/oto/agent proto/oto/runner.proto

test: runner-test client-test core-test

