have to auto run protoc

This commit is contained in:
Jeff Carr 2024-11-30 12:44:04 -06:00
parent dc356e9d0f
commit d24d836899
1 changed files with 35 additions and 26 deletions

View File

@ -5,6 +5,7 @@ package main
import ( import (
"errors" "errors"
"os" "os"
"strings"
"go.wit.com/lib/gui/shell" "go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/forgepb"
@ -34,35 +35,43 @@ func protocBuild(names map[string]string) error {
} }
log.Info("make protoc file:", names["protoc"]) 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()) {
return errors.New("paths don't match")
}
gopath := strings.TrimPrefix(pwd, forge.GetGoSrc())
log.Info("gopath", gopath)
return errors.New("make protoc here") return errors.New("make protoc here")
} }
/*
data, err := os.ReadFile(fullname)
if err != nil {
// log.Info("open config file :", err)
return err
}
w, _ := os.OpenFile(names["protobase"]+".pb.go", os.O_WRONLY|os.O_CREATE, 0600) /*
data, err := os.ReadFile(fullname)
if err != nil {
// log.Info("open config file :", err)
return err
}
var found bool w, _ := os.OpenFile(names["protobase"]+".pb.go", os.O_WRONLY|os.O_CREATE, 0600)
lines := strings.Split(string(data), "\n") var found bool
for _, line := range lines {
// log.Info("line:", line) lines := strings.Split(string(data), "\n")
start := "type " + names["Bases"] + " struct {" for _, line := range lines {
if strings.HasSuffix(line, start) { // log.Info("line:", line)
found = true start := "type " + names["Bases"] + " struct {"
log.Info("FOUND line:", line) if strings.HasSuffix(line, start) {
fmt.Fprintln(w, line) found = true
fmt.Fprintln(w, "\tsync.RWMutex // auto-added by go.wit.com/apps/autogenpb") log.Info("FOUND line:", line)
fmt.Fprintln(w, "") fmt.Fprintln(w, line)
} else { fmt.Fprintln(w, "\tsync.RWMutex // auto-added by go.wit.com/apps/autogenpb")
fmt.Fprintln(w, line) fmt.Fprintln(w, "")
} } else {
fmt.Fprintln(w, line)
} }
// os.Exit(-1) }
if found { // os.Exit(-1)
return nil if found {
} return nil
*/ }
*/