forked from ashirt-ops/aterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (61 loc) · 1.85 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
76
77
78
79
80
include .env
DEV_VERSION_FLAG=-X github.com/jrozner/go-info.version=v0.0.0-development
DEV_COMMIT_FLAG=-X github.com/jrozner/go-info.commitHash=$(shell git rev-list -1 HEAD)
DEV_DATE_FLAG=-X github.com/jrozner/go-info.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
DEV_REPO_FLAG=-X github.com/theparanoids/aterm/cmd/aterm/config.codeRepoRaw=theparanoids/aterm
LD_FLAGS=-ldflags "$(DEV_VERSION_FLAG) $(DEV_COMMIT_FLAG) $(DEV_DATE_FLAG) $(DEV_REPO_FLAG)"
.env:
cp .env_template .env
.PHONY: update
update:
go mod download
# tidy removes unused/outdated go modules.
.PHONY: tidy
tidy-go:
go mod tidy
.PHONY: clean
clean:
rm -rf dist/aterm/*
.PHONY: test
test:
go test ./...
.PHONY: format
format:
gofmt -w .
.PHONY: build-all
build-all: build-linux build-osx
.PHONY: build-test
build-test: update
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(LD_FLAGS) -o dist/aterm/linux/aterm cmd/aterm/*.go
.PHONY: build-linux
build-linux: update
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(LD_FLAGS) -o dist/aterm/linux/aterm cmd/aterm/*.go
.PHONY: build-osx
build-osx: update
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(LD_FLAGS) -o dist/aterm/osx/aterm cmd/aterm/*.go
.PHONY: run-env
run-env:
echo "loading settings from env file"
$(eval export $(shell sed -ne 's/ *#.*$$//; /./ s/=.*$$// p' .env))
go run cmd/aterm/*.go
.PHONY: run
run:
go run $(LD_FLAGS) cmd/aterm/*.go
.PHONY: run-menu
run-menu:
go run $(LD_FLAGS) cmd/aterm/*.go -menu
.PHONY: run-version
run-version:
go run $(LD_FLAGS) cmd/aterm/*.go -version
.PHONY: run-reset-hard
run-reset-hard:
go run $(LD_FLAGS) cmd/aterm/*.go -reset-hard
.PHONY: run-help
run-help:
go run $(LD_FLAGS) cmd/aterm/*.go -h
.PHONY: debug
debug:
go run $(LD_FLAGS) cmd/aterm/*.go 2>debug.log
# prep is shorthand for formatting and testing. Useful when prepping for a new Pull Request.
.PHONY: prep
prep: format test