rclone/Makefile

142 lines
4.3 KiB
Makefile
Raw Normal View History

2015-11-07 20:16:33 +08:00
SHELL = /bin/bash
TAG := $(shell echo `git describe --tags`-`git rev-parse --abbrev-ref HEAD` | sed 's/-\([0-9]\)-/-0\1-/; s/-\(HEAD\|master\)$$//')
LAST_TAG := $(shell git describe --tags --abbrev=0)
2014-07-04 04:43:14 +08:00
NEW_TAG := $(shell echo $(LAST_TAG) | perl -lpe 's/v//; $$_ += 0.01; $$_ = sprintf("v%.2f", $$_)')
GO_VERSION := $(shell go version)
GO_FILES := $(shell go list ./... | grep -v /vendor/ )
2017-02-17 17:40:14 +08:00
GO_LATEST := $(findstring go1.8,$(GO_VERSION))
2016-10-08 18:23:21 +08:00
BETA_URL := http://beta.rclone.org/$(TAG)/
# Only needed for Go 1.5
export GO15VENDOREXPERIMENT=1
.PHONY: rclone
2014-07-19 20:12:20 +08:00
rclone:
touch fs/version.go
go install -v --ldflags "-s -X github.com/ncw/rclone/fs.Version=$(TAG)"
cp -av `go env GOPATH`/bin/rclone .
2014-07-19 20:12:20 +08:00
vars:
@echo SHELL="'$(SHELL)'"
@echo TAG="'$(TAG)'"
@echo LAST_TAG="'$(LAST_TAG)'"
@echo NEW_TAG="'$(NEW_TAG)'"
@echo GO_VERSION="'$(GO_VERSION)'"
@echo GO_LATEST="'$(GO_LATEST)'"
2016-10-08 18:23:21 +08:00
@echo BETA_URL="'$(BETA_URL)'"
2016-07-13 19:25:19 +08:00
# Full suite of integration tests
2014-07-19 20:12:20 +08:00
test: rclone
go test $(GO_FILES)
cd fs && go run test_all.go
2014-03-29 06:34:13 +08:00
2016-07-13 19:25:19 +08:00
# Quick test
quicktest:
RCLONE_CONFIG="/notfound" go test $(GO_FILES)
RCLONE_CONFIG="/notfound" go test -cpu=2 -race $(GO_FILES)
2016-07-13 19:25:19 +08:00
# Do source code quality checks
2015-09-23 01:47:16 +08:00
check: rclone
ifdef GO_LATEST
2017-02-12 20:43:13 +08:00
go tool vet -printfuncs Debugf,Infof,Logf,Errorf . 2>&1 | grep -E -v vendor/ ; test $$? -eq 1
errcheck $(GO_FILES)
find . -name \*.go | grep -v /vendor/ | xargs goimports -d | grep . ; test $$? -eq 1
go list ./... | grep -v /vendor/ | xargs -i golint {} | grep -E -v '(StorageUrl|CdnUrl)' ; test $$? -eq 1
else
@echo Skipping tests as not on Go stable
endif
2015-09-23 01:47:16 +08:00
2016-07-13 19:25:19 +08:00
# Get the build dependencies
build_dep:
ifdef GO_LATEST
2016-07-13 19:25:19 +08:00
go get -u github.com/kisielk/errcheck
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/golang/lint/golint
go get -u github.com/inconshreveable/mousetrap
go get -u github.com/tools/godep
endif
2016-07-13 19:25:19 +08:00
# Update dependencies
update:
rm -rf Godeps vendor
2016-07-13 19:25:19 +08:00
go get -t -u -f -v ./...
godep save ./...
2016-07-13 19:25:19 +08:00
doc: rclone.1 MANUAL.html MANUAL.txt
rclone.1: MANUAL.md
pandoc -s --from markdown --to man MANUAL.md -o rclone.1
MANUAL.md: bin/make_manual.py docs/content/*.md commanddocs
./bin/make_manual.py
MANUAL.html: MANUAL.md
pandoc -s --from markdown --to html MANUAL.md -o MANUAL.html
MANUAL.txt: MANUAL.md
pandoc -s --from markdown --to plain MANUAL.md -o MANUAL.txt
commanddocs: rclone
rclone gendocs docs/content/commands/
install: rclone
install -d ${DESTDIR}/usr/bin
2014-07-19 20:12:20 +08:00
install -t ${DESTDIR}/usr/bin ${GOPATH}/bin/rclone
2014-03-29 06:34:13 +08:00
clean:
go clean ./...
2014-03-29 06:34:13 +08:00
find . -name \*~ | xargs -r rm -f
2014-04-18 05:32:39 +08:00
rm -rf build docs/public
2016-02-01 00:33:20 +08:00
rm -f rclone rclonetest/rclonetest
2014-03-29 06:34:13 +08:00
website:
2014-04-18 05:32:39 +08:00
cd docs && hugo
2014-03-29 06:34:13 +08:00
upload_website: website
2014-07-19 20:12:20 +08:00
rclone -v sync docs/public memstore:www-rclone-org
2014-03-29 06:34:13 +08:00
upload:
2014-07-19 20:12:20 +08:00
rclone -v copy build/ memstore:downloads-rclone-org
2014-03-29 06:34:13 +08:00
upload_github:
./bin/upload-github $(TAG)
cross: doc
go run bin/cross-compile.go -release current $(TAG)
2014-03-29 06:34:13 +08:00
2016-02-21 18:29:48 +08:00
beta:
go run bin/cross-compile.go $(TAG)β
rclone -v copy build/ memstore:pub-rclone-org/$(TAG)β
2015-11-30 18:10:41 +08:00
@echo Beta release ready at http://pub.rclone.org/$(TAG)%CE%B2/
travis_beta:
git log $(LAST_TAG).. > /tmp/git-log.txt
go run bin/cross-compile.go -release beta-latest -git-log /tmp/git-log.txt $(TAG)β
rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ memstore:beta-rclone-org/$(TAG)
rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' build/ memstore:beta-rclone-org
2016-10-08 18:23:21 +08:00
@echo Beta release ready at $(BETA_URL)
serve: website
2014-04-18 05:32:39 +08:00
cd docs && hugo server -v -w
2016-02-01 01:50:13 +08:00
tag: doc
@echo "Old tag is $(LAST_TAG)"
@echo "New tag is $(NEW_TAG)"
2017-03-18 19:16:43 +08:00
echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(NEW_TAG)\"\n" | gofmt > fs/version.go
perl -lpe 's/VERSION/${NEW_TAG}/g; s/DATE/'`date -I`'/g;' docs/content/downloads.md.in > docs/content/downloads.md
git tag $(NEW_TAG)
2017-03-18 19:16:43 +08:00
@echo "Edit the new changelog in docs/content/changelog.md"
@echo " * $(NEW_TAG) -" `date -I` >> docs/content/changelog.md
@git log $(LAST_TAG)..$(NEW_TAG) --oneline >> docs/content/changelog.md
@echo "Then commit the changes"
@echo git commit -m \"Version $(NEW_TAG)\" -a -v
@echo "And finally run make retag before make cross etc"
retag:
2014-06-27 00:57:32 +08:00
git tag -f $(LAST_TAG)
2017-03-18 19:16:43 +08:00
echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(LAST_TAG)-DEV\"\n" | gofmt > fs/version.go
git commit -m "Start $(LAST_TAG)-DEV development" fs/version.go
gen_tests:
cd fstest/fstests && go generate