-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (50 loc) · 1.52 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
default: build
.PHONY: build
build:
go build -v -o bin/minimediaserver ./cmd
# Cross-compile
.PHONY: build-cross
build-cross: build build-macos build-rpi4
# https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-16-04#step-4-building-executables-for-different-architectures
.PHONY: build-macos
build-macos:
GOOS=darwin GOARCH=amd64 go build -v -o bin/minimediaserver.macos-amd64 ./cmd
# https://mansfield-devine.com/speculatrix/2019/02/go-on-raspberry-pi-simple-cross-compiling/
# https://github.com/golang/go/wiki/GoArm
build-rpi4:
GOOS=linux GOARCH=arm64 go build -v -o bin/minimediaserver.rpi4-arm64 ./cmd
.PHONY: run
run:
go run ./cmd
@echo
.PHONY: test
test:
go test -v ./...
@echo
.PHONY: lint
lint: lint-go lint-js
jq . config-example.json
.PHONY: lint-go
lint-go:
sudo docker run -t --rm -v $$(pwd):/app -w /app golangci/golangci-lint:v1.52.2 golangci-lint run -v
.PHONY: lint-js
lint-js:
npx eslint cmd/static
@echo
# TODO: Add -race -covermode=atomic later?
# E.g.: when fetching tracks from multiple clients?
.PHONE: coverage
coverage:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Requires 'reflex' from https://github.com/cespare/reflex
# to be in the path.
WATCHREGEX = '(\.go|\.tmpl\.html|\.js|\.css|\.mod|\.sum)$$'
watch:
reflex -r $(WATCHREGEX) -s -- make run
watchtest:
reflex -r $(WATCHREGEX) -s -- make test
watchcoverage:
reflex -r $(WATCHREGEX) -s -- make coverage
clean:
rm -fv bin/minimediaserver*