summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-17 06:34:27 -0600
committerJeff Carr <[email protected]>2024-12-17 06:34:27 -0600
commit84c25d74da64460dc9c92cc05f78d288d3f8f59f (patch)
tree80b2809f3678c156eaa421079f3d93e7f3cb0c17
parent50cafc85178b8fee356c6b3b0ac38e0a110841e1 (diff)
lots of fixes in gitpbv0.0.31
-rw-r--r--argv.go2
-rw-r--r--main.go22
-rw-r--r--protoc.go10
3 files changed, 17 insertions, 17 deletions
diff --git a/argv.go b/argv.go
index 94d047c..7615b74 100644
--- a/argv.go
+++ b/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 {
diff --git a/main.go b/main.go
index 9fa2c01..064953a 100644
--- a/main.go
+++ b/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,17 +51,16 @@ 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 argv.GoSrc == "" {
+ argv.GoSrc = "/home/jcarr/go/src"
+ }
- 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.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"})
@@ -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"))
diff --git a/protoc.go b/protoc.go
index af7e0d1..53955e3 100644
--- a/protoc.go
+++ b/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
}