Skip to content

Commit 2508856

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 d7a38bb commit 2508856

File tree

4 files changed

+72
-12
lines changed

4 files changed

+72
-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: 69 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)'
@@ -8,35 +20,81 @@ test: build
820

921
build:
1022
go build -o golangci-lint ./cmd/golangci-lint
23+
.PHONY: test
1124

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

1630
test_linters:
1731
GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdataWithIssuesDir/$T
32+
.PHONY: test_linters
1833

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

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

2842
check_generated:
29-
$(MAKE) readme update_deps
43+
$(MAKE) --always-make generate
3044
git diff --exit-code # check no changes
45+
.PHONY: check_generated
3146

3247
release:
3348
rm -rf dist
3449
curl -sL https://git.io/goreleaser | bash
50+
.PHONY: release
51+
52+
# Non-PHONY targets (real files)
53+
54+
golangci-lint: FORCE pkg/logutils/log_mock.go
55+
go build -o $@ ./cmd/golangci-lint
56+
57+
tools/mockgen: go.mod go.sum
58+
GOBIN=$(CURDIR)/tools go install github.com/golang/mock/mockgen
59+
60+
tools/goimports: go.mod go.sum
61+
GOBIN=$(CURDIR)/tools go install golang.org/x/tools/cmd/goimports
62+
63+
tools/go.mod:
64+
@mkdir -p tools
65+
@rm -f $@
66+
cd tools && go mod init local-tools
3567

36-
update_deps:
68+
tools/godownloader: Makefile tools/go.mod
69+
cd tools && GOBIN=$(CURDIR)/tools go get github.com/goreleaser/godownloader@3b90d248ba30307915288f08ab3f2fc2d9f6710c
70+
71+
tools/svg-term:
72+
@mkdir -p tools
73+
cd tools && npm install svg-term-cli
74+
ln -sf node_modules/.bin/svg-term $@
75+
76+
tools/Dracula.itermcolors:
77+
@mkdir -p tools
78+
curl -fL -o $@ https://raw.githubusercontent.com/dracula/iterm/master/Dracula.itermcolors
79+
80+
docs/demo.svg: tools/svg-term tools/Dracula.itermcolors
81+
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
82+
83+
install.sh: tools/godownloader .goreleaser.yml
84+
PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@
85+
86+
README.md: FORCE golangci-lint
87+
go run ./scripts/gen_readme/main.go
88+
89+
pkg/logutils/log_mock.go: tools/mockgen tools/goimports pkg/logutils/log.go
90+
@rm -f $@
91+
PATH=$(CURDIR)/tools:$${PATH} go generate ./...
92+
93+
go.mod: FORCE
3794
go mod verify
3895
go mod tidy
96+
go.sum: go.mod
97+
98+
vendor: go.mod go.sum
3999
rm -rf vendor
40100
go mod vendor
41-
42-
.PHONY: test

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)