forked from abiosoft/colima
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (58 loc) · 1.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
OS ?= $(shell uname)
ARCH ?= $(shell uname -m)
GOOS ?= $(shell echo "$(OS)" | tr '[:upper:]' '[:lower:]')
GOARCH_x86_64 = amd64
GOARCH_aarch64 = arm64
GOARCH_arm64 = arm64
GOARCH ?= $(shell echo "$(GOARCH_$(ARCH))")
VERSION := $(shell git describe --tags --always)
REVISION := $(shell git rev-parse HEAD)
PACKAGE := github.com/abiosoft/colima/config
VERSION_VARIABLES := -X $(PACKAGE).appVersion=$(VERSION) -X $(PACKAGE).revision=$(REVISION)
OUTPUT_DIR := _output/binaries
OUTPUT_BIN := colima-$(OS)-$(ARCH)
INSTALL_DIR := /usr/local/bin
BIN_NAME := colima
LDFLAGS := $(VERSION_VARIABLES)
.PHONY: all
all: build
.PHONY: clean
clean:
rm -rf _output _build
.PHONY: gopath
gopath:
go get -v ./cmd/colima
.PHONY: fmt
fmt:
go fmt ./...
goimports -w .
.PHONY: build
build:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags="$(LDFLAGS)" -o $(OUTPUT_DIR)/$(OUTPUT_BIN) ./cmd/colima
cd $(OUTPUT_DIR) && openssl sha256 -r -out $(OUTPUT_BIN).sha256sum $(OUTPUT_BIN)
.PHONY: test
test:
go test -v -ldflags="$(LD_FLAGS)" ./...
.PHONY: vmnet
vmnet:
sh scripts/build_vmnet.sh
.PHONY: install
install:
mkdir -p $(INSTALL_DIR)
rm -f $(INSTALL_DIR)/$(BIN_NAME)
cp $(OUTPUT_DIR)/colima-$(OS)-$(ARCH) $(INSTALL_DIR)/$(BIN_NAME)
chmod +x $(INSTALL_DIR)/$(BIN_NAME)
.PHONY: lint
lint: ## Assumes that golangci-lint is installed and in the path. To install: https://golangci-lint.run/usage/install/
golangci-lint --timeout 3m run
.PHONY: print-binary-name
print-binary-name:
@echo $(OUTPUT_DIR)/$(OUTPUT_BIN)
.PHONY: nix-derivation-shell
nix-derivation-shell:
$(eval DERIVATION=$(shell nix-build))
echo $(DERIVATION) | grep ^/nix
nix-shell -p $(DERIVATION)
.PHONY: integration
integration: build
GOARCH=$(GOARCH) COLIMA_BINARY=$(OUTPUT_DIR)/$(OUTPUT_BIN) scripts/integration.sh