From 1d6698a7541ee4969fa5b8126fadf3520c2adc45 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 3 Jun 2016 20:09:34 +0100 Subject: [PATCH] Build tweaks - fixes #484 * disable CGO for static builds everywhere * override Version in release build script * don't output symbol table in release binaries --- Makefile | 2 +- cross-compile | 5 ++++- fs/fs.go | 4 ++-- fs/version.go | 2 +- rclone.go | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 402ce0257..c6ee06890 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ serve: website tag: doc @echo "Old tag is $(LAST_TAG)" @echo "New tag is $(NEW_TAG)" - echo -e "package fs\n\n// Version of rclone\nconst Version = \"$(NEW_TAG)\"\n" | gofmt > fs/version.go + 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) @echo "Add this to changelog in docs/content/changelog.md" diff --git a/cross-compile b/cross-compile index 514f9030d..09c44742e 100755 --- a/cross-compile +++ b/cross-compile @@ -13,7 +13,10 @@ VERSION="$1" rm -rf build -gox -output "build/{{.Dir}}-${VERSION}-{{.OS}}-{{.Arch}}/{{.Dir}}" -os "darwin linux freebsd openbsd windows freebsd netbsd plan9 solaris" +# Disable CGO and dynamic builds on all platforms (including build patform) +export CGO_ENABLED=0 + +gox --ldflags "-s -X github.com/ncw/rclone/fs.Version=${VERSION}" -output "build/{{.Dir}}-${VERSION}-{{.OS}}-{{.Arch}}/{{.Dir}}" -os "darwin linux freebsd openbsd windows freebsd netbsd plan9 solaris" # Not implemented yet: nacl dragonfly android # gox -osarch-list for definitive list diff --git a/fs/fs.go b/fs/fs.go index e7d2b2103..20f996ca6 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -14,8 +14,6 @@ import ( // Constants const ( - // UserAgent for Fs which can set it - UserAgent = "rclone/" + Version // ModTimeNotSupported is a very large precision value to show // mod time isn't supported on this Fs ModTimeNotSupported = 100 * 365 * 24 * time.Hour @@ -25,6 +23,8 @@ const ( // Globals var ( + // UserAgent for Fs which can set it + UserAgent = "rclone/" + Version // Filesystem registry fsRegistry []*RegInfo // ErrorNotFoundInConfigFile is returned by NewFs if not found in config file diff --git a/fs/version.go b/fs/version.go index eb025f1ae..0aaad4316 100644 --- a/fs/version.go +++ b/fs/version.go @@ -1,4 +1,4 @@ package fs // Version of rclone -const Version = "v1.29" +var Version = "v1.29" diff --git a/rclone.go b/rclone.go index 32b7b0b3a..ed12585c9 100644 --- a/rclone.go +++ b/rclone.go @@ -414,6 +414,7 @@ func main() { log.SetOutput(f) redirectStderr(f) } + fs.Debug("rclone", "Starting with parameters %+v", os.Args) // Setup CPU profiling if desired if *cpuProfile != "" {