// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main // An app to submit patches for the 30 GO GUI repos import ( "errors" "fmt" "os" "go.wit.com/lib/fhelp" "go.wit.com/lib/gui/shell" "go.wit.com/log" ) // download forge. A good way to check things work func doRebuild() (string, error) { var s string var err error if argv.Rebuild.Forge != nil { s, err = doRebuildForge() } return s, err } func doRebuildForge() (string, error) { log.Info("download here") if path, err := fhelp.CheckCmd("goimports"); err != nil { log.Info("go-clone missing", path, err) cmd := []string{"go", "install", "golang.org/x/tools/cmd/goimports@latest"} shell.RunRealtime(cmd) } if path, err := fhelp.CheckCmd("go-clone"); err != nil { log.Info("go-clone missing", path, err) cmd := []string{"go", "install", "go.wit.com/apps/go-clone@latest"} shell.RunRealtime(cmd) } if _, err := fhelp.CheckCmd("autogenpb"); err != nil { cmd := []string{"go", "install", "go.wit.com/apps/autogenpb@latest"} shell.RunRealtime(cmd) } if _, err := fhelp.CheckCmd("go-mod-clean"); err != nil { cmd := []string{"go", "install", "go.wit.com/apps/go-mod-clean@latest"} shell.RunRealtime(cmd) } if path, err := fhelp.CheckCmd("go-clone"); err != nil { pfile, _ := resources.ReadFile("resources/GOPATH") log.Info("") log.Info(string(pfile)) log.Info("may be at:", path) s := fmt.Sprintf("setup PATH") return s, errors.New("prep build failed") } var basecmd []string var cmd []string if me.forge.IsGoWork() { log.Info("Using go.work directory") basecmd = []string{"go-clone", "--work"} } else { basecmd = []string{"go-clone"} } // log.Info("Running:", cmd) // shell.RunRealtime(cmd) r := shell.Run([]string{"forge", "show"}) if r.Error != nil { return "download go-mod-clean failed", r.Error } cmd = append(basecmd, "go.wit.com/apps/go-mod-clean") log.Info("Running:", cmd) r = shell.RunRealtime(cmd) if r.Error != nil { return "download go-mod-clean failed", r.Error } cmd = append(basecmd, "go.wit.com/apps/autogenpb") log.Info("Running:", cmd) r = shell.RunRealtime(cmd) if r.Error != nil { return "download autogenpb failed", r.Error } cmd = append(basecmd, "go.wit.com/apps/forge") log.Info("Running:", cmd) r = shell.RunRealtime(cmd) if r.Error != nil { me.sh.BadExit("download forge failed", r.Error) } cmd = append(basecmd, "go.wit.com/toolkits/gocui") log.Info("Running:", cmd) r = shell.RunRealtime(cmd) if r.Error != nil { me.sh.BadExit("download CUI GO plugin toolkit failed", r.Error) } cmd = append(basecmd, "go.wit.com/toolkits/andlabs") log.Info("Running:", cmd) r = shell.RunRealtime(cmd) if r.Error != nil { me.sh.BadExit("download GTK GO plugin toolkit failed", r.Error) } if (me.forge == nil) || (me.forge.Repos == nil) { log.Info("RUN forge --rebuild again. it might work after a few tries") return "forge is new. this may not work yet", errors.New("forge init not working yet") } repo := me.forge.Repos.FindByNamespace("go.wit.com/apps/forge") if repo == nil { r := shell.Run([]string{"forge", "show"}) return "failed the first go around. run it again. this feature is new", r.Error } // yay. it might work os.Chdir(repo.FullPath) r = shell.Run([]string{"make", "generate"}) return "make generate might have worked", r.Error }