-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lapack/netlib: autogenerate errors strings from gonum copy
- Loading branch information
Showing
5 changed files
with
133 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright ©2018 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. | ||
|
||
//go:generate go run generate_errors.go | ||
|
||
package netlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright ©2018 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 ( | ||
"fmt" | ||
"go/parser" | ||
"go/printer" | ||
"go/token" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
const errorFile = "../../../gonum/lapack/gonum/errors.go" | ||
|
||
func main() { | ||
path, err := filepath.Abs(errorFile) | ||
if err != nil { | ||
log.Fatalf("no absolute path for %q: %v", errorFile, err) | ||
} | ||
|
||
fset := token.NewFileSet() | ||
f, err := parser.ParseFile(fset, path, nil, 0) | ||
if err != nil { | ||
log.Fatalf("failed to parse %q: %v", path, err) | ||
} | ||
|
||
dst := filepath.Base(errorFile) | ||
o, err := os.Create(dst) | ||
if err != nil { | ||
log.Fatalf("failed to create %q: %v", dst, err) | ||
} | ||
defer o.Close() | ||
|
||
fmt.Fprintln(o, header) | ||
p := printer.Config{ | ||
Mode: printer.UseSpaces | printer.TabIndent, | ||
Tabwidth: 8, | ||
} | ||
p.Fprint(o, fset, f.Decls) | ||
fmt.Fprintln(o) | ||
} | ||
|
||
const header = `// Code generated by "go generate gonum.org/v1/netlib/lapack/netlib”; DO NOT EDIT. | ||
// Copyright ©2018 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. | ||
package netlib | ||
// Copied from gonum/lapack/gonum. Keep in sync.` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters