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.
This commit is contained in:
Luke Shumaker 2019-05-19 21:00:40 -04:00
parent d7a38bbdf2
commit 2508856219
4 changed files with 72 additions and 12 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
/.idea/ /.idea/
/test/path /test/path
/golangci-lint /golangci-lint
/tools/

View File

@ -1,5 +1,17 @@
.DEFAULT_GOAL = test
.PHONY: FORCE
export GO111MODULE = on export GO111MODULE = on
# Build
build: golangci-lint
clean:
rm -f golangci-lint test/path
rm -rf tools
.PHONY: build clean
# Test
test: build test: build
GL_TEST_RUN=1 ./golangci-lint run -v GL_TEST_RUN=1 ./golangci-lint run -v
GL_TEST_RUN=1 ./golangci-lint run --fast --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)' 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
build: build:
go build -o golangci-lint ./cmd/golangci-lint go build -o golangci-lint ./cmd/golangci-lint
.PHONY: test
test_race: test_race:
go build -race -o golangci-lint ./cmd/golangci-lint go build -race -o golangci-lint ./cmd/golangci-lint
GL_TEST_RUN=1 ./golangci-lint run -v --deadline=5m GL_TEST_RUN=1 ./golangci-lint run -v --deadline=5m
.PHONY: test_race
test_linters: test_linters:
GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdataWithIssuesDir/$T GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdataWithIssuesDir/$T
.PHONY: test_linters
assets: # Maintenance
svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile Dracula --term iterm2
readme: generate: docs/demo.svg README.md install.sh pkg/logutils/log_mock.go vendor
go run ./scripts/gen_readme/main.go maintainer-clean: clean
rm -f docs/demo.svg README.md install.sh pkg/logutils/log_mock.go
gen: rm -rf vendor
go generate ./... .PHONY: generate maintainer-clean
check_generated: check_generated:
$(MAKE) readme update_deps $(MAKE) --always-make generate
git diff --exit-code # check no changes git diff --exit-code # check no changes
.PHONY: check_generated
release: release:
rm -rf dist rm -rf dist
curl -sL https://git.io/goreleaser | bash curl -sL https://git.io/goreleaser | bash
.PHONY: release
update_deps: # Non-PHONY targets (real files)
golangci-lint: FORCE pkg/logutils/log_mock.go
go build -o $@ ./cmd/golangci-lint
tools/mockgen: go.mod go.sum
GOBIN=$(CURDIR)/tools go install github.com/golang/mock/mockgen
tools/goimports: go.mod go.sum
GOBIN=$(CURDIR)/tools go install golang.org/x/tools/cmd/goimports
tools/go.mod:
@mkdir -p tools
@rm -f $@
cd tools && go mod init local-tools
tools/godownloader: Makefile tools/go.mod
cd tools && GOBIN=$(CURDIR)/tools go get github.com/goreleaser/godownloader@3b90d248ba30307915288f08ab3f2fc2d9f6710c
tools/svg-term:
@mkdir -p tools
cd tools && npm install svg-term-cli
ln -sf node_modules/.bin/svg-term $@
tools/Dracula.itermcolors:
@mkdir -p tools
curl -fL -o $@ https://raw.githubusercontent.com/dracula/iterm/master/Dracula.itermcolors
docs/demo.svg: tools/svg-term tools/Dracula.itermcolors
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
install.sh: tools/godownloader .goreleaser.yml
PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@
README.md: FORCE golangci-lint
go run ./scripts/gen_readme/main.go
pkg/logutils/log_mock.go: tools/mockgen tools/goimports pkg/logutils/log.go
@rm -f $@
PATH=$(CURDIR)/tools:$${PATH} go generate ./...
go.mod: FORCE
go mod verify go mod verify
go mod tidy go mod tidy
go.sum: go.mod
vendor: go.mod go.sum
rm -rf vendor rm -rf vendor
go mod vendor go mod vendor
.PHONY: test

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
set -e set -e
# Code generated by godownloader on 2018-06-05T12:04:55Z. DO NOT EDIT. # Code generated by godownloader. DO NOT EDIT.
# #
usage() { usage() {

View File

@ -1,6 +1,7 @@
package logutils package logutils
//go:generate mockgen -package logutils -source log.go -destination log_mock.go //go:generate mockgen -package logutils -source log.go -destination log_mock.go
//go:generate goimports -w log_mock.go
type Log interface { type Log interface {
Fatalf(format string, args ...interface{}) Fatalf(format string, args ...interface{})