.PHONY: all build tidy test test-e2e test-openai-ollama proto clean

GOFLAGS ?= -trimpath

all: build

build:
	go build $(GOFLAGS) -o bin/node          ./apps/node/cmd/node
	go build $(GOFLAGS) -o bin/edge          ./apps/edge/cmd/edge
	go build $(GOFLAGS) -o bin/control-plane ./apps/control-plane/cmd/control-plane
	go build $(GOFLAGS) -o bin/worker        ./apps/worker/cmd/worker

tidy:
	go mod tidy

test:
	go test ./...

test-e2e:
	@echo "NOTE: test-e2e runs auxiliary smoke plus fake Ollama OpenAI serving; completion still requires user-flow verification when changing runtime paths."
	./scripts/e2e-smoke.sh
	./scripts/e2e-openai-ollama.sh

test-openai-ollama:
	./scripts/e2e-openai-ollama.sh

# Requires: protoc + protoc-gen-go (go install google.golang.org/protobuf/cmd/protoc-gen-go@latest)
proto:
	protoc \
		--go_out=. \
		--go_opt=module=iop \
		--proto_path=. \
		proto/iop/runtime.proto \
		proto/iop/node.proto \
		proto/iop/control.proto \
		proto/iop/job.proto

clean:
	rm -f bin/node bin/edge bin/control-plane bin/worker
