This repository was archived by the owner on Sep 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (41 loc) · 1.54 KB
/
Makefile
File metadata and controls
52 lines (41 loc) · 1.54 KB
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
PKG_NAME:=github.com/sapcc/lyra-cli
BUILD_IMAGE:=golang:1.23
TARGETS:=linux/amd64 windows/amd64 darwin/amd64 darwin/arm64
LYRA_CLI_BIN_TPL:=lyra_cli_{{.OS}}_{{.Arch}}
ifneq ($(BUILD_VERSION),)
LDFLAGS += -X github.com/sapcc/lyra-cli/version.Version=$(BUILD_VERSION)
LYRA_CLI_BIN_TPL:=lyra_cli_$(BUILD_VERSION)_{{.OS}}_{{.Arch}}
endif
.PHONY: help
help:
@echo
@echo "Available targets:"
@echo " * test - run metalint and unit"
@echo " * unit - run unit tests"
@echo " * metalint - linter which runs a number of other linters against your files, and normalises their output to a standard format."
@echo " * cross - cross compile for darwin, windows, linux (requires docker)"
packages = $(PKG_NAME) $(shell go list -f '{{ join .Deps "\n" }}' | grep -v vendor | grep $(PKG_NAME))
.PHONY: test
test: metalint unit
.PHONY: unit
unit:
go test -v -timeout=120s ./...
.PHONY: metalint
metalint:
docker run --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.60.3 golangci-lint run -v
.PHONY: bin/lyra_cli
bin/lyra_cli:
go build -o "bin/lyra_cli" -ldflags="$(LDFLAGS)" $(PKG_NAME)
.PHONY: cross
cross:
@# -w omit DWARF symbol table -> smaller
@# -s stip binary
docker run \
--rm \
-v $(CURDIR):/go/src/$(PKG_NAME) \
-w /go/src/$(PKG_NAME) \
$(BUILD_IMAGE) \
go install github.com/mitchellh/gox && make cross-compile TARGETS="$(TARGETS)" BUILD_VERSION=$(BUILD_VERSION)
.PHONY: cross-compile
cross-compile:
gox -osarch="$(TARGETS)" -output="bin/$(LYRA_CLI_BIN_TPL)" -ldflags="$(LDFLAGS)" $(PKG_NAME)