Merge "make.go: restore version stamping"

This commit is contained in:
Mathieu Lonjaret 2015-12-07 22:04:24 +00:00 committed by Gerrit Code Review
commit 0f4ab197d5
4 changed files with 6 additions and 56 deletions

View File

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

View File

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

View File

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

View File

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