-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (60 loc) · 2.26 KB
/
Makefile
File metadata and controls
77 lines (60 loc) · 2.26 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
.PHONY: default
.DEFAULT_GOAL := default
# The shell script is itz and the actual binary is itzcli
WRAPPER=itz
BINARY=itzcli
ITZ_VER := $(shell git describe --tags)
# Add windows here if/when we start supporting Windows OS officially
PLATFORMS=darwin linux windows
# Add 386 if we want, but for modern usages I see no reason why to include 32
# bit archs
ARCHITECTURES=amd64
LDFLAGS=-ldflags "-X main.Version=${ITZ_VER}"
ADDL_FILES=itz QUICKSTART.md CHANGELOG.md
default: ci
clean-mocks:
@rm -rf ./mocks
generate-mocks:
@bash scripts/generate-mocks.sh $(PWD)
regenerate-mocks: clean-mocks generate-mocks
clean:
@echo "Cleaning up..."
@rm -rf bin
@rm -rf contrib
@rm -rf $(BINARY)-*.tar.gz
@rm itzcli
verify: regenerate-mocks
@echo "Running tests..."
go test ./test/...
test/scripts/cli-tests.sh
build:
@echo "Building itzcli..."
go build ${LDFLAGS} -o ${BINARY}
package:
@tar cvf - itz itzcli | gzip > itzcli.tar.gz
build_all:
$(foreach GOOS, $(PLATFORMS),\
$(foreach GOARCH, $(ARCHITECTURES), $(shell mkdir -p bin/$(GOOS)/$(GOARCH) && GOOS=$(GOOS) GOARCH=$(GOARCH) go build -v $(LDFLAGS) -o bin/$(GOOS)/$(GOARCH)/$(BINARY))))
# The `make install` does not do a full install, but it does the build and
# generates the different documentation bash and also man pages
install: build
@echo "Generating man pages..."
@mkdir -p contrib/manpages
@go run main.go generate man
@echo "Installing itzcli..."
@mkdir -p contrib/bash
@mkdir -p contrib/zsh
@./itzcli completion bash > contrib/bash/itzcli
@./itzcli completion zsh > contrib/zsh/_itzcli
package_all:
$(foreach GOOS, $(PLATFORMS),\
$(foreach GOARCH, $(ARCHITECTURES), $(shell cp $(ADDL_FILES) bin/$(GOOS)/$(GOARCH))))
$(foreach GOOS, $(PLATFORMS),\
$(foreach GOARCH, $(ARCHITECTURES), $(shell tar -C bin/$(GOOS)/$(GOARCH) -cvf - $(ADDL_FILES) $(BINARY) | gzip > $(BINARY)-$(GOOS)-$(GOARCH).tar.gz)))
# This is not as dynamic as the others, but it is just used for the one-off of creating a ZIP file for Windows users
# who might be more accustomed to using ZIP rather than TAR files.
$(foreach GOOS, windows, $(foreach GOARCH, amd64, @zip -j -r $(BINARY)-$(GOOS)-$(GOARCH).zip bin/$(GOOS)/$(GOARCH)))
generate-docs:
@rm -rf docs/*.md
@go run main.go generate html
ci: clean build verify install build_all package_all