lots of fixes in gitpb
This commit is contained in:
parent
50cafc8517
commit
84c25d74da
Notes:
Jeff Carr
2024-12-17 22:11:50 -06:00
// `autogen:go.mod` module go.wit.com/apps/autogenpb go 1.21 toolchain go1.23.4 require ( github.com/alexflint/go-arg v1.5.1 github.com/go-cmd/cmd v1.4.3 go.wit.com/lib/gui/shell v0.22.18 go.wit.com/log v0.22.9 golang.org/x/text v0.21.0 ) require github.com/alexflint/go-scalar v1.2.0 // indirect // `autogen:go.sum` github.com/alexflint/go-arg v1.5.1 h1:nBuWUCpuRy0snAG+uIJ6N0UvYxpxA0/ghA/AaHxlT8Y= github.com/alexflint/go-arg v1.5.1/go.mod h1:A7vTJzvjoaSTypg4biM5uYNTkJ27SkNTArtYXnlqVO8= github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw= github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y= github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= go.wit.com/lib/gui/shell v0.22.18 h1:2z14XRxGrNjRKVsfvlk70sWsRZWoLdnL7z0FS+BFzFM= go.wit.com/lib/gui/shell v0.22.18/go.mod h1:zduuMSWq+EE7w0xbXn+vkoGZ4HJhURVJpvXw8oK9WAU= go.wit.com/log v0.22.9 h1:aBM6SI2kxlJcBfS/osFTomJqNhO0hfEo1gk+LCqLk7Y= go.wit.com/log v0.22.9/go.mod h1:4uNPFBqhsAh8zNF+zxVEmC3c/9AZ8JeTfUUvRpddvLQ= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= // `autogen:`
2
argv.go
2
argv.go
|
@ -19,6 +19,8 @@ type args struct {
|
|||
NoSort bool `arg:"--no-sort" help:"do not make a sort.pb.go file"`
|
||||
Mutex bool `arg:"--mutex" help:"try mutex hack (breaks proto.Marshal()"`
|
||||
DryRun bool `arg:"--dry-run" help:"show what would be run"`
|
||||
GoSrc string `arg:"--go-src" help:"default is ~/go/src. could be set to your go.work path"`
|
||||
GoPath string `arg:"--gopath" help:"the gopath of this repo"`
|
||||
}
|
||||
|
||||
func (a args) Description() string {
|
||||
|
|
24
main.go
24
main.go
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/alexflint/go-arg"
|
||||
"github.com/go-cmd/cmd"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
|
@ -22,7 +21,6 @@ var VERSION string
|
|||
var BUILDTIME string
|
||||
|
||||
var sortmap map[string]string
|
||||
var forge *forgepb.Forge // forgepb figures out how to run protoc correctly if it's needed
|
||||
var marshalKeys []string
|
||||
var uniqueKeys []string
|
||||
|
||||
|
@ -53,18 +51,17 @@ func main() {
|
|||
os.Exit(-1)
|
||||
}
|
||||
|
||||
// have to figure out how to run protoc so initialize forge
|
||||
forge = forgepb.Init()
|
||||
|
||||
gosrc := forge.GetGoSrc()
|
||||
pwd, _ := os.Getwd()
|
||||
|
||||
if strings.HasPrefix(pwd, gosrc) {
|
||||
log.Info("does match", pwd, "vs", gosrc)
|
||||
} else {
|
||||
log.Info("does not match. should exit(-1) here", pwd, "vs", gosrc)
|
||||
if argv.GoSrc == "" {
|
||||
argv.GoSrc = "/home/jcarr/go/src"
|
||||
}
|
||||
|
||||
if argv.GoPath == "" {
|
||||
pwd, _ := os.Getwd()
|
||||
argv.GoPath = strings.TrimPrefix(pwd, argv.GoSrc)
|
||||
argv.GoPath = strings.Trim(argv.GoPath, "/")
|
||||
}
|
||||
log.Info(argv.GoSrc, argv.GoPath)
|
||||
|
||||
if !shell.Exists("go.sum") {
|
||||
shell.RunQuiet([]string{"go", "mod", "init"})
|
||||
shell.RunQuiet([]string{"go", "mod", "tidy"})
|
||||
|
@ -73,7 +70,8 @@ func main() {
|
|||
|
||||
var result cmd.Status
|
||||
var cmd []string
|
||||
if forge.IsGoWork() {
|
||||
// if forge.IsGoWork() {
|
||||
if false {
|
||||
cmd = []string{"go", "work", "use"}
|
||||
result = shell.Run(cmd)
|
||||
log.Info(strings.Join(result.Stdout, "\n"))
|
||||
|
|
10
protoc.go
10
protoc.go
|
@ -36,13 +36,13 @@ func protocBuild(names map[string]string) error {
|
|||
// return nil
|
||||
}
|
||||
log.Info("make protoc file:", names["protoc"])
|
||||
log.Info("go src", forge.GetGoSrc())
|
||||
// log.Info("go src", forge.GetGoSrc())
|
||||
pwd, _ := os.Getwd()
|
||||
log.Info("go.Getwd()", pwd)
|
||||
if !strings.HasPrefix(pwd, forge.GetGoSrc()) {
|
||||
if !strings.HasPrefix(pwd, argv.GoSrc) {
|
||||
return errors.New("paths don't match")
|
||||
}
|
||||
gopath := strings.TrimPrefix(pwd, forge.GetGoSrc())
|
||||
gopath := strings.TrimPrefix(pwd, argv.GoSrc)
|
||||
gopath = strings.Trim(gopath, "/")
|
||||
log.Info("gopath", gopath)
|
||||
cmd := []string{"protoc", "--go_out=."}
|
||||
|
@ -84,10 +84,10 @@ func protocBuild(names map[string]string) error {
|
|||
}
|
||||
|
||||
cmd = append(cmd, names["protofile"])
|
||||
log.Info("\tpwd", forge.GetGoSrc())
|
||||
log.Info("\tpwd", argv.GoSrc)
|
||||
for i, s := range cmd {
|
||||
log.Info("\t", i, s)
|
||||
}
|
||||
shell.PathRun(forge.GetGoSrc(), cmd)
|
||||
shell.PathRun(argv.GoSrc, cmd)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue