mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Allow make to run from outside GOPATH
This commit is contained in:
parent
e967a773c4
commit
2a4495cf89
@ -199,7 +199,7 @@ DEEPCOPY_FILES := $(addsuffix /$(DEEPCOPY_FILENAME), $(DEEPCOPY_DIRS))
|
||||
.PHONY: gen_deepcopy
|
||||
gen_deepcopy: $(DEEPCOPY_FILES)
|
||||
if [[ -f $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \
|
||||
$(DEEPCOPY_GEN) \
|
||||
./hack/run-in-gopath.sh $(DEEPCOPY_GEN) \
|
||||
-i $$(cat $(META_DIR)/$(DEEPCOPY_GEN).todo | paste -sd, -) \
|
||||
--bounding-dirs $(PRJ_SRC_PATH) \
|
||||
-O $(DEEPCOPY_BASENAME); \
|
||||
@ -243,6 +243,7 @@ $(META_DIR)/$(DEEPCOPY_GEN).mk:
|
||||
-f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
|
||||
./cmd/libs/go2idl/deepcopy-gen \
|
||||
| grep "^$(PRJ_SRC_PATH)" \
|
||||
| sed 's|^$(PRJ_SRC_PATH)|./|' \
|
||||
| xargs go list -e -f '{{.Dir}} {{.Dir}}/*.go'); \
|
||||
echo $$DIRECT $$INDIRECT | sed 's/ / =,/g' | tr '=,' '\n\t'; \
|
||||
) | sed "s|$$(pwd -P)/||" > $@.tmp; \
|
||||
@ -309,7 +310,7 @@ CONVERSION_FILES := $(addsuffix /$(CONVERSION_FILENAME), $(CONVERSION_DIRS))
|
||||
.PHONY: gen_conversion
|
||||
gen_conversion: $(CONVERSION_FILES)
|
||||
if [[ -f $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \
|
||||
$(CONVERSION_GEN) \
|
||||
./hack/run-in-gopath.sh $(CONVERSION_GEN) \
|
||||
-i $$(cat $(META_DIR)/$(CONVERSION_GEN).todo | paste -sd, -) \
|
||||
-O $(CONVERSION_BASENAME); \
|
||||
fi
|
||||
@ -419,6 +420,7 @@ $(META_DIR)/$(CONVERSION_GEN).mk:
|
||||
-f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
|
||||
./cmd/libs/go2idl/conversion-gen \
|
||||
| grep "^$(PRJ_SRC_PATH)" \
|
||||
| sed 's|^$(PRJ_SRC_PATH)|./|' \
|
||||
| xargs go list -e -f '{{.Dir}} {{.Dir}}/*.go'); \
|
||||
echo $$DIRECT $$INDIRECT | sed 's/ / =,/g' | tr '=,' '\n\t'; \
|
||||
) | sed "s|$$(pwd -P)/||" > $@.tmp; \
|
||||
|
33
hack/run-in-gopath.sh
Executable file
33
hack/run-in-gopath.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This script sets up a temporary Kubernetes GOPATH and runs an arbitrary
|
||||
# command under it. Go tooling requires that the current directory be under
|
||||
# GOPATH or else it fails to find some things, such as the vendor directory for
|
||||
# the project.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
# This sets up a clean GOPATH and makes sure we are currently in it.
|
||||
kube::golang::setup_env
|
||||
|
||||
# Run the user-provided command.
|
||||
"${@}"
|
Loading…
Reference in New Issue
Block a user