Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ TARGET_OS ?= linux
BUILD_GO_FLAGS := -tags osusergo
BUILD_GO_FLAGS += -asmflags "all=-trimpath=$(shell dirname $(PWD))"
BUILD_GO_FLAGS += -gcflags "all=-trimpath=$(shell dirname $(PWD))"
BUILD_GO_LDFLAGS_EXTRA := -extldflags=-static
ifeq ($(shell go env GOOS),darwin)
BUILD_GO_LDFLAGS_EXTRA =
endif

LD_FLAGS := -X main.goos=$(shell go env GOOS)
LD_FLAGS += -X main.goarch=$(shell go env GOARCH)
LD_FLAGS += -X main.gitCommit=$(shell git rev-parse HEAD)
LD_FLAGS += -X main.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
LD_FLAGS += $(BUILD_GO_LDFLAGS_EXTRA)

GO_SRCS := $(shell find . -type f -name '*.go' -not -name '*_test.go' -not -name 'zz_generated*')

Expand All @@ -34,7 +40,7 @@ all: clean lint test build ## Run all commands to build the tool
.PHONY: clean
clean: ## Clean the bin directory
rm -rf $(BIN_DIR)
rm -rf static/bin/k0s
rm -rf static/bin
rm -rf static/helm/*tgz
$(MAKE) -C inttest clean

Expand Down Expand Up @@ -62,13 +68,22 @@ static/helm/000-admin-console-$(admin_console_version).tgz: helm

##@ Development

GOLANGCI_LINT = $(BIN_DIR)/golangci-lint
.PHONY: golangci-lint
golangci-lint:
@[ -f $(GOLANGCI_LINT) ] || { \
set -e ;\
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b $(shell dirname $(GOLANGCI_LINT));\
}

.PHONY: lint
lint: golangci-lint go.sum ## Run golangci-lint linter
golangci-lint run
$(GOLANGCI_LINT) run --timeout=5m

.PHONY: lint-fix
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
golangci-lint run --fix
lint-fix: golangci-lint go.sum ## Run golangci-lint linter and perform fixes
$(GOLANGCI_LINT) run --timeout=5m --fix

.PHONY: test
test: GO_TEST_RACE ?= -race
Expand All @@ -82,15 +97,6 @@ $(smoketests): build
.PHONY: smoketests
smoketests: $(smoketests)

GOLANGCI_LINT = $(BIN_DIR)/golangci-lint
.PHONY: golangci-lint
golangci-lint:
@[ -f $(GOLANGCI_LINT) ] || { \
set -e ;\
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b $(shell dirname $(GOLANGCI_LINT));\
}

.PHONY: helm
helm:
@mkdir -p $(BIN_DIR)
Expand Down