1# Protocol Buffers for Go with Gadgets
2#
3# Copyright (c) 2013, The GoGo Authors. All rights reserved.
4# http://github.com/gogo/protobuf
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10#     * Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12#     * Redistributions in binary form must reproduce the above
13# copyright notice, this list of conditions and the following disclaimer
14# in the documentation and/or other materials provided with the
15# distribution.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29GO_VERSION:=$(shell go version)
30BENCHLIST?=all
31
32# Skip known issues from purego tests
33# https://github.com/gogo/protobuf/issues/447
34# https://github.com/gogo/protobuf/issues/448
35SKIPISSUE:="/jsonpb|/test/casttype/|/test/oneof/combos/"
36
37.PHONY: nuke regenerate tests clean install gofmt vet contributors
38
39all: clean install regenerate install tests errcheck vet
40
41buildserverall: clean install regenerate install tests vet js purego
42
43install:
44	go install ./proto
45	go install ./gogoproto
46	go install ./jsonpb
47	go install ./protoc-gen-gogo
48	go install ./protoc-gen-gofast
49	go install ./protoc-gen-gogofast
50	go install ./protoc-gen-gogofaster
51	go install ./protoc-gen-gogoslick
52	go install ./protoc-gen-gostring
53	go install ./protoc-min-version
54	go install ./protoc-gen-combo
55	go install ./gogoreplace
56
57clean:
58	go clean ./...
59
60nuke:
61	go clean -i -cache ./...
62
63gofmt:
64	gofmt -l -s -w .
65
66regenerate:
67	make -C protoc-gen-gogo regenerate
68	make -C gogoproto regenerate
69	make -C proto/test_proto regenerate
70	make -C proto/proto3_proto regenerate
71	make -C jsonpb/jsonpb_test_proto regenerate
72	make -C conformance regenerate
73	make -C protobuf regenerate
74	make -C test regenerate
75	make -C test/example regenerate
76	make -C test/unrecognized regenerate
77	make -C test/group regenerate
78	make -C test/unrecognizedgroup regenerate
79	make -C test/enumstringer regenerate
80	make -C test/unmarshalmerge regenerate
81	make -C test/moredefaults regenerate
82	make -C test/issue8 regenerate
83	make -C test/enumprefix regenerate
84	make -C test/enumcustomname regenerate
85	make -C test/packed regenerate
86	make -C test/protosize regenerate
87	make -C test/tags regenerate
88	make -C test/oneof regenerate
89	make -C test/oneof3 regenerate
90	make -C test/theproto3 regenerate
91	make -C test/mapdefaults regenerate
92	make -C test/mapsproto2 regenerate
93	make -C test/issue42order regenerate
94	make -C proto generate-test-pbs
95	make -C test/importdedup regenerate
96	make -C test/importduplicate regenerate
97	make -C test/custombytesnonstruct regenerate
98	make -C test/required regenerate
99	make -C test/casttype regenerate
100	make -C test/castvalue regenerate
101	make -C vanity/test regenerate
102	make -C test/sizeunderscore regenerate
103	make -C test/issue34 regenerate
104	make -C test/empty-issue70 regenerate
105	make -C test/indeximport-issue72 regenerate
106	make -C test/fuzztests regenerate
107	make -C test/oneofembed regenerate
108	make -C test/asymetric-issue125 regenerate
109	make -C test/filedotname regenerate
110	make -C test/nopackage regenerate
111	make -C test/types regenerate
112	make -C test/proto3extension regenerate
113	make -C test/stdtypes regenerate
114	make -C test/data regenerate
115	make -C test/typedecl regenerate
116	make -C test/issue260 regenerate
117	make -C test/issue261 regenerate
118	make -C test/issue262 regenerate
119	make -C test/issue312 regenerate
120	make -C test/enumdecl regenerate
121	make -C test/typedecl_all regenerate
122	make -C test/enumdecl_all regenerate
123	make -C test/int64support regenerate
124	make -C test/issue322 regenerate
125	make -C test/issue330 regenerate
126	make -C test/importcustom-issue389 regenerate
127	make -C test/merge regenerate
128	make -C test/cachedsize regenerate
129	make -C test/deterministic regenerate
130	make -C test/issue438 regenerate
131	make -C test/issue444 regenerate
132	make -C test/issue449 regenerate
133	make -C test/xxxfields regenerate
134	make -C test/issue435 regenerate
135	make -C test/issue411 regenerate
136	make -C test/issue498 regenerate
137	make -C test/issue503 regenerate
138	make -C test/issue530 regenerate
139	make -C test/issue617 regenerate
140	make -C test/issue620 regenerate
141	make -C test/protobuffer regenerate
142	make -C test/issue630 regenerate
143
144	make gofmt
145
146tests:
147	go build ./test/enumprefix
148	go test ./...
149	(cd test/stdtypes && make test)
150
151vet:
152	go get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
153	go vet ./...
154	go vet -vettool=$(shell which shadow) ./...
155
156errcheck:
157	go get github.com/kisielk/errcheck
158	errcheck ./test/...
159
160drone:
161	sudo apt-get install protobuf-compiler
162	(cd $(GOPATH)/src/github.com/gogo/protobuf && make buildserverall)
163
164testall:
165	go get -u github.com/golang/protobuf/proto
166	make -C protoc-gen-gogo test
167	make -C vanity/test test
168	make -C test/registration test
169	make -C conformance test
170	make -C test/issue427 test
171	make tests
172
173bench:
174	go get golang.org/x/tools/cmd/benchcmp
175	(cd test/mixbench && go build .)
176	./test/mixbench/mixbench -benchlist "${BENCHLIST}"
177
178contributors:
179	git log --format='%aN <%aE>' | sort -fu > CONTRIBUTORS
180
181js:
182ifeq (go1.12, $(findstring go1.12, $(GO_VERSION)))
183	go get -u github.com/gopherjs/gopherjs
184	gopherjs build github.com/gogo/protobuf/protoc-gen-gogo
185endif
186
187purego:
188	go test -tags purego $$(go list ./... | grep -Ev $(SKIPISSUE))
189
190update:
191	(cd protobuf && make update)
192