Use build tags to control when and where cmount is built

This commit is contained in:
Nick Craig-Wood 2017-05-19 15:46:13 +01:00
parent 7daf97f90a
commit 8f54dc06a2
11 changed files with 29 additions and 15 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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)

View File

@ -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{

View File

@ -1,3 +1,4 @@
// +build cmount
// +build cgo
// +build linux darwin freebsd windows

View File

@ -2,6 +2,7 @@
//
// This uses the cgo based cgofuse library
// +build cmount
// +build cgo
// +build linux darwin freebsd windows

View File

@ -1,3 +1,4 @@
// +build cmount
// +build cgo
// +build linux darwin freebsd windows

View File

@ -1,3 +1,4 @@
// +build cmount
// +build cgo
// +build linux darwin freebsd

View File

@ -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

View File

@ -1,3 +1,4 @@
// +build cmount
// +build cgo
// +build windows