File: Makefile

package info (click to toggle)
golang-gitaly-proto 1.37.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 372 kB
  • sloc: ruby: 216; makefile: 93
file content (93 lines) | stat: -rw-r--r-- 2,785 bytes parent folder | download | duplicates (2)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
TARGET_DIR := $(CURDIR)/_build
TARGET_SETUP := $(TARGET_DIR)/.ok
BIN_BUILD_DIR := $(TARGET_DIR)/bin

unexport GOROOT
unexport GOBIN
export GO111MODULE = on

export PATH := $(TARGET_DIR)/bin:$(PATH)

# Developer Tools
PROTOC = $(TARGET_DIR)/protoc/bin/protoc
PROTOC_GEN_GO = $(BIN_BUILD_DIR)/protoc-gen-go
PROTOC_GEN_DOC = $(BIN_BUILD_DIR)/protoc-gen-doc
PROTOC_GEN_GITALY := $(BIN_BUILD_DIR)/protoc-gen-gitaly

.PHONY: all
all: generate

$(TARGET_SETUP):
	rm -rf $(TARGET_DIR)
	mkdir -p $(BIN_BUILD_DIR)
	touch $(TARGET_SETUP)

.PHONY: generate
generate: install-developer-tools go/gitalypb/*.pb.go
	_support/generate-from-proto

.PHONY: clean
clean:
	rm -rf $(TARGET_DIR) public .ruby-bundle

.PHONY: release
release: install-developer-tools
ifeq ($(version), "")
	$error("Please run 'make release version=x.y.z'")
endif
	_support/release $(version)

.PHONY: check-grpc-proto-clients
check-grpc-proto-clients: install-developer-tools
	_support/check-grpc-proto-clients

.PHONY: install-developer-tools
install-developer-tools: $(TARGET_SETUP) $(PROTOC) .ruby-bundle $(PROTOC_GEN_GITALY)

.PHONY: docs
docs: $(TARGET_SETUP) $(PROTOC_GEN_DOC) $(PROTOC)
	rm -rf public && mkdir public
	$(PROTOC) --doc_out=./public \
	          --plugin=protoc-gen-doc=$(PROTOC_GEN_DOC) \
	          *.proto

$(PROTOC): $(TARGET_SETUP)
	_support/install-protoc

.ruby-bundle: $(TARGET_SETUP) _support/Gemfile.lock
	bundle install --gemfile=_support/Gemfile --binstubs=$(BIN_BUILD_DIR)
	touch $@

$(PROTOC_GEN_GO): $(TARGET_SETUP)
	cd go/internal && go build -o $@ github.com/golang/protobuf/protoc-gen-go

$(PROTOC_GEN_DOC): $(TARGET_SETUP)
	cd go/internal && go build -o $@ github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc

$(PROTOC_GEN_GITALY): $(TARGET_SETUP)
	# Check if test protobuf stubs are stale
	cd go/internal && go build -o $@ gitlab.com/gitlab-org/gitaly-proto/go/internal/cmd/protoc-gen-gitaly

.PHONY: pb-go-stubs
pb-go-stubs: go/gitalypb/*.pb.go

go/gitalypb/%.pb.go: %.proto $(PROTOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GITALY)
	$(PROTOC) --gitaly_out=proto_dir=.,gitalypb_dir=go/gitalypb:. --go_out=paths=source_relative,plugins=grpc:./go/gitalypb -I$(shell pwd) *.proto

go/internal/linter/testdata/%.pb.go: go/internal/linter/testdata/%.proto $(PROTOC) $(PROTOC_GEN_GO) go/gitalypb/*.pb.go
	$(PROTOC) --go_out=paths=source_relative:. -I$(shell pwd) -I$(shell pwd)/go/internal/linter/testdata go/internal/linter/testdata/*.proto

.PHONY: test
test: test-go-pkg-opt
	cd go/internal && go test ./...

# test-go-pkg-opt checks if the go_package option is specified in all *.proto
# files
.PHONY: test-go-pkg-opt
test-go-pkg-opt:
	@for p in *.proto ; do \
		if ! grep -Fq "option go_package" $${p} ; then \
			echo "$${p} is missing the go_package option" ; \
			exit 1 ; \
		fi \
	done