-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (38 loc) · 1.63 KB
/
Copy pathMakefile
File metadata and controls
48 lines (38 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
SNAPCHAIN_VER := $(shell cat SNAPCHAIN_VERSION 2>/dev/null || echo "unset")
PROTO_FILES = $(wildcard proto/*.proto)
# Colors for output
GREEN = \033[0;32m
NC = \033[0m
all: proto-bindings
# Compile .proto files, touch stamp file
proto-bindings: fetch-proto proto/.downloaded_version
@echo -e "$(GREEN)Compiling .proto files...$(NC)"
@command -v protoc >/dev/null || (echo "Error: protoc not found in PATH" && exit 1)
protoc --proto_path=proto --go_out=. --go-grpc_out=. \
$(foreach f,$(PROTO_FILES),--go_opt=M$(notdir $(f))=farcaster/ --go-grpc_opt=M$(notdir $(f))=farcaster/) \
$(PROTO_FILES)
@echo "package farcaster" > farcaster/doc.go
@touch $@
fetch-proto: SNAPCHAIN_VERSION proto/.downloaded_version
@echo -e "$(GREEN)Downloading proto files (Hubble v$(SNAPCHAIN_VER))...$(NC)"
curl -s -L "https://codeload.github.com/farcasterxyz/snapchain/tar.gz/refs/tags/v$(SNAPCHAIN_VER)" \
| tar -zxvf - -C . --strip-components 2 "snapchain-$(SNAPCHAIN_VER)/src/proto/"
@echo "$(SNAPCHAIN_VER)" > proto/.downloaded_version
@touch $@
proto/.downloaded_version:
@touch $@
clean:
@echo -e "$(GREEN)Deleting protobuf definitions...$(NC)"
rm -f proto/* fetch-proto
@echo -e "$(GREEN)Deleting protobuf bindings...$(NC)"
rm -f farcaster/*.pb.go farcaster/*.pb.gw.go
rm -f proto-bindings
test:
@echo -e "$(GREEN)Running tests...$(NC)"
go test -v ./tests/...
test-coverage:
@echo -e "$(GREEN)Running tests with coverage...$(NC)"
go test -v -coverprofile=coverage.out ./tests/...
go tool cover -html=coverage.out -o coverage.html
@echo -e "$(GREEN)Coverage report generated: coverage.html$(NC)"
.PHONY: all clean test test-coverage