@@ -33,17 +33,26 @@ cd $REPO_ROOT
3333echo " Ensuring go version."
3434source ./hack/build/setup-go.sh
3535
36- wrap-go-tool () {
37- local tool=" $1 "
38- local wrapper_name=" ${tool} -XXXX"
39- wrapper=" $( mktemp --tmpdir $wrapper_name ) "
40- printf ' #!/usr/bin/bash\n\ngo tool %s $@\n' " $tool " >> " $wrapper "
41- chmod +x " $wrapper "
42- echo " $wrapper "
43- }
44- PROTOC_GEN_GO_WRAPPER=" $( wrap-go-tool protoc-gen-go) "
45- PROTOC_GEN_GO_GRPC_WRAPPER=" $( wrap-go-tool protoc-gen-go-grpc) "
46-
36+ # build codegen tools
37+ echo " Install codegen tools."
38+ cd " hack/tools"
39+ clientgen=${REPO_ROOT} /_bin/client-gen
40+ go build -o " ${clientgen} " k8s.io/code-generator/cmd/client-gen
41+ deepcopygen=${REPO_ROOT} /_bin/deepcopy-gen
42+ go build -o " ${deepcopygen} " k8s.io/code-generator/cmd/deepcopy-gen
43+ informergen=${REPO_ROOT} /_bin/informer-gen
44+ go build -o " ${informergen} " k8s.io/code-generator/cmd/informer-gen
45+ listergen=${REPO_ROOT} /_bin/lister-gen
46+ go build -o " ${listergen} " k8s.io/code-generator/cmd/lister-gen
47+ go_bindata=${REPO_ROOT} /_bin/go-bindata
48+ go build -o " ${go_bindata} " github.com/go-bindata/go-bindata/v3/go-bindata
49+ controllergen=${REPO_ROOT} /_bin/controller-gen
50+ go build -o " ${controllergen} " sigs.k8s.io/controller-tools/cmd/controller-gen
51+ protoc_gen_go=" ${REPO_ROOT} /_bin/protoc-gen-go" # golang protobuf plugin
52+ GOBIN=
" ${REPO_ROOT} /_bin" go install google.golang.org/protobuf/cmd/
[email protected] 53+ GOBIN=
" ${REPO_ROOT} /_bin" go install google.golang.org/grpc/cmd/
[email protected] 54+
55+ cd " ${REPO_ROOT} "
4756ensure-protoc-deps () {
4857 # Install protoc
4958 if [[ ! -f " _bin/protoc/bin/protoc" ]]; then
@@ -88,15 +97,15 @@ gen-prow-config-documented() {
8897
8998gen-deepcopy () {
9099 echo " Generating DeepCopy() methods..." >&2
91- go tool deepcopy-gen ./... \
100+ " $deepcopygen " ./... \
92101 --go-header-file hack/boilerplate/boilerplate.generated.go.txt \
93102 --output-file zz_generated.deepcopy.go \
94103 --bounding-dirs sigs.k8s.io/prow/pkg/apis,sigs.k8s.io/prow/pkg/config
95104}
96105
97106gen-client () {
98107 echo " Generating client..." >&2
99- go tool client-gen \
108+ " $clientgen " \
100109 --go-header-file hack/boilerplate/boilerplate.generated.go.txt \
101110 --clientset-name versioned \
102111 --input-base " " \
@@ -105,7 +114,7 @@ gen-client() {
105114 --output-pkg sigs.k8s.io/prow/pkg/client/clientset
106115
107116 echo " Generating client for pipeline..." >&2
108- go tool client-gen \
117+ " $clientgen " \
109118 --go-header-file hack/boilerplate/boilerplate.generated.go.txt \
110119 --clientset-name versioned \
111120 --input-base " " \
@@ -116,29 +125,29 @@ gen-client() {
116125
117126gen-lister () {
118127 echo " Generating lister..." >&2
119- go tool lister-gen sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
128+ " $listergen " sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
120129 --go-header-file hack/boilerplate/boilerplate.generated.go.txt \
121130 --output-dir pkg/client/listers \
122131 --output-pkg sigs.k8s.io/prow/pkg/client/listers
123132
124133 echo " Generating lister for pipeline..." >&2
125- go tool lister-gen github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
134+ " $listergen " github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
126135 --go-header-file hack/boilerplate/boilerplate.generated.go.txt \
127136 --output-dir pkg/pipeline/listers \
128137 --output-pkg sigs.k8s.io/prow/pkg/pipeline/listers
129138}
130139
131140gen-informer () {
132141 echo " Generating informer..." >&2
133- go tool informer-gen sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
142+ " $informergen " sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
134143 --go-header-file hack/boilerplate/boilerplate.generated.go.txt \
135144 --versioned-clientset-package sigs.k8s.io/prow/pkg/client/clientset/versioned \
136145 --listers-package sigs.k8s.io/prow/pkg/client/listers \
137146 --output-dir pkg/client/informers \
138147 --output-pkg sigs.k8s.io/prow/pkg/client/informers
139148
140149 echo " Generating informer for pipeline..." >&2
141- go tool informer-gen github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
150+ " $informergen " github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
142151 --go-header-file hack/boilerplate/boilerplate.generated.go.txt \
143152 --versioned-clientset-package sigs.k8s.io/prow/pkg/pipeline/clientset/versioned \
144153 --listers-package sigs.k8s.io/prow/pkg/pipeline/listers \
@@ -149,14 +158,14 @@ gen-informer() {
149158gen-spyglass-bindata () {
150159 cd pkg/spyglass/lenses/common/
151160 echo " Generating spyglass bindata..." >&2
152- go tool go-bindata -pkg=common static/
161+ $go_bindata -pkg=common static/
153162 gofmt -s -w ./
154163 cd - > /dev/null
155164}
156165
157166gen-prowjob-crd () {
158167 echo " Generating prowjob crd..." >&2
159- go tool controller-gen crd:crdVersions=v1 paths=./pkg/apis/prowjobs/v1 output:stdout \
168+ " $controllergen " crd:crdVersions=v1 paths=./pkg/apis/prowjobs/v1 output:stdout \
160169 | $SED ' /^$/d' \
161170 | $SED ' /^spec:.*/a \ preserveUnknownFields: false' \
162171 | $SED ' /^ annotations.*/a \ api-approved.kubernetes.io: https://github.com/kubernetes/test-infra/pull/8669' \
@@ -184,21 +193,22 @@ gen-proto-stubs() {
184193 # structure (so that the generated files can sit next to the .proto files,
185194 # instead of under a "k8.io/test-infra/prow/..." subfolder).
186195 " ${REPO_ROOT} /_bin/protoc/bin/protoc" \
187- --plugin=protoc-gen-go=" $PROTOC_GEN_GO_WRAPPER " \
188- --plugin=protoc-gen-go-grpc=" $PROTOC_GEN_GO_GRPC_WRAPPER " \
189- --proto_path=" ${REPO_ROOT} /_bin/protoc/include/google/protobuf" \
190- --proto_path=" ${REPO_ROOT} /_bin/protoc/include/googleapis" \
191- --proto_path=" $dir " \
192- --go_out=" $dir " \
193- --go_opt=paths=source_relative \
194- --go-grpc_out=" $dir " \
195- --go-grpc_opt=paths=source_relative \
196+ " --plugin=${protoc_gen_go} " \
197+ " --proto_path=${REPO_ROOT} /_bin/protoc/include/google/protobuf" \
198+ " --proto_path=${REPO_ROOT} /_bin/protoc/include/googleapis" \
199+ " --proto_path=${dir} " \
200+ --go_out=" ${dir} " --go_opt=paths=source_relative \
201+ --go-grpc_out=" ${dir} " --go-grpc_opt=paths=source_relative \
196202 " $1 "
197203}
198204
199205gen-all-proto-stubs () {
200206 echo >&2 " Generating proto stubs"
201207
208+ # Expose the golang protobuf plugin binaries (protoc-gen-go,
209+ # protoc-gen-go-grpc) to the PATH so that protoc can find it.
210+ export PATH=" ${REPO_ROOT} /_bin:$PATH "
211+
202212 while IFS= read -r -d ' ' proto; do
203213 echo >&2 " $proto "
204214 gen-proto-stubs " $proto "
0 commit comments