-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
86 lines (67 loc) · 2.65 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
81
82
83
84
85
86
# Copyright 2020 Marius Wilms, Christoph Labacher. All rights reserved.
# Copyright 2017 Atelier Disko. All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
FRONTEND ?= $(shell pwd)/frontend/build
DDT ?= $(shell pwd)/../example-design-system
VERSION ?= head-$(shell git rev-parse --short HEAD)
LDFLAGS = -X main.Version=$(VERSION)
ANY_DEPS = $(shell find cmd internal)
ALL_PKGS = $(shell go list ./...)
CMD_PKG = github.com/rundsk/dsk/cmd/dsk
.PHONY: test
test:
go test -tags=dev -race -ldflags "$(LDFLAGS)" $(ALL_PKGS)
.PHONY: bench
bench:
go test -tags=dev -run XXX -bench -ldflags "$(LDFLAGS)" .
.PHONY: profile
profile:
go test -tags=dev -run ^$$ -bench . -cpuprofile cpu.prof -memprofile mem.prof -mutexprofile mutex.prof $(ALL_PKGS)
.PHONY: lint
lint: internal/frontend/vfsdata.go
go vet -all $(shell go list ./...)
.PHONY: dev
dev: internal/frontend/vfsdata.go
go build -tags=dev -ldflags "$(LDFLAGS)" $(CMD_PKG)
./dsk -frontend $(FRONTEND) "$(DDT)"
rm dsk
.PHONY: clean
clean:
if [ -f ./internal/frontend/vfsdata.go ]; then rm ./internal/frontend/vfsdata.go; fi
if [ -d ./dist ]; then rm -r ./dist; fi
if [ -f ./dsk ]; then rm ./dsk; fi
if [ -f ./dsk.test ]; then rm ./dsk.test; fi
if [ -f ./cpu.prof ]; then rm ./cpu.prof; fi
if [ -f ./mem.prof ]; then rm ./mem.prof; fi
.PHONY: dist
dist: dist/dsk-darwin-amd64 dist/dsk-linux-amd64 dist/dsk-windows-386.exe
dist: dist/dsk-darwin-amd64.zip dist/dsk-linux-amd64.tar.gz dist/dsk-windows-386.zip
dist: container-image
ls -lh dist
.PHONY: container-image
container-image:
docker buildx build --tag rundsk/dsk:$(VERSION) --build-arg VERSION=$(VERSION) .
.PHONY: container-push
container-push: container-image
docker push rundsk/dsk:$(VERSION)
dist/%.zip: dist/%
cd dist && zip $(notdir $@) $(notdir $<)
cd example && zip -r ../$@ .
dist/dsk-windows-386.zip: dist/dsk-windows-386.exe
cd dist && zip $(notdir $@) $(notdir $<)
cd example && zip -r ../$@ .
dist/%.tar: dist/%
cd dist && tar -cpvf $(notdir $@) $(notdir $<)
cd example && tar -rvf ../$@ .
dist/%.tar.gz: | dist/%.tar
gzip $(basename $@)
dist/%-darwin-amd64: $(ANY_DEPS) internal/frontend/vfsdata.go
GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS) -s -w" -o $@ $(CMD_PKG)
dist/%-linux-amd64: $(ANY_DEPS) internal/frontend/vfsdata.go
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS) -s -w" -o $@ $(CMD_PKG)
dist/%-windows-386.exe: $(ANY_DEPS) internal/frontend/vfsdata.go
GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS) -s -w" -o $@ $(CMD_PKG)
internal/frontend/vfsdata.go: $(shell find $(FRONTEND) -type f)
FRONTEND=$(FRONTEND) go run cmd/frontend/generate.go