diff --git a/make.go b/make.go index c1c795883..568a67954 100644 --- a/make.go +++ b/make.go @@ -61,7 +61,7 @@ var ( ifModsSince = flag.Int64("if_mods_since", 0, "If non-zero return immediately without building if there aren't any filesystem modifications past this time (in unix seconds)") buildARCH = flag.String("arch", runtime.GOARCH, "Architecture to build for.") buildOS = flag.String("os", runtime.GOOS, "Operating system to build for.") - stampVersion = flag.Bool("stampversion", false, "Stamp version into buildinfo.GitInfo") + stampVersion = flag.Bool("stampversion", true, "Stamp version into buildinfo.GitInfo") ) var ( @@ -184,9 +184,7 @@ func main() { } var ldFlags string if *stampVersion { - // TODO(bradfitz): this is currently broken, at least on my machine. - // Maybe my Go 1.4 vs Go 1.5 clients are out of sync. Temporarily disabled. - ldFlags = "-X camlistore.org/pkg/buildinfo.GitInfo " + version + ldFlags = "-X camlistore.org/pkg/buildinfo.GitInfo=" + version } baseArgs = append(baseArgs, "--ldflags="+ldFlags, "--tags="+strings.Join(tags, " ")) diff --git a/pkg/buildinfo/buildinfo.go b/pkg/buildinfo/buildinfo.go index 8a7f6fc7a..75f1faec4 100644 --- a/pkg/buildinfo/buildinfo.go +++ b/pkg/buildinfo/buildinfo.go @@ -17,6 +17,8 @@ limitations under the License. // Package buildinfo provides information about the current build. package buildinfo +import "flag" + // GitInfo is either the empty string (the default) // or is set to the git hash of the most recent commit // using the -X linker flag. For example, it's set like: @@ -32,15 +34,9 @@ func Version() string { return "unknown" } -var testingLinked func() bool - // TestingLinked reports whether the "testing" package is linked into the binary. -// It always returns false for Go 1.1. func TestingLinked() bool { - if testingLinked == nil { - return false - } - return testingLinked() + return flag.CommandLine.Lookup("test.v") != nil } // djpegFunc implements DjpegStatus. nil means the images/fastjpeg package diff --git a/pkg/buildinfo/buildinfo_test.go b/pkg/buildinfo/buildinfo_test.go index 1ce1947b9..f37cb9c94 100644 --- a/pkg/buildinfo/buildinfo_test.go +++ b/pkg/buildinfo/buildinfo_test.go @@ -17,28 +17,11 @@ limitations under the License. package buildinfo import ( - "go/build" "testing" ) func TestTestingLinked(t *testing.T) { - if !isGo12() { - t.Skip("skipping test for Go 1.1") - } - if testingLinked == nil { - t.Fatal("go1.2+ but testingLinked is nil") - } - if !testingLinked() { + if !TestingLinked() { t.Error("testingLinked = false; want true") } } - -// isGo12 reports whether the Go version is 1.2 or higher -func isGo12() bool { - for _, v := range build.Default.ReleaseTags { - if v == "go1.2" { - return true - } - } - return false -} diff --git a/pkg/buildinfo/testinglinked.go b/pkg/buildinfo/testinglinked.go deleted file mode 100644 index 9610836ab..000000000 --- a/pkg/buildinfo/testinglinked.go +++ /dev/null @@ -1,27 +0,0 @@ -// +build go1.2 - -/* -Copyright 2014 The Camlistore Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package buildinfo - -import "flag" - -func init() { - testingLinked = func() bool { - return flag.CommandLine.Lookup("test.v") != nil - } -}