travis,unit: fix and check unit code generation

Also fix blas generate check for move.
This commit is contained in:
kortschak
2017-06-26 10:15:29 +09:30
committed by Dan Kortschak
parent ec20c1f479
commit 9363ac56d7
6 changed files with 28 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
#!/bin/bash
go generate gonum.org/v1/gonum/blas/native
go generate gonum.org/v1/gonum/blas/gonum
go generate gonum.org/v1/gonum/unit
if [ -n "$(git diff)" ]; then
exit 1
fi

View File

@@ -1,3 +1,9 @@
// Copyright ©2014 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package main
import (
@@ -197,7 +203,7 @@ func init() {
log.Fatal("no gopath")
}
unitPkgPath = filepath.Join(gopath, "src", "github.com", "gonum", "unit")
unitPkgPath = filepath.Join(gopath, "src", "gonum.org", "v1", "gonum", "unit")
}
// Generate generates a file for each of the units
@@ -207,8 +213,7 @@ func main() {
}
}
const headerTemplate = `// This file is autogenerated by github.com/gonum/unit/autogen
// Changes should be made to the autogenerated template rather than this one
const headerTemplate = `// Code generated by "go generate gonum.org/v1/gonum/unit”; DO NOT EDIT.
// Copyright ©2014 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -280,18 +285,20 @@ func ({{.Receiver}} {{.Name}}) Format(fs fmt.State, c rune){
fallthrough
case 'e', 'E', 'f', 'F', 'g', 'G':
p, pOk := fs.Precision()
if !pOk {
p = -1
}
w, wOk := fs.Width()
if !wOk {
w = -1
}
switch {
case pOk && wOk:
fmt.Fprintf(fs, "%*.*"+string(c), w, p, float64({{.Receiver}}))
case pOk:
fmt.Fprintf(fs, "%.*"+string(c), p, float64({{.Receiver}}))
case wOk:
fmt.Fprintf(fs, "%*"+string(c), w, float64({{.Receiver}}))
default:
fmt.Fprintf(fs, "%"+string(c), float64({{.Receiver}}))
}
fmt.Fprint(fs, " {{.PrintString}}")
default:
fmt.Fprintf(fs, "%%!%c(%T=%g {{.PrintString}})", c, {{.Receiver}}, float64({{.Receiver}}))
return
}
}
`

View File

@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate go run autogen.go
// Package unit provides a set of types and constants that facilitate
// the use of the International System of Units (SI).
//

View File

@@ -1,5 +1,4 @@
// This file is autogenerated by github.com/gonum/unit/autogen
// Changes should be made to the autogenerated template rather than this one
// Code generated by "go generate gonum.org/v1/gonum/unit”; DO NOT EDIT.
// Copyright ©2014 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -87,6 +86,5 @@ func (l Length) Format(fs fmt.State, c rune) {
fmt.Fprint(fs, " m")
default:
fmt.Fprintf(fs, "%%!%c(%T=%g m)", c, l, float64(l))
return
}
}

View File

@@ -1,5 +1,4 @@
// This file is autogenerated by github.com/gonum/unit/autogen
// Changes should be made to the autogenerated template rather than this one
// Code generated by "go generate gonum.org/v1/gonum/unit”; DO NOT EDIT.
// Copyright ©2014 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -87,6 +86,5 @@ func (m Mass) Format(fs fmt.State, c rune) {
fmt.Fprint(fs, " kg")
default:
fmt.Fprintf(fs, "%%!%c(%T=%g kg)", c, m, float64(m))
return
}
}

View File

@@ -1,5 +1,4 @@
// This file is autogenerated by github.com/gonum/unit/autogen
// Changes should be made to the autogenerated template rather than this one
// Code generated by "go generate gonum.org/v1/gonum/unit”; DO NOT EDIT.
// Copyright ©2014 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -90,6 +89,5 @@ func (t Time) Format(fs fmt.State, c rune) {
fmt.Fprint(fs, " s")
default:
fmt.Fprintf(fs, "%%!%c(%T=%g s)", c, t, float64(t))
return
}
}