@@ -8,7 +8,7 @@ EXEC_NAME := $(OUTPUT_DIR)/protoc-gen-ext
8
8
SOURCES := $(shell find . -name "* .go" | grep -v test.go)
9
9
VERSION ?= $(shell git describe --tags)
10
10
11
- GO_BUILD_FLAGS := GO111MODULE=on CGO_ENABLED=0 GOARCH=amd64
11
+ GO_BUILD_FLAGS := GO111MODULE=on CGO_ENABLED=0
12
12
GCFLAGS := 'all=-N -l'
13
13
14
14
@@ -44,14 +44,14 @@ GO_IMPORT_SPACES := ${EXT_IMPORT},\
44
44
GO_IMPORT: =$(subst $(space ) ,,$(GO_IMPORT_SPACES ) )
45
45
46
46
47
- PHONE : generated-code
47
+ .PHONY : generated-code
48
48
generated-code :
49
- PATH=$(DEPSGOBIN ) :$$ PATH protoc -I=. --go_out=" ${EXT_IMPORT} :." extproto/ext.proto
49
+ PATH=$(DEPSGOBIN ) :$$ PATH $( DEPSGOBIN ) / protoc -I=. -I=./external --go_out=" ${EXT_IMPORT} :." extproto/ext.proto
50
50
PATH=$(DEPSGOBIN ) :$$ PATH cp -r ${PACKAGE} /extproto/* extproto
51
- PATH=$(DEPSGOBIN ) :$$ PATH protoc -I=. -I=./extproto --go_out=" ." --ext_out=" ." tests/api/hello.proto
51
+ PATH=$(DEPSGOBIN ) :$$ PATH $( DEPSGOBIN ) / protoc -I=. -I=./extproto -I=./external --go_out=" ." --ext_out=" ." tests/api/hello.proto
52
52
PATH=$(DEPSGOBIN ) :$$ PATH cp -r ${PACKAGE} /tests/api/* tests/api/
53
53
PATH=$(DEPSGOBIN ) :$$ PATH rm -rf github.com
54
- PATH=$(DEPSGOBIN ) :$$ PATH goimports -w .
54
+ PATH=$(DEPSGOBIN ) :$$ PATH $( DEPSGOBIN ) / goimports -w .
55
55
56
56
57
57
DEPSGOBIN =$(shell pwd) /_output/.bin
@@ -64,8 +64,39 @@ install-go-tools: install
64
64
GOBIN=$(DEPSGOBIN ) go install golang.org/x/tools/cmd/goimports
65
65
GOBIN=$(DEPSGOBIN ) go install github.com/onsi/ginkgo/ginkgo
66
66
67
+ # proto compiler installation
68
+ # no explicit arm build, but x86_64 build works on arm macs
69
+ PROTOC_VERSION: =3.15.8
70
+ PROTOC_URL: =https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}
71
+ .PHONY : install-protoc
72
+ install-protoc :
73
+ if [ $( shell ${DEPSGOBIN} /protoc --version | grep -c ${PROTOC_VERSION} ) -ne 0 ]; then \
74
+ echo expected protoc version ${PROTOC_VERSION} already installed ; \
75
+ else \
76
+ if [ " $( shell uname) " == " Darwin" ]; then \
77
+ echo " downloading protoc for osx" ; \
78
+ wget $(PROTOC_URL ) -osx-x86_64.zip -O $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} .zip ; \
79
+ elif [ " $( shell uname -m) " == " aarch64" ]; then \
80
+ echo " downloading protoc for linux aarch64" ; \
81
+ wget $(PROTOC_URL ) -linux-aarch_64.zip -O $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} .zip ; \
82
+ else \
83
+ echo " downloading protoc for linux x86-64" ; \
84
+ wget $(PROTOC_URL ) -linux-x86_64.zip -O $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} .zip ; \
85
+ fi ; \
86
+ unzip $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} .zip -d $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} ; \
87
+ mv $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} /bin/protoc $(DEPSGOBIN ) /protoc ; \
88
+ chmod +x $(DEPSGOBIN ) /protoc ; \
89
+ @echo manage google protos too, since we have a folder of them based on the protoc version ; \
90
+ rm -Rf $(shell pwd) /external/google/protobuf/* ; \
91
+ mv $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} /include/google/protobuf/* .proto $(shell pwd) /external/google/protobuf ; \
92
+ rm -rf $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} $(DEPSGOBIN ) /protoc-${PROTOC_VERSION} .zip ; \
93
+ fi
94
+
95
+ .PHONY : install-tools
96
+ install-tools : install-go-tools install-protoc
97
+
67
98
.PHONY : run-tests
68
- run-tests : install-go-tools
99
+ run-tests :
69
100
$(DEPSGOBIN ) /ginkgo -r -failFast -trace -progress -race -compilers=4 -failOnPending -noColor $(TEST_PKG )
70
101
71
102
$(EXEC_NAME ) :
0 commit comments