integrating generate invocation into version.go

so go generate . regenerates generated code and even installs it all in one. Take that, rustaceans, cultists of cargo
This commit is contained in:
херетик
2023-02-20 14:01:53 +00:00
parent ce2bf6bc87
commit 0086d170c2
5 changed files with 36 additions and 19 deletions

View File

@@ -15,11 +15,11 @@ import (
"path/filepath"
"strings"
"time"
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"git-indra.lan/indra-labs/indra"
log2 "git-indra.lan/indra-labs/indra/pkg/proc/log"
)
@@ -183,6 +183,18 @@ func main() {
name := filepath.Base(dir)
versionFile := `package ` + name + `
// Put invocations to run all the generators in here (
// check cmd/bumper/ to add them, and they will automatically run with:
//
// $ go generate .
//
// which will run all these generators below and finish with a go install.` +
`//go:generate go run ./pkg/relay/gen/main.go
// Lastly install
` + `//go:generate go install -v ./...
import (
"fmt"
)

View File

@@ -1,3 +1,5 @@
//go:build ignore
package main
import (
@@ -33,8 +35,6 @@ func main() {
sort.Strings(typesList)
tpl := `package relay
//go:generate go run ./gen/main.go
import (
"fmt"
@@ -77,7 +77,7 @@ func Peel(b slice.Bytes, c *slice.Cursor) (on types.Onion, e error) {
if check(e) {
panic(e)
}
const filename = "peel.go"
const filename = "pkg/relay/peel.go"
f, err := os.Create(filename)
if check(err) {
panic(err)
@@ -86,7 +86,7 @@ func Peel(b slice.Bytes, c *slice.Cursor) (on types.Onion, e error) {
panic(e)
}
_ = f.Close()
if e = runCmd("go", "fmt", filename); e != nil {
if e = runCmd("go", "fmt", filename); check(e) {
os.Exit(1)
}
typesList2 := handlemessages{
@@ -106,8 +106,6 @@ func Peel(b slice.Bytes, c *slice.Cursor) (on types.Onion, e error) {
tpl = `package relay
//go:generate go run ./gen/main.go
import (
"reflect"
@@ -150,7 +148,7 @@ func (eng *Engine) handleMessage(b slice.Bytes, prev types.Onion) {
if check(e) {
panic(e)
}
const handlemessage = "handlemessage.go"
const handlemessage = "pkg/relay/handlemessage.go"
f, e = os.Create(handlemessage)
if check(e) {
panic(e)
@@ -158,7 +156,7 @@ func (eng *Engine) handleMessage(b slice.Bytes, prev types.Onion) {
if e = t.Execute(f, typesList2); check(e) {
panic(e)
}
if e = runCmd("go", "fmt", handlemessage); e != nil {
if e = runCmd("go", "fmt", handlemessage); check(e) {
panic(e)
}
}

View File

@@ -1,7 +1,5 @@
package relay
//go:generate go run ./gen/main.go
import (
"reflect"

View File

@@ -1,7 +1,5 @@
package relay
//go:generate go run ./gen/main.go
import (
"fmt"

View File

@@ -1,5 +1,16 @@
package indra
// Put invocations to run all the generators in here (
// check cmd/bumper/ to add them, and they will automatically run with:
//
// $ go generate .
//
// which will run all these generators below and finish with a go install.//go:generate go run ./pkg/relay/gen/main.go
// Lastly install
//go:generate go install -v ./...
import (
"fmt"
)
@@ -8,13 +19,13 @@ var (
// URL is the git URL for the repository.
URL = ""
// GitRef is the gitref, as in refs/heads/branchname.
GitRef = "refs/heads/main"
GitRef = "refs/heads/protocol"
// ParentGitCommit is the commit hash of the parent HEAD.
ParentGitCommit = "12c1ba34bfdbcfd0ea7e8f4126e8f31ce7d2fb5f"
ParentGitCommit = "ce2bf6bc871f68e0996a018138fb8ac2dc3098c7"
// BuildTime stores the time when the current binary was built.
BuildTime = "2023-02-16T02:34:17Z"
BuildTime = "2023-02-20T14:01:53Z"
// SemVer lists the (latest) git tag on the release.
SemVer = "v0.0.8"
SemVer = "v0.0.9"
// PathBase is the path base returned from runtime caller.
PathBase = "/opt/indra-labs/indra/"
// Major is the major number from the tag.
@@ -22,7 +33,7 @@ var (
// Minor is the minor number from the tag.
Minor = 0
// Patch is the patch version number from the tag.
Patch = 8
Patch = 9
)
// Version returns a pretty printed version information string.