-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMakefile
83 lines (72 loc) · 3.22 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
# 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
LICENSE_HEADER_YEAR_RANGE := 2022-2023
CONFORMANCE_VERSION := 8e6893a4b801c282eb6cf9ad03d38b993b66ca66
LICENSE_HEADER_VERSION := v1.12.0
LICENSE_IGNORE := -e Package.swift \
-e $(BIN)\/ \
-e Examples/ElizaSharedSources/GeneratedSources\/ \
-e Libraries/Connect/Implementation/Generated\/ \
-e Tests/ConnectLibraryTests/proto/grpc\/ \
-e Tests/ConnectLibraryTests/Generated\/
.PHONY: buildpackage
buildpackage: ## Build all targets in the Swift package
swift build
.PHONY: buildplugins
buildplugins: ## Build all plugin binaries
mkdir -p $(BIN)
swift build -c release --product protoc-gen-connect-swift
mv ./.build/release/protoc-gen-connect-swift $(BIN)
swift build -c release --product protoc-gen-connect-swift-mocks
mv ./.build/release/protoc-gen-connect-swift-mocks $(BIN)
@echo "Success! Plugins are available in $(BIN)"
.PHONY: clean
clean: cleangenerated ## Delete all plugins and generated outputs
rm -rf $(BIN)
.PHONY: cleangenerated
cleangenerated: ## Delete all generated outputs
rm -rf ./Examples/ElizaSharedSources/GeneratedSources/*
rm -rf ./Libraries/Connect/Implementation/Generated/*
rm -rf ./Tests/ConnectLibraryTests/Generated/*
.PHONY: conformanceserverstop
conformanceserverstop: ## Stop the conformance server
-docker container stop serverconnect servergrpc
.PHONY: conformanceserverrun
conformanceserverrun: conformanceserverstop ## Start the conformance server
docker run --rm --name serverconnect -p 8080:8080 -p 8081:8081 -d \
connectrpc/conformance:$(CONFORMANCE_VERSION) \
/usr/local/bin/serverconnect --h1port "8080" --h2port "8081" --cert "cert/localhost.crt" --key "cert/localhost.key"
docker run --rm --name servergrpc -p 8083:8083 -d \
connectrpc/conformance:$(CONFORMANCE_VERSION) \
/usr/local/bin/servergrpc --port "8083" --cert "cert/localhost.crt" --key "cert/localhost.key"
.PHONY: generate
generate: cleangenerated ## Regenerate outputs for all .proto files
cd Examples; buf generate
cd Libraries/Connect; buf generate
cd Tests/ConnectLibraryTests; buf generate https://github.com/connectrpc/conformance.git#ref=$(CONFORMANCE_VERSION),subdir=proto
.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: licenseheaders
licenseheaders: $(BIN)/license-headers ## Add/reformat license headers in source files
comm -23 \
<(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u | grep -v $(LICENSE_IGNORE) ) \
<(git ls-files --deleted | sort -u) | \
xargs $(BIN)/license-header \
--license-type "apache" \
--copyright-holder "The Connect Authors" \
--year-range "$(LICENSE_HEADER_YEAR_RANGE)"
$(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: test
test: conformanceserverrun ## Run all tests
swift test
$(MAKE) conformanceserverstop