Skip to content

Commit 22d0b2a

Browse files
committed
Allow overriding binaries installed by hack/go-install.sh
Makefile targets for binary dependencies (i.e. code-generator, openshift-goimports and golangci-lint) now use version-less filepaths: `$(TOOLS_DIR)/<Binary>` instead of `$(TOOLS_DIR)/<Binary>-<Version>` `$(TOOLS_DIR)/<Binary>` may be a symlink to the versioned executable file. Secondly, hack/go-install.sh now adds a check for `$(TOOLS_DIR)/<Binary>` to be present and executable, in which case it skips `go install` invocation. This allows for making local changes to these dependencies (e.g. when working on kcp-dev/code-generator) and generating client code. On-behalf-of: SAP robert.vasek@sap.com Signed-off-by: Robert Vasek <robert.vasek@clyso.com>
1 parent 6f3a538 commit 22d0b2a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ TMPDIR := $(shell mktemp -d)
2525

2626
CODE_GENERATOR_VER := v2.3.0
2727
CODE_GENERATOR_BIN := code-generator
28-
CODE_GENERATOR := $(TOOLS_DIR)/$(CODE_GENERATOR_BIN)-$(CODE_GENERATOR_VER)
28+
CODE_GENERATOR := $(TOOLS_DIR)/$(CODE_GENERATOR_BIN)
2929
export CODE_GENERATOR # so hack scripts can use it
3030

3131
$(CODE_GENERATOR):
3232
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/kcp-dev/code-generator/v2 $(CODE_GENERATOR_BIN) $(CODE_GENERATOR_VER)
3333

3434
OPENSHIFT_GOIMPORTS_VER := c70783e636f2213cac683f6865d88c5edace3157
3535
OPENSHIFT_GOIMPORTS_BIN := openshift-goimports
36-
OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)-$(OPENSHIFT_GOIMPORTS_VER)
36+
OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)
3737
export OPENSHIFT_GOIMPORTS # so hack scripts can use it
3838

3939
$(OPENSHIFT_GOIMPORTS):
@@ -45,7 +45,7 @@ imports: $(OPENSHIFT_GOIMPORTS)
4545

4646
GOLANGCI_LINT_VER := v1.58.1
4747
GOLANGCI_LINT_BIN := golangci-lint
48-
GOLANGCI_LINT := $(TOOLS_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
48+
GOLANGCI_LINT := $(TOOLS_DIR)/$(GOLANGCI_LINT_BIN)
4949

5050
$(GOLANGCI_LINT):
5151
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)

hack/go-install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ if [ -z "${GOBIN}" ]; then
4141
exit 1
4242
fi
4343

44+
# An executable already exists, exit early.
45+
[[ -f "${GOBIN}/${2}" && -x $(realpath "${GOBIN}/${2}") ]] && exit 0
46+
4447
rm -f "${GOBIN}/${2}"* || true
4548

4649
# install the golang module specified as the first argument

0 commit comments

Comments
 (0)