forked from connectrpc/connect-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
123 lines (102 loc) · 4.12 KB
/
Makefile
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# See https://tech.davis-hansson.com/p/make/
SHELL := bash
.DELETE_ON_ERROR:
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := all
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-print-directory
BIN := .tmp/bin
CACHE := .tmp/cache
LICENSE_HEADER_YEAR_RANGE := 2022-2023
LICENSE_HEADER_VERSION := v1.26.1
PROTOC_VERSION ?= 24.4
GRADLE_ARGS ?=
UNAME_OS := $(shell uname -s)
UNAME_ARCH := $(shell uname -m)
.PHONY: all
all: build
$(BIN)/license-headers: Makefile
mkdir -p $(@D)
GOBIN=$(abspath $(BIN)) go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@$(LICENSE_HEADER_VERSION)
.PHONY: build
build: generate ## Build the entire project.
./gradlew $(GRADLE_ARGS) build
.PHONY: buildplugin
buildplugin: ## Build the connect-kotlin protoc plugin.
./gradlew $(GRADLE_ARGS) protoc-gen-connect-kotlin:installDist
.PHONY: clean
clean: ## Cleans the underlying build.
./gradlew $(GRADLE_ARGS) clean
.PHONY: conformancerun
conformancerun: conformancerunjava ## Run the conformance tests.
.PHONY: conformancerunjava
conformancerunjava: generate ## Run the conformance tests for protoc-gen-java integration.
./gradlew $(GRADLE_ARGS) conformance:google-java:test
ifeq ($(UNAME_OS),Darwin)
PROTOC_OS := osx
ifeq ($(UNAME_ARCH),arm64)
PROTOC_ARCH := aarch_64
else
PROTOC_ARCH := x86_64
endif
endif
ifeq ($(UNAME_OS),Linux)
PROTOC_OS = linux
PROTOC_ARCH := $(UNAME_ARCH)
endif
PROTOC := $(CACHE)/protoc-$(PROTOC_VERSION).zip
$(PROTOC):
@if ! command -v curl >/dev/null 2>/dev/null; then echo "error: curl must be installed" >&2; exit 1; fi
@if ! command -v unzip >/dev/null 2>/dev/null; then echo "error: unzip must be installed" >&2; exit 1; fi
@rm -f $(BIN)/protoc
$(eval PROTOC_TMP := $(shell mktemp -d))
curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-$(PROTOC_OS)-$(PROTOC_ARCH).zip -o $(PROTOC_TMP)/protoc.zip
@mkdir -p $(BIN)
unzip -q $(PROTOC_TMP)/protoc.zip -d $(dir $(BIN)) bin/protoc
@rm -rf $(PROTOC_TMP)
@mkdir -p $(dir $@)
@touch $@
.PHONY: generate
generate: $(PROTOC) buildplugin generateconformance generateexamples ## Generate proto files for the entire project.
buf generate --template protoc-gen-connect-kotlin/buf.gen.yaml -o protoc-gen-connect-kotlin protoc-gen-connect-kotlin/proto
buf generate --template extensions/buf.gen.yaml -o extensions buf.build/googleapis/googleapis
make licenseheaders
.PHONY: generateconformance
generateconformance: $(PROTOC) buildplugin ## Generate protofiles for conformance tests.
buf generate --template conformance/buf.gen.yaml -o conformance conformance/proto
.PHONY: generateexamples
generateexamples: $(PROTOC) buildplugin ## Generate proto files for example apps.
buf generate --template examples/buf.gen.yaml -o examples buf.build/connectrpc/eliza
.PHONY: help
help: ## Describe useful make targets.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}'
.PHONY: installandroid
installandroid: ## Install the example Android app.
./gradlew $(GRADLE_ARGS) examples:android:installDebug
.PHONY: licenseheaders
licenseheaders: $(BIN)/license-headers ## Format all files, adding license headers.
comm -23 \
<(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u ) \
<(git ls-files --deleted | sort -u) | \
xargs $(BIN)/license-header \
--license-type "apache" \
--copyright-holder "The Connect Authors" \
--year-range "$(LICENSE_HEADER_YEAR_RANGE)"
.PHONY: lint
lint: ## Run lint.
buf lint
./gradlew $(GRADLE_ARGS) spotlessCheck
.PHONY: lintfix
lintfix: ## Applies the lint changes.
./gradlew $(GRADLE_ARGS) spotlessApply
.PHONY: release
release: generate ## Upload artifacts to Sonatype Nexus.
./gradlew $(GRADLE_ARGS) --info publish --stacktrace --no-daemon --no-parallel
./gradlew $(GRADLE_ARGS) --info closeAndReleaseRepository
.PHONY: releaselocal
releaselocal: ## Release artifacts to local maven repository.
./gradlew $(GRADLE_ARGS) --info publishToMavenLocal
.PHONY: test
test: generate ## Run tests for the library.
./gradlew $(GRADLE_ARGS) library:test