This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
70 lines (57 loc) · 2.15 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
include .env
export
APP_NAME := export-komoot
REVISION := $(shell git rev-parse --short HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD | tr -d '\040\011\012\015\n')
BUILD_CMD := go build -buildvcs -ldflags "-s -w -X $(PACKAGE).GitRevision=$(REVISION) -X $(PACKAGE).GitBranch=$(BRANCH)" -trimpath
init:
@go mod download
build: init
$(call build-binary)
test:
@$(GO) test -cover `go list ./... | grep -v cmd`
run-incremental: build
@DEBUG=0 ./$(APP_NAME) --email "$(KOMOOT_EMAIL)" --password "$(KOMOOT_PASSWD)" --to "export"
run-full: build
@DEBUG=0 ./$(APP_NAME) --email "$(KOMOOT_EMAIL)" --password "$(KOMOOT_PASSWD)" --to "export" --fulldownload
run-filter: build
@DEBUG=0 ./$(APP_NAME) --email "$(KOMOOT_EMAIL)" --password "$(KOMOOT_PASSWD)" --to "export" --fulldownload --filter "*KK*"
help: build
@DEBUG=0 ./$(APP_NAME) --help
build-all:
@rm -f ./$(APP_NAME)-*
$(call build-binary-mac)
$(call build-binary-linux)
$(call build-binary-windows)
## Helper functions
define build-binary
@GOOS=$(1) GOARCH=$(2) $(BUILD_CMD) -o $(APP_NAME)
endef
define build-binary-mac
@echo "Building $(APP_NAME) for macos"
$(call build-binary,darwin,arm64,arm64)
@mv $(APP_NAME) $(APP_NAME)-arm
$(call build-binary,darwin,amd64,x86_64)
@mv $(APP_NAME) $(APP_NAME)-x86
@lipo -create -output $(APP_NAME) $(APP_NAME)-x86 $(APP_NAME)-arm
@tar czf ./$(APP_NAME)-$(REVISION)-macos.tar.gz $(APP_NAME)
@rm -f $(APP_NAME)-x86 $(APP_NAME)-arm $(APP_NAME)
endef
define build-binary-linux
@echo "Building $(APP_NAME) for linux"
$(call build-binary,linux,arm64,arm64)
@tar czf ./$(APP_NAME)-$(REVISION)-linux-arm64.tar.gz $(APP_NAME)
$(call build-binary,linux,amd64,x86_64)
@tar czf ./$(APP_NAME)-$(REVISION)-linux-x86_64.tar.gz $(APP_NAME)
@rm -f $(APP_NAME)
endef
define build-binary-windows
@echo "Building $(APP_NAME) for windows"
@$(call build-binary,windows,arm64,arm64)
@mv ./$(APP_NAME) ./$(APP_NAME).exe
@zip -rq ./$(APP_NAME)-$(REVISION)-windows-arm64.zip $(APP_NAME).exe
@$(call build-binary,windows,amd64,x86_64)
@mv ./$(APP_NAME) ./$(APP_NAME).exe
@zip -rq ./$(APP_NAME)-$(REVISION)-windows-x86_64.zip $(APP_NAME).exe
@rm -f $(APP_NAME).exe $(APP_NAME)
endef