diff options
| author | Jeff Carr <[email protected]> | 2024-11-30 12:17:38 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-30 12:17:38 -0600 |
| commit | dc356e9d0fc6b05f50b01d141206f679ecda2de9 (patch) | |
| tree | a875c8f8288f0a7292bac99176894a3b7fd07426 /protoc.go | |
| parent | 10cf601ea03e92323d802391a437f335924e5107 (diff) | |
auto run protoc
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'protoc.go')
| -rw-r--r-- | protoc.go | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/protoc.go b/protoc.go new file mode 100644 index 0000000..f3b545d --- /dev/null +++ b/protoc.go @@ -0,0 +1,68 @@ +package main + +// auto run protoc with the correct args + +import ( + "errors" + "os" + + "go.wit.com/lib/gui/shell" + "go.wit.com/lib/protobuf/forgepb" + "go.wit.com/log" +) + +// test.pb.go: test.proto +// cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/apps/autogenpb/testautogen \ +// --go_opt=Mtest.proto=go.wit.com/apps/autogenpb/testautogen \ +// test.proto + +// forgeConfig.pb.go: forgeConfig.proto +// cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/apps/autogenpb/testautogen \ +// --go_opt=MforgeConfig.proto=go.wit.com/apps/autogenpb/testautogen \ +// forgeConfig.proto + +func protocBuild(names map[string]string) error { + // have to figure out how to run protoc so initialize forge + forge = forgepb.Init() + // forge.ConfigPrintTable() + os.Setenv("REPO_WORK_PATH", forge.GetGoSrc()) + + log.Info("") + if shell.Exists(names["protoc"]) { + log.Info("protoc file already created", names["protoc"]) + return nil + } + log.Info("make protoc file:", names["protoc"]) + log.Info("go src", forge.GetGoSrc()) + 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) + + var found bool + + lines := strings.Split(string(data), "\n") + for _, line := range lines { + // log.Info("line:", line) + start := "type " + names["Bases"] + " struct {" + if strings.HasSuffix(line, start) { + found = true + log.Info("FOUND line:", line) + fmt.Fprintln(w, line) + fmt.Fprintln(w, "\tsync.RWMutex // auto-added by go.wit.com/apps/autogenpb") + fmt.Fprintln(w, "") + } else { + fmt.Fprintln(w, line) + } + } + // os.Exit(-1) + if found { + return nil + } + */ |
