Skip to content

Commit 1fd4816

Browse files
committed
Makefile: Be clear about exactly which files are generated, and how
This mostly aims to document how everything was generated, and the steps necessary to re-generate the same files verbatim; the goal is to figure out how to reproduce the files as they currently are. The exception is that we strip out the timestamp out of install.sh.
1 parent a308639 commit 1fd4816

File tree

4 files changed

+74
-12
lines changed

4 files changed

+74
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/.idea/
66
/test/path
77
/golangci-lint
8+
/tools/

Makefile

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
.DEFAULT_GOAL = test
2+
.PHONY: FORCE
13
export GO111MODULE = on
24

5+
# Build
6+
7+
build: golangci-lint
8+
clean:
9+
rm -f golangci-lint test/path
10+
rm -rf tools
11+
.PHONY: build clean
12+
13+
# Test
14+
315
test: build
416
GL_TEST_RUN=1 ./golangci-lint run -v
517
GL_TEST_RUN=1 ./golangci-lint run --fast --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)'
@@ -9,34 +21,82 @@ test: build
921

1022
build:
1123
go build -o golangci-lint ./cmd/golangci-lint
24+
.PHONY: test
1225

1326
test_race:
1427
go build -race -o golangci-lint ./cmd/golangci-lint
1528
GL_TEST_RUN=1 ./golangci-lint run -v --deadline=5m
29+
.PHONY: test_race
1630

1731
test_linters:
1832
GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdataWithIssuesDir/$T
33+
.PHONY: test_linters
1934

20-
assets:
21-
svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile Dracula --term iterm2
22-
23-
readme:
24-
go run ./scripts/gen_readme/main.go
35+
# Maintenance
2536

26-
gen:
27-
go generate ./...
37+
generate: docs/demo.svg README.md install.sh pkg/logutils/log_mock.go vendor
38+
maintainer-clean: clean
39+
rm -f docs/demo.svg README.md install.sh pkg/logutils/log_mock.go
40+
rm -rf vendor
41+
.PHONY: generate maintainer-clean
2842

2943
check_generated:
30-
make readme && git diff --exit-code # check no changes
44+
$(MAKE) --always-make generate
45+
git diff --exit-code # check no changes
46+
.PHONY: check_generatedg
3147

3248
release:
3349
rm -rf dist
3450
curl -sL https://git.io/goreleaser | bash
51+
.PHONY: release
3552

3653
update_deps:
3754
go mod verify
3855
go mod tidy
39-
rm -rf vendor
40-
go mod vendor
56+
$(MAKE) vendor
57+
.PHONY: update_deps
4158

42-
.PHONY: test
59+
# Non-PHONY targets (real files)
60+
61+
golangci-lint: FORCE pkg/logutils/log_mock.go
62+
go build -o $@ ./cmd/golangci-lint
63+
64+
tools/mockgen: go.mod go.sum
65+
GOBIN=$(CURDIR)/tools go install github.com/golang/mock/mockgen
66+
67+
tools/goimports: go.mod go.sum
68+
GOBIN=$(CURDIR)/tools go install golang.org/x/tools/cmd/goimports
69+
70+
tools/go.mod:
71+
@mkdir -p tools
72+
@rm -f $@
73+
cd tools && go mod init local-tools
74+
75+
tools/godownloader: Makefile tools/go.mod
76+
cd tools && GOBIN=$(CURDIR)/tools go get github.com/goreleaser/godownloader@3b90d248ba30307915288f08ab3f2fc2d9f6710c
77+
78+
tools/svg-term:
79+
@mkdir -p tools
80+
cd tools && npm install svg-term-cli
81+
ln -sf node_modules/.bin/svg-term $@
82+
83+
tools/Dracula.itermcolors:
84+
@mkdir -p tools
85+
curl -fL -o $@ https://raw.githubusercontent.com/dracula/iterm/master/Dracula.itermcolors
86+
87+
docs/demo.svg: tools/svg-term tools/Dracula.itermcolors
88+
PATH=$(CURDIR)/tools:$${PATH} svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile ./tools/Dracula.itermcolors --term iterm2
89+
90+
install.sh: tools/godownloader .goreleaser.yml
91+
PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@
92+
93+
README.md: FORCE golangci-lint
94+
PATH=$(CURDIR):$${PATH} go run ./scripts/gen_readme/main.go
95+
96+
pkg/logutils/log_mock.go: tools/mockgen tools/goimports pkg/logutils/log.go
97+
@rm -f $@
98+
PATH=$(CURDIR)/tools:$${PATH} go generate ./...
99+
100+
vendor: go.mod go.sum
101+
@rm -rf vendor
102+
go mod vendor

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
set -e
3-
# Code generated by godownloader on 2018-06-05T12:04:55Z. DO NOT EDIT.
3+
# Code generated by godownloader. DO NOT EDIT.
44
#
55

66
usage() {

pkg/logutils/log.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package logutils
22

33
//go:generate mockgen -package logutils -source log.go -destination log_mock.go
4+
//go:generate goimports -w log_mock.go
45

56
type Log interface {
67
Fatalf(format string, args ...interface{})

0 commit comments

Comments
 (0)