diff --git a/.appveyor.yml b/.appveyor.yml index 8c78ea8f0..87bee5bf4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -31,12 +31,12 @@ build_script: - make version > %TEMP%\version - set /p RCLONE_VERSION=<%TEMP%\version - set PATH=%PATHCC32% -- go run bin/cross-compile.go -release beta-latest -git-log %TEMP%\git-log.txt -include "^windows/386" -cgo %RCLONE_VERSION% +- go run bin/cross-compile.go -release beta-latest -git-log %TEMP%\git-log.txt -include "^windows/386" -cgo -tags cmount %RCLONE_VERSION% - set PATH=%PATHCC64% -- go run bin/cross-compile.go -release beta-latest -git-log %TEMP%\git-log.txt -include "^windows/amd64" -cgo -no-clean %RCLONE_VERSION% +- go run bin/cross-compile.go -release beta-latest -git-log %TEMP%\git-log.txt -include "^windows/amd64" -cgo -no-clean -tags cmount %RCLONE_VERSION% test_script: -- make quicktest +- make GOTAGS=cmount quicktest artifacts: - path: rclone.exe diff --git a/.circleci/config.yml b/.circleci/config.yml index b694a1693..7eee157ec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,6 +18,7 @@ jobs: xgo \ --image=billziss/xgo-cgofuse \ --targets=darwin/386,darwin/amd64,linux/386,linux/amd64,windows/386,windows/amd64 \ + -tags cmount \ . - run: diff --git a/.travis.yml b/.travis.yml index 712977187..58f7fd9df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ script: - make check - make quicktest env: + global: + - GOTAGS=cmount matrix: secure: gU8gCV9R8Kv/Gn0SmCP37edpfIbPoSvsub48GK7qxJdTU628H0KOMiZW/T0gtV5d67XJZ4eKnhJYlxwwxgSgfejO32Rh5GlYEKT/FuVoH0BD72dM1GDFLSrUiUYOdoHvf/BKIFA3dJFT4lk2ASy4Zh7SEoXHG6goBlqUpYx8hVA= addons: @@ -29,7 +31,7 @@ matrix: include: - os: osx go: 1.8.1 - env: CGO_ENABLED=0 + env: GOTAGS="" deploy: provider: script script: make travis_beta diff --git a/Makefile b/Makefile index e3ec8da02..96067ef00 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,16 @@ GO_VERSION := $(shell go version) GO_FILES := $(shell go list ./... | grep -v /vendor/ ) GO_LATEST := $(findstring go1.8,$(GO_VERSION)) BETA_URL := https://beta.rclone.org/$(TAG)/ +# Pass in GOTAGS=xyz on the make command line to set build tags +ifdef GOTAGS +BUILDTAGS=-tags "$(GOTAGS)" +endif .PHONY: rclone vars version rclone: touch fs/version.go - go install -v --ldflags "-s -X github.com/ncw/rclone/fs.Version=$(TAG)" + go install -v --ldflags "-s -X github.com/ncw/rclone/fs.Version=$(TAG)" $(BUILDTAGS) cp -av `go env GOPATH`/bin/rclone . vars: @@ -28,19 +32,19 @@ version: # Full suite of integration tests test: rclone - go test $(GO_FILES) - cd fs && go run test_all.go + go test $(BUILDTAGS) $(GO_FILES) + cd fs && go run $(BUILDTAGS) test_all.go # Quick test quicktest: - RCLONE_CONFIG="/notfound" go test $(GO_FILES) - if [ "$$CGO_ENABLED" != "0" ]; then RCLONE_CONFIG="/notfound" go test -cpu=2 -race $(GO_FILES) ; fi + RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) $(GO_FILES) + RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) -cpu=2 -race $(GO_FILES) # Do source code quality checks check: rclone ifdef GO_LATEST - go tool vet -printfuncs Debugf,Infof,Logf,Errorf . 2>&1 | grep -E -v vendor/ ; test $$? -eq 1 - errcheck $(GO_FILES) + go tool vet $(BUILDTAGS) -printfuncs Debugf,Infof,Logf,Errorf . 2>&1 | grep -E -v vendor/ ; test $$? -eq 1 + errcheck $(BUILDTAGS) $(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 @@ -101,10 +105,10 @@ upload_github: ./bin/upload-github $(TAG) cross: doc - go run bin/cross-compile.go -release current $(TAG) + go run bin/cross-compile.go -release current $(BUILDTAGS) $(TAG) beta: - go run bin/cross-compile.go $(TAG)β + go run bin/cross-compile.go $(BUILDTAGS) $(TAG)β rclone -v copy build/ memstore:pub-rclone-org/$(TAG)β @echo Beta release ready at https://pub.rclone.org/$(TAG)%CE%B2/ @@ -118,7 +122,7 @@ upload_beta: 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 -exclude "^windows/" $(TAG)β + go run bin/cross-compile.go -release beta-latest -git-log /tmp/git-log.txt -exclude "^windows/" $(BUILDTAGS) $(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 @echo Beta release ready at $(BETA_URL) diff --git a/bin/cross-compile.go b/bin/cross-compile.go index fe38c585a..d0d5b2029 100644 --- a/bin/cross-compile.go +++ b/bin/cross-compile.go @@ -27,6 +27,7 @@ var ( exclude = flag.String("exclude", "^$", "os/arch regexp to exclude") cgo = flag.Bool("cgo", false, "Use cgo for the build") noClean = flag.Bool("no-clean", false, "Don't clean the build directory before running.") + tags = flag.String("tags", "", "Space separated list of build tags") ) // GOOS/GOARCH pairs we build for @@ -100,6 +101,7 @@ func compileArch(version, goos, goarch, dir string) { "--ldflags", "-s -X github.com/ncw/rclone/fs.Version=" + version, "-i", "-o", output, + "-tags", *tags, "..", } env := []string{ diff --git a/cmd/cmount/fs.go b/cmd/cmount/fs.go index 0c1a931ac..c7681ab32 100644 --- a/cmd/cmount/fs.go +++ b/cmd/cmount/fs.go @@ -1,3 +1,4 @@ +// +build cmount // +build cgo // +build linux darwin freebsd windows diff --git a/cmd/cmount/mount.go b/cmd/cmount/mount.go index 1f4fe61cd..4f7606816 100644 --- a/cmd/cmount/mount.go +++ b/cmd/cmount/mount.go @@ -2,6 +2,7 @@ // // This uses the cgo based cgofuse library +// +build cmount // +build cgo // +build linux darwin freebsd windows diff --git a/cmd/cmount/mount_test.go b/cmd/cmount/mount_test.go index 20d282840..f8d81f062 100644 --- a/cmd/cmount/mount_test.go +++ b/cmd/cmount/mount_test.go @@ -1,3 +1,4 @@ +// +build cmount // +build cgo // +build linux darwin freebsd windows diff --git a/cmd/cmount/mount_unix.go b/cmd/cmount/mount_unix.go index c81ca064e..d9e288b21 100644 --- a/cmd/cmount/mount_unix.go +++ b/cmd/cmount/mount_unix.go @@ -1,3 +1,4 @@ +// +build cmount // +build cgo // +build linux darwin freebsd diff --git a/cmd/cmount/mount_unsupported.go b/cmd/cmount/mount_unsupported.go index 11d69ee62..57d820e22 100644 --- a/cmd/cmount/mount_unsupported.go +++ b/cmd/cmount/mount_unsupported.go @@ -1,6 +1,6 @@ // Build for cmount for unsupported platforms to stop go complaining // about "no buildable Go source files " -// +build !linux,!darwin,!freebsd,!windows !cgo +// +build !linux,!darwin,!freebsd,!windows !cgo !cmount package cmount diff --git a/cmd/cmount/mount_windows.go b/cmd/cmount/mount_windows.go index 371c6e6d9..a68f7e40a 100644 --- a/cmd/cmount/mount_windows.go +++ b/cmd/cmount/mount_windows.go @@ -1,3 +1,4 @@ +// +build cmount // +build cgo // +build windows