...

Text file src/github.com/golang-migrate/migrate/v4/Makefile

Documentation: github.com/golang-migrate/migrate/v4

     1SOURCE ?= file go_bindata github github_ee bitbucket aws_s3 google_cloud_storage godoc_vfs gitlab
     2DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb clickhouse mongodb sqlserver firebird neo4j pgx
     3DATABASE_TEST ?= $(DATABASE) sqlite sqlite3 sqlcipher
     4VERSION ?= $(shell git describe --tags 2>/dev/null | cut -c 2-)
     5TEST_FLAGS ?=
     6REPO_OWNER ?= $(shell cd .. && basename "$$(pwd)")
     7COVERAGE_DIR ?= .coverage
     8
     9build:
    10	CGO_ENABLED=0 go build -ldflags='-X main.Version=$(VERSION)' -tags '$(DATABASE) $(SOURCE)' ./cmd/migrate
    11
    12build-docker:
    13	CGO_ENABLED=0 go build -a -o build/migrate.linux-386 -ldflags="-s -w -X main.Version=${VERSION}" -tags "$(DATABASE) $(SOURCE)" ./cmd/migrate
    14
    15build-cli: clean
    16	-mkdir ./cli/build
    17	cd ./cmd/migrate && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o ../../cli/build/migrate.linux-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
    18	cd ./cmd/migrate && CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -a -o ../../cli/build/migrate.linux-armv7 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
    19	cd ./cmd/migrate && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o ../../cli/build/migrate.linux-arm64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
    20	cd ./cmd/migrate && CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -o ../../cli/build/migrate.darwin-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
    21	cd ./cmd/migrate && CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -a -o ../../cli/build/migrate.windows-386.exe -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
    22	cd ./cmd/migrate && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -a -o ../../cli/build/migrate.windows-amd64.exe -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
    23	cd ./cli/build && find . -name 'migrate*' | xargs -I{} tar czf {}.tar.gz {}
    24	cd ./cli/build && shasum -a 256 * > sha256sum.txt
    25	cat ./cli/build/sha256sum.txt
    26
    27
    28clean:
    29	-rm -r ./cli/build
    30
    31
    32test-short:
    33	make test-with-flags --ignore-errors TEST_FLAGS='-short'
    34
    35
    36test:
    37	@-rm -r $(COVERAGE_DIR)
    38	@mkdir $(COVERAGE_DIR)
    39	make test-with-flags TEST_FLAGS='-v -race -covermode atomic -coverprofile $$(COVERAGE_DIR)/combined.txt -bench=. -benchmem -timeout 20m'
    40
    41
    42test-with-flags:
    43	@echo SOURCE: $(SOURCE)
    44	@echo DATABASE_TEST: $(DATABASE_TEST)
    45
    46	@go test $(TEST_FLAGS) ./...
    47
    48
    49kill-orphaned-docker-containers:
    50	docker rm -f $(shell docker ps -aq --filter label=migrate_test)
    51
    52
    53html-coverage:
    54	go tool cover -html=$(COVERAGE_DIR)/combined.txt
    55
    56
    57list-external-deps:
    58	$(call external_deps,'.')
    59	$(call external_deps,'./cli/...')
    60	$(call external_deps,'./testing/...')
    61
    62	$(foreach v, $(SOURCE), $(call external_deps,'./source/$(v)/...'))
    63	$(call external_deps,'./source/testing/...')
    64	$(call external_deps,'./source/stub/...')
    65
    66	$(foreach v, $(DATABASE), $(call external_deps,'./database/$(v)/...'))
    67	$(call external_deps,'./database/testing/...')
    68	$(call external_deps,'./database/stub/...')
    69
    70
    71restore-import-paths:
    72	find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/$(REPO_OWNER)/migrate%\"github.com/mattes/migrate%g '{}' \;
    73
    74
    75rewrite-import-paths:
    76	find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/mattes/migrate%\"github.com/$(REPO_OWNER)/migrate%g '{}' \;
    77
    78
    79# example: fswatch -0 --exclude .godoc.pid --event Updated . | xargs -0 -n1 -I{} make docs
    80docs:
    81	-make kill-docs
    82	nohup godoc -play -http=127.0.0.1:6064 </dev/null >/dev/null 2>&1 & echo $$! > .godoc.pid
    83	cat .godoc.pid
    84
    85
    86kill-docs:
    87	@cat .godoc.pid
    88	kill -9 $$(cat .godoc.pid)
    89	rm .godoc.pid
    90
    91
    92open-docs:
    93	open http://localhost:6064/pkg/github.com/$(REPO_OWNER)/migrate
    94
    95
    96# example: make release V=0.0.0
    97release:
    98	git tag v$(V)
    99	@read -p "Press enter to confirm and push to origin ..." && git push origin v$(V)
   100
   101echo-source:
   102	@echo "$(SOURCE)"
   103
   104echo-database:
   105	@echo "$(DATABASE)"
   106
   107
   108define external_deps
   109	@echo '-- $(1)';  go list -f '{{join .Deps "\n"}}' $(1) | grep -v github.com/$(REPO_OWNER)/migrate | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
   110
   111endef
   112
   113
   114.PHONY: build build-docker build-cli clean test-short test test-with-flags html-coverage \
   115        restore-import-paths rewrite-import-paths list-external-deps release \
   116		docs kill-docs open-docs kill-orphaned-docker-containers echo-source echo-database
   117
   118SHELL = /bin/sh
   119RAND = $(shell echo $$RANDOM)
   120

View as plain text