From 5db343390beb9a59722849093584b7aabf5676e3 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 25 Nov 2024 01:52:49 -0600 Subject: [PATCH] try to build the protobuf files --- globalBuildOptions.go | 36 ---------------------- globalResetOptions.go | 17 ----------- rebuildAutotypist.go | 69 +++++++++++++++++++++++++++++++++++++++++++ shell.go | 34 --------------------- 4 files changed, 69 insertions(+), 87 deletions(-) create mode 100644 rebuildAutotypist.go delete mode 100644 shell.go diff --git a/globalBuildOptions.go b/globalBuildOptions.go index 2ae0326..b3e1fae 100644 --- a/globalBuildOptions.go +++ b/globalBuildOptions.go @@ -193,39 +193,3 @@ func globalBuildOptions(vbox *gui.Node) { }) grid.NextRow() } - -// this code isn't ready yet -/* - s.checkB = s.grid.NewButton("Check repos are working", func() { - me.Disable() - defer me.Enable() - for loop.Scan() { - if repo.GitURL() != "" { - log.Info("repo already checked. do they match?") - log.Info("go.wit.com =", repo.GoURL()) - log.Info("localurl =", repo.Path()) - } else { - ok, giturl := gowit.CheckRegistered(repo) - if ok { - log.Info("is url correct?", repo.Path(), "vs", giturl) - repo.giturl = giturl - if giturl != repo.Path() { - log.Info("repo check failed", repo.String()) - s.unknownOL.SetText(repo.String()) - s.unknownOL.Show() - s.unknownSubmitB.Show() - return - } - } else { - log.Info("repo check failed", repo.String()) - repo.giturl = "look in .git/config" - s.unknownOL.SetText(repo.String()) - s.unknownOL.Show() - s.unknownSubmitB.Show() - return - } - } - } - s.checkB.SetText("GOOD") - }) -*/ diff --git a/globalResetOptions.go b/globalResetOptions.go index d6ab747..aafa51f 100644 --- a/globalResetOptions.go +++ b/globalResetOptions.go @@ -158,20 +158,3 @@ func globalResetOptions(box *gui.Node) { } }) } - -func attemptAutoRebuild() { - gosrc := me.goSrcPwd.String() - - quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/apps/autotypist"}) - quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/debian"}) - quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/tree"}) - quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/nocui"}) - quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/gocui"}) - quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/andlabs"}) - - quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/nocui/"), []string{"make"}) - quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/gocui/"), []string{"make"}) - quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/andlabs/"), []string{"make"}) - - quickCmd(filepath.Join(gosrc, "go.wit.com/apps/autotypist/"), []string{"make", "build"}) -} diff --git a/rebuildAutotypist.go b/rebuildAutotypist.go new file mode 100644 index 0000000..10dcaa4 --- /dev/null +++ b/rebuildAutotypist.go @@ -0,0 +1,69 @@ +package main + +import ( + "path/filepath" + "strings" + "github.com/go-cmd/cmd" + + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +// attempt to rebuild this app +// This should work from a blank slate +// TODO: make sure this works in a empty directory with a go-work file + +func attemptAutoRebuild() bool { + gosrc := me.goSrcPwd.String() + + if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/apps/autotypist"}); !ok { return buildDied(r) } + if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/debian"}); !ok { return buildDied(r) } + if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/tree"}); !ok { return buildDied(r) } + if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/nocui"}); !ok { return buildDied(r) } + if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/gocui"}); !ok { return buildDied(r) } + if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/andlabs"}); !ok { return buildDied(r) } + + if r, ok := quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/nocui/"), []string{"make"}); !ok { return buildDied(r) } + if r, ok := quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/gocui/"), []string{"make"}); !ok { return buildDied(r) } + if r, ok := quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/andlabs/"), []string{"make"}); !ok { return buildDied(r) } + + // build the protobuf files + // TODO: verify the right protoc-gen-go exists + if !shell.Exists("/usr/bin/protoc-gen-go") { + log.Warn("missing /usr/bin/protc-gen-go. apt install protoc-gen-go") + return false + } + quickCmd(filepath.Join(gosrc, "go.wit.com/lib/protobuf/virtbuf/"), []string{"make"}) + quickCmd(filepath.Join(gosrc, "go.wit.com/apps/autotypist/"), []string{"make", "build"}) + return true +} + +// only errors on bad errors +func quickCmd(fullpath string, cmd []string) (*cmd.Status, bool) { + if me.autoDryRun.Checked() { + log.Warn("RUN --dry-run", fullpath, cmd) + return nil, true + } else { + log.Warn("RUN:", fullpath, cmd) + } + + r := shell.PathRun(fullpath, cmd) + output := strings.TrimSpace(strings.Join(r.Stdout, "\n")) + if r.Error != nil { + log.Warn("cmd =", cmd) + log.Warn("err =", r.Error) + log.Warn("b =", r.Exit) + log.Warn("output =", output) + return &r, false + } else if r.Exit != 0 { + log.Warn("b =", r.Exit) + log.Warn("output =", output) + return &r, true + } + log.Warn("output = ", output) + return &r, true +} + +func buildDied(r *cmd.Status) bool { + return false +} diff --git a/shell.go b/shell.go deleted file mode 100644 index c3bb264..0000000 --- a/shell.go +++ /dev/null @@ -1,34 +0,0 @@ -package main - -import ( - "strings" - - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - -// only errors on bad errors -func quickCmd(fullpath string, cmd []string) bool { - if me.autoDryRun.Checked() { - log.Warn("RUN --dry-run", fullpath, cmd) - return false - } else { - log.Warn("RUN:", fullpath, cmd) - } - - r := shell.PathRun(fullpath, cmd) - output := strings.TrimSpace(strings.Join(r.Stdout, "\n")) - if r.Error != nil { - log.Warn("cmd =", cmd) - log.Warn("err =", r.Error) - log.Warn("b =", r.Exit) - log.Warn("output =", output) - return false - } else if r.Exit != 0 { - log.Warn("b =", r.Exit) - log.Warn("output =", output) - return true - } - log.Warn("output = ", output) - return true -}