-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (70 loc) · 2.09 KB
/
Makefile
File metadata and controls
89 lines (70 loc) · 2.09 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
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
87
88
89
ifeq ($(OS),Windows_NT)
SHELL=CMD.EXE
NUL=NUL
DEL=del
SET=set
WHICH=where.exe
ifeq ($(shell go env GOOS),windows)
SYSO=nyagos.syso
else
SYSO=
endif
else
NUL=/dev/null
SET=export
WHICH=which
DEL=rm
SYSO=
endif
ifndef GO
SUPPORTGO=go1.20.14
GO:=$(shell $(WHICH) $(SUPPORTGO) 2>$(NUL) || echo go)
endif
NAME:=$(notdir $(CURDIR))
VERSION:=$(shell git describe --tags 2>$(NUL) || echo v0.0.0)
GOOPT:=-ldflags "-s -w -X main.version=$(VERSION)"
EXE:=$(shell go env GOEXE)
build:
$(GO) fmt ./...
$(SET) "CGO_ENABLED=0" && $(GO) build $(GOOPT)
define tstlua1
"./nyagos" --norc -f "$(1)"
endef
define tstlua2
"$(1)"
endef
test:
$(GO) test -v ./...
$(foreach I,$(wildcard test/lua/*.lua),$(call tstlua1,$(I)))
ifeq ($(OS),Windows_NT)
$(foreach I,$(wildcard test/cmd/*.cmd),$(call tstlua2,$(I)))
endif
clean:
-$(DEL) nyagos.exe nyagos nyagos.syso 2>$(NUL)
_dist:
$(SET) "CGO_ENABLED=0" && $(GO) build $(GOOPT)
zip -9 "nyagos-$(VERSION)-$(GOOS)-$(GOARCH).zip" \
"nyagos$(EXE)" .nyagos \
"nyagos.d/catalog/*.lua" \
$(FILES)
dist:
$(SET) "GOPROXY=direct" && $(GO) generate -C Etc
$(SET) "GOOS=windows" && $(SET) "GOARCH=386" && $(MAKE) _dist "FILES=makeicon.cmd"
$(SET) "GOOS=windows" && $(SET) "GOARCH=amd64" && $(MAKE) _dist "FILES=makeicon.cmd"
$(SET) "GOOS=linux" && $(SET) "GOARCH=amd64" && $(MAKE) _dist
LATEST=$(GO) run github.com/hymkor/latest-notes@latest -pattern "^\d+\.\d+\.\d+\\?\_\d+$$"
NOTES=doc/CHANGELOG*.md
release:
$(LATEST) $(NOTES) | gh release create -d --notes-file - -t $(VERSION) $(VERSION) $(wildcard $(NAME)-$(VERSION)-*.zip)
dry-release:
$(LATEST) $(NOTES)
bump:
$(LATEST) -gosrc main -suffix "-goinstall" $(NOTES) > version.go
docs:
$(MAKE) -C doc all
$(SUPPORTGO):
go install golang.org/dl/$(SUPPORTGO)@latest
"$(shell go env GOPATH)/bin/$(SUPPORTGO)" download
update-complete-jj:
cd "nyagos.d/catalog" && "../../nyagos" -f make-complete-jj.lua
.PHONY: build debug test tstlua clean get _dist dist release install docs